Skip to content
Snippets Groups Projects
Commit 62e594f4 authored by Walid's avatar Walid
Browse files

[FIX] mrp_account: AVCO product valuation with component cost 0


Steps to reproduce:
- Create a manufactured product P with AVCO valuation
- On the bom of the previous product add a component C with unit cost 5$
- Manufacture product P (Unit cost correct so far 5$)
- Change component cost to 0 and manufacture again
- Unit cost of P is still 5$ were it should be 2.5$

Bug:
since the move unit price is 0 the standard price of the product P is
used insted for the valuation of the newly created qty

Fix:
force unit price to 0 in the case of manufacturing

opw-3374462

closes odoo/odoo#131687

X-original-commit: 4000b18f
Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
Signed-off-by: default avatarWalid Hanniche (waha) <waha@odoo.com>
parent 4de4a099
Branches
Tags
No related merge requests found
......@@ -42,3 +42,7 @@ class StockMove(models.Model):
if self.unbuild_id:
return True
return super()._is_returned(valued_type)
def _should_force_price_unit(self):
self.ensure_one()
return self.picking_type_id.code == 'mrp_operation' or super()._should_force_price_unit()
......@@ -238,9 +238,22 @@ class TestMrpValuationStandard(TestMrpValuationCommon):
self.assertEqual(self.product1.value_svl, 8.8 * 2)
self.assertEqual(self.component.quantity_svl, 0)
self.assertEqual(self.product1.quantity_svl, 2)
self.assertEqual(self.product1.standard_price, 8.8)
self._make_out_move(self.product1, 1)
self.assertEqual(self.product1.value_svl, 8.8)
# Update component price
self.component.standard_price = 0
self._make_in_move(self.component, 3)
mo = self._make_mo(self.bom, 3)
self._produce(mo)
mo.button_mark_done()
self.assertEqual(self.product1.value_svl, 8.8)
self.assertEqual(self.product1.quantity_svl, 4)
self.assertEqual(self.product1.standard_price, 2.2)
def test_std_std_1(self):
self.component.product_tmpl_id.categ_id.property_cost_method = 'standard'
self.product1.product_tmpl_id.categ_id.property_cost_method = 'standard'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment