diff --git a/addons/repair/models/sale_order.py b/addons/repair/models/sale_order.py index 4bf88693c73..274b2d934ab 100644 --- a/addons/repair/models/sale_order.py +++ b/addons/repair/models/sale_order.py @@ -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: diff --git a/addons/repair/tests/test_repair.py b/addons/repair/tests/test_repair.py index 9001fa3d417..0699b5825b6 100644 --- a/addons/repair/tests/test_repair.py +++ b/addons/repair/tests/test_repair.py @@ -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))