[FIX] stock : update UoM of SM on product change
An error appears when we try to change the product in transfer line via product/search steps to reproduce the error : 1- create 2 products : Test 1 (UoM is Cm) and Test 2 (Uom is g) 2- create a delivery order and add Test 1 3- UoM error due to the UoM not being updated at the time of change The error was happening because when updating the product directly in the line section , the stock_move item already has a UoM and the if statement makes it impossible to change it , so the error appears. opw-3231298 closes odoo/odoo#117504 X-original-commit: ece3dea8c1ab43a854a57513cc317e8618010542 Signed-off-by: Adrien Widart <awt@odoo.com> Signed-off-by: Mahdi Cheikh Rouhou (macr) <macr@odoo.com>
This commit is contained in:
@@ -189,9 +189,7 @@ class StockMove(models.Model):
|
||||
@api.depends('product_id')
|
||||
def _compute_product_uom(self):
|
||||
for move in self:
|
||||
if not move.product_uom:
|
||||
move.product_uom = move.product_id.uom_id.id
|
||||
|
||||
move.product_uom = move.product_id.uom_id.id
|
||||
|
||||
@api.depends('has_tracking', 'picking_type_id.use_create_lots', 'picking_type_id.use_existing_lots', 'state')
|
||||
def _compute_display_assign_serial(self):
|
||||
|
||||
@@ -5976,6 +5976,15 @@ class StockMove(TransactionCase):
|
||||
})
|
||||
self.assertEqual(move.product_uom, self.product.uom_id)
|
||||
self.assertEqual(move.move_line_ids.product_uom_id, self.product.uom_id)
|
||||
uom_kg = self.env.ref('uom.product_uom_kgm')
|
||||
product1 = self.env['product.product'].create({
|
||||
'name': 'product1',
|
||||
'type': 'product',
|
||||
'uom_id': uom_kg.id,
|
||||
'uom_po_id': uom_kg.id
|
||||
})
|
||||
move.product_id = product1
|
||||
self.assertEqual(move.product_uom, product1.uom_id)
|
||||
|
||||
def test_move_line_compute_locations(self):
|
||||
stock_location = self.env['stock.location'].create({
|
||||
|
||||
Reference in New Issue
Block a user