Skip to content

Commit

Permalink
Merge PR #741 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Dec 14, 2023
2 parents ccc9f6e + dda3664 commit a71dbed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions delivery_purchase/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 5 additions & 1 deletion delivery_purchase/tests/test_delivery_purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from odoo.tests import Form, common


class TestDeliveryPurchase(common.SavepointCase):
class TestDeliveryPurchaseBase(common.SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -105,9 +107,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)
Expand Down

0 comments on commit a71dbed

Please sign in to comment.