diff --git a/repair_purchase_return/tests/test_repair_purchase_return_order.py b/repair_purchase_return/tests/test_repair_purchase_return_order.py index 37c241f4..557f711e 100644 --- a/repair_purchase_return/tests/test_repair_purchase_return_order.py +++ b/repair_purchase_return/tests/test_repair_purchase_return_order.py @@ -15,6 +15,15 @@ def setUpClass(cls): "list_price": 20, } ) + + cls.service = cls.env["product.product"].create( + { + "name": "Test Fee", + "standard_price": 30, + "list_price": 50, + } + ) + cls.partner = cls.env.ref("base.res_partner_address_1") cls.location = cls.env["stock.location"].create( { @@ -28,7 +37,7 @@ def setUpClass(cls): "partner_invoice_id": cls.partner.id, "product_uom": cls.product.uom_id.id, "location_id": cls.location.id, - "invoice_method": "after_repair", + "invoice_method": "none", } ) domain_location = [("usage", "=", "production")] @@ -43,11 +52,23 @@ def setUpClass(cls): "location_id": cls.repair.location_id.id, "location_dest_id": stock_location_id.id, "product_uom_qty": 1, - "price_unit": 20, + "price_unit": cls.product.list_price, + } + ) + + cls.fees_lines = cls.env["repair.fee"].create( + { + "repair_id": cls.repair.id, + "product_id": cls.service.id, + "product_uom": cls.service.uom_id.id, + "name": "Test Fee", + "product_uom_qty": 1, + "price_unit": cls.service.list_price, } ) cls.repair["operations"] = cls.repair_line + cls.repair["fees_lines"] = cls.fees_lines cls.journal = cls.env["account.journal"].create( { @@ -65,6 +86,11 @@ def setUpClass(cls): } ) - def test_purchase_return_base(self): - self.pro = self.repair._create_purchase_return(self.vendor) - self.pro.action_view_repair_orders() + def test_repair_purchase_return(self): + pro = self.repair._create_purchase_return(self.vendor) + pro.action_view_repair_orders() + + # Check that purchase return order is caching the two lines and using the product cost + self.assertEqual(pro.order_line[0].price_unit, 10) + + self.assertEqual(pro.order_line[1].price_unit, 30)