How Multibranch Product Sync Works
Source: products_controller.rb:22, products_controller.rb:226, products_controller.rb:733, products_controller.rb:742-746
- Multibranch product sync triggers automatically on both product create and update when dealer/branch conditions are met
- A comprehensive list of protected fields cannot be overwritten by the sync: id, company_id, branch_link, vendor_id, quantity_on_hand, costs, and all accounting integration IDs (Xero/MYOB/QBO)
- The sync prevents blanking out fields that already have values at the receiving branch -- changes that would clear existing data are reverted and logged
- When a branch product is created by a dealer branch owner, it is auto-flagged with is_branch_product = true (requires all three conditions: is_dealer_multibranch_version, is_branch_owner, is_dealer)
- Multibranch product list includes head office products not yet copied locally, using a NOT EXISTS subquery
Support scenarios
- "Why did a product I created at head office appear at my branch store?" → Multibranch sync automatically propagates products to linked branches
- "Why didn't the vendor/cost/stock change when head office updated the product?" → Vendor, cost, and stock fields are protected from sync to preserve local values
- "Why is my product marked as a branch product?" → It was created by a dealer branch owner with all multibranch conditions met
- "Why am I seeing products from head office in my product list?" → Multibranch mode shows head office products that have not been copied locally yet