Compare commits

..

1 Commits
19.0 ... 17.0

Author SHA1 Message Date
00c6377eef [REF] Refactor module for Odoo 17 compatibility 2026-06-20 12:54:34 +07:00
2 changed files with 30 additions and 30 deletions

View File

@ -5,9 +5,9 @@ This Odoo 19 module automatically shares and synchronizes company-dependent prod
## Overview
In Odoo, standard product templates (`product.template`) and product categories (`product.category`) are globally accessible if their `company_id` is set to `False` (empty). However, accounting, taxes, location routing, and manufacturing recipes remain company-dependent:
1. **Accounting Accounts**: Stored as `jsonb` fields on the model in Odoo 19, mapping company IDs directly to account record IDs.
2. **Taxes & Routes**: Many-to-many relationships where each company must map its own specific records.
3. **Bill of Materials (BOM)**: Explicitly linked to a company, requiring child branches to duplicate manufacturing structures if they wish to produce locally.
**Accounting Accounts**: Stored as `jsonb` fields on the model in Odoo 19, mapping company IDs directly to account record IDs.
**Taxes & Routes**: Many-to-many relationships where each company must map its own specific records.
**Bill of Materials (BOM)**: Explicitly linked to a company, requiring child branches to duplicate manufacturing structures if they wish to produce locally.
This module automates the propagation of these settings and structures down the company hierarchy, minimizing manual configuration errors across multiple branch companies.
@ -18,41 +18,41 @@ Propagates all settings down the active company's branch hierarchy recursively u
### 🧮 Product Category Sync (`product.category`)
Synchronizes the following fields from the parent category to branch categories:
- **Inventory Valuation**: Periodic or Automated (`property_valuation`)
- **Costing Method**: Standard, Average (AVCO), or FIFO (`property_cost_method`)
- **Income Account** (`property_account_income_categ_id`)
- **Expense Account** (`property_account_expense_categ_id`)
- **Price Difference Account** (`property_price_difference_account_id`)
- **Stock Production Cost Account** (`property_stock_account_production_cost_id`)
- **Stock Valuation Account** (`property_stock_valuation_account_id`)
- **Note**: `account_stock_variation_id` (Stock Variation Account) in Odoo 19 is a global field (`company_dependent=False`) and is shared automatically without additional sync code.
- **Valuation Journal Excluded**: The Stock Journal (`property_stock_journal`) is completely excluded from the sync to remain branch-company specific.
**Inventory Valuation**: Periodic or Automated (`property_valuation`)
**Costing Method**: Standard, Average (AVCO), or FIFO (`property_cost_method`)
**Income Account** (`property_account_income_categ_id`)
**Expense Account** (`property_account_expense_categ_id`)
**Price Difference Account** (`property_price_difference_account_id`)
**Stock Production Cost Account** (`property_stock_account_production_cost_id`)
**Stock Valuation Account** (`property_stock_valuation_account_id`)
**Note**: `account_stock_variation_id` (Stock Variation Account) in Odoo 19 is a global field (`company_dependent=False`) and is shared automatically without additional sync code.
**Valuation Journal Excluded**: The Stock Journal (`property_stock_journal`) is completely excluded from the sync to remain branch-company specific.
### 📦 Product Template Sync (`product.template`)
Synchronizes the following fields from the parent product template to branch templates:
- **Income Account** (`property_account_income_id`)
- **Expense Account** (`property_account_expense_id`)
- **Price Difference Account** (`property_price_difference_account_id`)
- **Stock Inventory Location** (`property_stock_inventory`)
- **Stock Production Location** (`property_stock_production`)
- **Customer Taxes** (`taxes_id`) & **Vendor Taxes** (`supplier_taxes_id`)
- **Logistics Routes** (`route_ids`)
- **Note**: Many-to-Many taxes and routes updates are performed safely to prevent standard Odoo writes from clearing the mappings of other unrelated branch companies.
- **Cost Price Excluded**: Cost price (`standard_price`) is excluded from synchronization to allow branch-specific costing.
**Income Account** (`property_account_income_id`)
**Expense Account** (`property_account_expense_id`)
**Price Difference Account** (`property_price_difference_account_id`)
**Stock Inventory Location** (`property_stock_inventory`)
**Stock Production Location** (`property_stock_production`)
**Customer Taxes** (`taxes_id`) & **Vendor Taxes** (`supplier_taxes_id`)
**Logistics Routes** (`route_ids`)
**Note**: Many-to-Many taxes and routes updates are performed safely to prevent standard Odoo writes from clearing the mappings of other unrelated branch companies.
**Cost Price Excluded**: Cost price (`standard_price`) is excluded from synchronization to allow branch-specific costing.
### 🔨 Bill of Materials (BOM) Sync (`mrp.bom`)
Synchronizes manufacturing recipes and component lines recursively:
- **Recipe Structures**: Replicates `mrp.bom` records and their ingredient lines (`mrp.bom.line`) to branch companies.
- **Parent Tracking**: Automatically maps and tracks branch records to their parent via a custom field (`parent_bom_id`) complete with cascade deletion.
- **Hierarchical Company Matching**: Implements custom compatibility matching that respects Odoo's multi-company visibility. BOMs are replicated if the main product template and all ingredient component products are either global or belong to a parent/ancestor company of the branch (e.g. products and ingredients owned by the parent company `OT` can be safely used inside BOM records created for the child branch `Mie Mapan Barata`). This strictly satisfies Odoo's internal `_check_company` constraints while maintaining centralized recipe ownership.
**Recipe Structures**: Replicates `mrp.bom` records and their ingredient lines (`mrp.bom.line`) to branch companies.
**Parent Tracking**: Automatically maps and tracks branch records to their parent via a custom field (`parent_bom_id`) complete with cascade deletion.
**Hierarchical Company Matching**: Implements custom compatibility matching that respects Odoo's multi-company visibility. BOMs are replicated if the main product template and all ingredient component products are either global or belong to a parent/ancestor company of the branch.
### 🔄 Intelligent Branch Counterpart Matching
When mapping a parent company record to a child company:
1. **Accounts**: Matches by account `code`. (Falls back to the parent record if no branch-specific account is found, as accounts in Odoo 19 can be shared across companies).
2. **Taxes**: Matches by tax `name`, `type_tax_use`, `amount`, and `amount_type`.
3. **Routes**: Matches by route `name`.
4. **Locations**: Matches by `complete_name` first, then by `name`.
5. **Universal Fallback**: If no specific branch-company counterpart exists, the sync falls back to preserving the parent record value for the branch (to support setups where branch companies share the parent company's chart of accounts and taxes).
**Accounts**: Matches by account `code`.
**Taxes**: Matches by tax `name`, `type_tax_use`, `amount`, and `amount_type`.
**Routes**: Matches by route `name`.
**Locations**: Matches by `complete_name` first, then by `name`.
**Universal Fallback**: If no specific branch-company counterpart exists, the sync falls back to preserving the parent record value for the branch.
## Installation

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
{
'name': 'Multi-Company Product & Category Settings Sync',
'version': '19.0.1.0.0',
'version': '17.0.1.0.0',
'summary': 'Automatically share and synchronize product and product category settings from parent company to branch companies recursively.',
'description': """
Multi-Company Product & Category Settings Sync