[FIX] purchase_mrp, mrp: correct BoM Kit valuation with nested kits
[FIX] purchase_mrp, mrp: correct BoM Kit valuation with nested kits
Issue:
When purchasing a BoM Kit (50/50) containing others BoM Kits (50/50), cost share was applied at each level (50% instead of 25%), leading to overvaluation (e.g., 200% total instead of 100%)
Cause:
cost_share was always applied fully during BoM explosion and as a portion of the full price on _get_unit_price()
Other bug fixed:
Fix _get_cost_share() to correctly return 0 when BoM total cost_share already equals 100%
Requirement:
AVCO (Average Cost) must be enabled on all components/BoMs
Steps to reproduce:
- Recreate that hierarchy with AVCO Products
- A kit "Testing Kit Complete" containing: -- "Component01", cost share 50% -- A kit "Testing Kit 1", cost share 50%: --- "Component02", cost share 50% --- "Component03", cost share 50%
- Create and validate a Purchase Order for "Testing Kit Complete" (unit price: 1000)
- Receive the products
- Go in Inventory > Reporting > Valuation and search for Component
- All 3 components are set to 500, instead of Component01: 500 / Component02: 250/ Component03: 250
opw-4806023
[FIX] purchase_mrp: correct BoM valuation with product variants or optional lines
Issue:
BoM valuation ignores variant-specific lines and does not skip lines with quantity 0
Cause:
The code only checks that the BoM adds up to 100% But this can cause issues with variants that do not include all products or with optional lines As a result, the total valuation may be incorrect
Steps to reproduce:
- Recreate a kit hierarchy with AVCO products:
- Kit "Variant Kit" (Variant Color: White and Wood) containing: -- "Component01", cost share 0%, only for variant White -- "Component02", cost share 0%
- Create and confirm a Purchase Order for "Variant Kit" (variant: Wood, unit price: 1000)
- Receive the products
- Go to Inventory > Reporting > Valuation and search for the components
- Only Component02 appears with 500$, so only half of the total value is shown
opw-4806023 opw-5085457
Forward-Port-Of: odoo/odoo#218326
@coco2299 @Whenrow cherrypicking of pull request odoo/odoo#218326 failed.
- 8c05caffab3765eae3310fd49e12c13b1cc76b8d <- on this commit
- 445de0fbdf01ac4c0719cfa05be4248a02d9683e
stdout:
Auto-merging addons/mrp/models/mrp_bom.py
CONFLICT (content): Merge conflict in addons/mrp/models/mrp_bom.py
Auto-merging addons/mrp/models/stock_move.py
CONFLICT (content): Merge conflict in addons/mrp/models/stock_move.py
Auto-merging addons/purchase_mrp/models/stock_move.py
Auto-merging addons/purchase_mrp/tests/test_anglo_saxon_valuation.py
Auto-merging addons/purchase_mrp/tests/test_purchase_mrp_flow.py
Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?).
In the former case, you may want to edit this PR message as well.
:warning: after resolving this conflict, you will need to merge it via @robodoo.
More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port
Require https://github.com/odoo/odoo/pull/239490 to be merged since the action_archive of products can not be used in stock tests without pos access rights.
@coco2299 @Whenrow this forward port of odoo/odoo#218326 is awaiting action (not merged or closed).
robodoo r+
