[FIX] mrp_account: correct component price unbuild
Steps to reproduce: - Create a component C (automated/FIFO) - Create and confirm two PO for C qty: 1, price: 10 qty: 1, price: 20 - Make an MO with C as a component - Unbuild that MO Bug: The valuation of the new component C is wrong, the new move in is valued at the current product cost instead of its original value. Fix: create moves as a return to get the correct value opw-3379457 closes odoo/odoo#137353 X-original-commit: d42238cc75fe6621c1eb893395856870c8bfbafb Signed-off-by: William Henrotin (whe) <whe@odoo.com> Signed-off-by: Walid Hanniche (waha) <waha@odoo.com>
This commit is contained in:
@@ -258,6 +258,7 @@ class MrpUnbuild(models.Model):
|
||||
'warehouse_id': location_dest_id.warehouse_id.id,
|
||||
'unbuild_id': self.id,
|
||||
'company_id': move.company_id.id,
|
||||
'origin_returned_move_id': move.id,
|
||||
})
|
||||
|
||||
def _generate_move_from_bom_line(self, product, product_uom, quantity, bom_line_id=False, byproduct_id=False):
|
||||
|
||||
@@ -128,6 +128,28 @@ class TestMrpValuationStandard(TestMrpValuationCommon):
|
||||
self.assertEqual(self.product1.quantity_svl, 2)
|
||||
self.assertEqual(byproduct.quantity_svl, 2)
|
||||
|
||||
def test_fifo_unbuild(self):
|
||||
""" This test creates an MO and then creates an unbuild
|
||||
orders and checks the stock valuation.
|
||||
"""
|
||||
self.component.product_tmpl_id.categ_id.property_cost_method = 'fifo'
|
||||
# ---------------------------------------------------
|
||||
# MO
|
||||
# ---------------------------------------------------
|
||||
self._make_in_move(self.component, 1, 10)
|
||||
self._make_in_move(self.component, 1, 20)
|
||||
mo = self._make_mo(self.bom, 1)
|
||||
self._produce(mo)
|
||||
mo.button_mark_done()
|
||||
self.assertEqual(self.component.value_svl, 20)
|
||||
# ---------------------------------------------------
|
||||
# Unbuild
|
||||
# ---------------------------------------------------
|
||||
unbuild_form = Form(self.env['mrp.unbuild'])
|
||||
unbuild_form.mo_id = mo
|
||||
unbuild_form.save().action_unbuild()
|
||||
self.assertEqual(self.component.value_svl, 30)
|
||||
|
||||
def test_fifo_avco_1(self):
|
||||
self.component.product_tmpl_id.categ_id.property_cost_method = 'fifo'
|
||||
self.product1.product_tmpl_id.categ_id.property_cost_method = 'average'
|
||||
|
||||
Reference in New Issue
Block a user