From 4696a605b39077b73c6cd9615b574ed39478d87e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Thu, 14 Dec 2023 14:39:48 +0100 Subject: [PATCH 1/2] [IMP] delivery_purchase: Set carrier_price when creating a picking If we have a delivery price of 10 on the order, it is expected to show 10 on the picking (without needing to be set to that amount when set the picking as done). TT45656 --- delivery_purchase/models/purchase_order.py | 1 + delivery_purchase/tests/test_delivery_purchase.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/delivery_purchase/models/purchase_order.py b/delivery_purchase/models/purchase_order.py index 5e68113396..d444b76bf3 100644 --- a/delivery_purchase/models/purchase_order.py +++ b/delivery_purchase/models/purchase_order.py @@ -43,6 +43,7 @@ def _prepare_picking(self): res = super()._prepare_picking() if self.carrier_id: res["carrier_id"] = self.carrier_id.id + res["carrier_price"] = self.delivery_price return res def _create_delivery_line(self, carrier, price_unit): diff --git a/delivery_purchase/tests/test_delivery_purchase.py b/delivery_purchase/tests/test_delivery_purchase.py index c8415462ed..65503c80d8 100644 --- a/delivery_purchase/tests/test_delivery_purchase.py +++ b/delivery_purchase/tests/test_delivery_purchase.py @@ -105,9 +105,11 @@ def test_delivery_purchase(self): self.assertEqual(self.purchase.delivery_price, 30) def test_picking_carrier_01(self): + self.assertEqual(self.purchase.delivery_price, 20) self.purchase.button_confirm() picking = self.purchase.picking_ids self.assertEqual(picking.carrier_id, self.carrier_fixed) + self.assertEqual(picking.carrier_price, 20) picking.carrier_id = self.carrier_rules.id self._action_picking_validate(picking) self.assertEqual(picking.carrier_price, 10) From dda3664b72ee09ac8b53a0404c7f18b2a8fa66ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Thu, 14 Dec 2023 14:52:31 +0100 Subject: [PATCH 2/2] [IMP] delivery_purchase: Create TestDeliveryPurchaseBase to be used in tests of other modules TT45656 --- delivery_purchase/tests/test_delivery_purchase.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/delivery_purchase/tests/test_delivery_purchase.py b/delivery_purchase/tests/test_delivery_purchase.py index 65503c80d8..8e6d26f7f1 100644 --- a/delivery_purchase/tests/test_delivery_purchase.py +++ b/delivery_purchase/tests/test_delivery_purchase.py @@ -3,7 +3,7 @@ from odoo.tests import Form, common -class TestDeliveryPurchase(common.SavepointCase): +class TestDeliveryPurchaseBase(common.SavepointCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -77,6 +77,8 @@ def _action_picking_validate(self, picking): model = self.env[res["res_model"]].with_context(**res["context"]) model.create({}).process() + +class TestDeliveryPurchase(TestDeliveryPurchaseBase): def test_onchange_partner_id(self): self.assertEqual(self.purchase.carrier_id, self.carrier_fixed)