How Multibranch Reverse Sync and Blank Prevention Works
Source: products_controller.rb:693-712, products_controller.rb:742-746, products_controller.rb:115-158
- When a sync detects "prevented changes" (fields being blanked that already have values), a reverse sync runs to propagate the non-blank values back to the originating product and all other branches
- This means if you try to clear a product field at one branch, the system may restore it from the value at another branch
- Branch push-down is a separate process: only branch owners can push down, and for each franchise company it finds or creates the product by item_code, finds or creates matching product group and category, then updates description, prices, costs, etc.
- Push-down creates the entire group/category hierarchy at the receiving branch if it does not exist
- The push-down operation is one-directional from head office to branches, unlike the bidirectional regular sync
Support scenarios
- "Why did a product field I tried to clear get restored?" → The reverse sync detected a blank-out attempt and propagated the non-blank value back from another branch
- "Why can't I clear a product field from the branch?" → The sync prevents overwriting existing values with blank values; reverse sync restores them
- "How does 'push down' work for branch products?" → Head office pushes product details, groups, and categories to all franchise companies; it creates missing groups/categories automatically
- "Product at branch has different details than head office" → Protected fields (costs, stock, vendor, accounting IDs) are excluded from sync by design