[FIX] repair: prevent uom comparison for non products
Issue: When updating section line or note in a confirmed SO, the system tried to compare uom of them causing an error Steps to reproduce: 1- Install sale and repair apps 2- Create a sale order with adding a product and a section line 3- Confirm sale order 4- Modify section line 5- Save Solution: We need to check if the order line is a product before performing the uom comparison opw-3644939 closes odoo/odoo#148900 X-original-commit: e3cd490ab0e62865b5ad7516643a22c6ba3a3371 Signed-off-by: Adrien Widart (awt) <awt@odoo.com> Signed-off-by: Omar Abosamaha (abom) <abom@odoo.com>
This commit is contained in:
@@ -70,7 +70,7 @@ class SaleOrderLine(models.Model):
|
||||
old_product_uom_qty = {line.id: line.product_uom_qty for line in self}
|
||||
res = super().write(vals_list)
|
||||
for line in self:
|
||||
if line.state in ('sale', 'done'):
|
||||
if line.state in ('sale', 'done') and line.product_id:
|
||||
if float_compare(old_product_uom_qty[line.id], 0, precision_rounding=line.product_uom.rounding) <= 0 and float_compare(line.product_uom_qty, 0, precision_rounding=line.product_uom.rounding) > 0:
|
||||
self._create_repair_order()
|
||||
if float_compare(old_product_uom_qty[line.id], 0, precision_rounding=line.product_uom.rounding) > 0 and float_compare(line.product_uom_qty, 0, precision_rounding=line.product_uom.rounding) <= 0:
|
||||
|
||||
@@ -336,8 +336,12 @@ class TestRepair(common.TransactionCase):
|
||||
with so_form.order_line.new() as line:
|
||||
line.product_id = self.product_consu_order_repair
|
||||
line.product_uom_qty = 2.0
|
||||
with so_form.order_line.new() as line:
|
||||
line.display_type = 'line_section'
|
||||
line.name = 'Dummy Section'
|
||||
sale_order = so_form.save()
|
||||
order_line = sale_order.order_line[0]
|
||||
line_section = sale_order.order_line[1]
|
||||
self.assertEqual(len(sale_order.repair_order_ids), 0)
|
||||
sale_order.action_confirm()
|
||||
# Quantity set on the "create repair" product doesn't affect the number of RO created
|
||||
@@ -348,6 +352,7 @@ class TestRepair(common.TransactionCase):
|
||||
order_line.product_uom_qty = 0
|
||||
self.assertEqual(repair_order.state, 'cancel')
|
||||
order_line.product_uom_qty = 1
|
||||
line_section.name = 'updated section'
|
||||
self.assertEqual(repair_order.state, 'confirmed')
|
||||
repair_order.action_repair_cancel()
|
||||
self.assertTrue(float_is_zero(order_line.product_uom_qty, 2))
|
||||
|
||||
Reference in New Issue
Block a user