diff --git a/product_catch_weight/models/account_invoice.py b/product_catch_weight/models/account_invoice.py index c6b3db66..11879f5b 100644 --- a/product_catch_weight/models/account_invoice.py +++ b/product_catch_weight/models/account_invoice.py @@ -25,7 +25,7 @@ class AccountInvoiceLine(models.Model): move_lines = self.sale_line_ids.mapped('move_ids.move_line_ids') else: move_lines = self.purchase_line_id.mapped('move_ids.move_line_ids') - for move_line in move_lines: + for move_line in move_lines.filtered(lambda l: l.lot_id): qty_done = move_line.qty_done current_qty_done = qty_done + qty_done_total r = move_line.lot_id.catch_weight_ratio diff --git a/product_catch_weight/tests/test_catch_weight.py b/product_catch_weight/tests/test_catch_weight.py index 1b13cb55..48821d7a 100644 --- a/product_catch_weight/tests/test_catch_weight.py +++ b/product_catch_weight/tests/test_catch_weight.py @@ -30,6 +30,7 @@ class TestPicking(TransactionCase): 'uom_po_id': self.product_uom_id.id, 'catch_weight_uom_id': self.ref_uom_id.id, }) + self.pricelist = self.env.ref('product.list0') # def test_creation(self): @@ -69,6 +70,7 @@ class TestPicking(TransactionCase): 'partner_invoice_id': self.partner1.id, 'partner_shipping_id': self.partner1.id, 'order_line': [(0, 0, {'product_id': self.product1.id})], + 'pricelist_id': self.pricelist.id, }) so.action_confirm() self.assertTrue(so.state in ('sale', 'done')) @@ -104,6 +106,7 @@ class TestPicking(TransactionCase): 'partner_invoice_id': self.partner1.id, 'partner_shipping_id': self.partner1.id, 'order_line': [(0, 0, {'product_id': self.product1.id, 'product_uom_qty': 2.0})], + 'pricelist_id': self.pricelist.id, }) so.action_confirm() self.assertTrue(so.state in ('sale', 'done'))