-
- Downloads
[FIX] purchase_{stock,mrp}: compute price difference of a kit
In automated-AVCO configuration, buying a kit at a higher price than its cost can create inconsistencies in the accounting. To reproduce the issue: (Need account_accountant. Use demo data) 1. Create a product category PC: - Costing Method: AVCO - Inventory Valuation: Automated - Set up the Price Difference Account PDA 2. Create 3 products P_kit, P_compo01, P_compo02 - Type: Storable - Category: PC - P_compo01: - Cost: 10 - P_compo02: - Cost: 20 3. Create a bill of materials: - Product: P_kit - Type: Kit - Components: - 1 x P_compo01 - 1 x P_compo02 4. On P_kit's form, "Compute Price from BoM": - The cost should be $30 5. Create a purchase order PO with one line: - Product: P_kit - Quantity: 1 - Unit Price: 100 6. Confirm PO and process the receipt 7. Create and Post the bill Error: There is an error in the journal items of the bill: the value for PDA is $85 When posting the bill, for each account move line, the module computes the stock valuation of the associated product and the price difference. To do so, it sums the valuation of all related outgoing stock moves and divides by the quantity to get the value per unit, then it compares with the unit price used on the PO's line. Here is the issue: in case of a kit, there is one outgoing move per component while the PO's line is linked to the kit itself. Therefore, in the above case, it uses the outgoing moves of P_compo01 and P_compo02, adds up their value ($10 + $20 = $30) and then divides by the total quantity (one P_compo01 and one P_compo02, thus $30 / 2 = $15). This is the reason why it considers that the unit value of P_kit equals $15. Then, since the unit price on the PO's line is $100, it gets a price difference value equal to $85. When comparing the unit value of the kit and its unit price, the unit value should not be divided by the quantity of components ($30 should not be divided by 2). Moreover, when buying such a kit at $100, the surplus ($70) should be distributed among each component. However, it is difficult to define a rule to correctly weight this distribution. Therefore, this surplus will be considered as a price difference. OPW-2566546 closes odoo/odoo#82318 X-original-commit: 75191404 Signed-off-by:Arnold Moyaux <arm@odoo.com> Signed-off-by:
Adrien Widart <awt@odoo.com>
Showing
- addons/purchase_mrp/models/stock_move.py 13 additions, 0 deletionsaddons/purchase_mrp/models/stock_move.py
- addons/purchase_mrp/tests/__init__.py 1 addition, 0 deletionsaddons/purchase_mrp/tests/__init__.py
- addons/purchase_mrp/tests/test_anglo_saxon_valuation.py 78 additions, 0 deletionsaddons/purchase_mrp/tests/test_anglo_saxon_valuation.py
- addons/purchase_stock/models/account_invoice.py 2 additions, 19 deletionsaddons/purchase_stock/models/account_invoice.py
- addons/purchase_stock/models/stock.py 23 additions, 1 deletionaddons/purchase_stock/models/stock.py
Loading
Please register or sign in to comment