Skip to content

Commit b8f71b3

Browse files
[FIX] delivery_price_product_domain: fix shipping without rule
1 parent 537c656 commit b8f71b3

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

delivery_price_product_domain/models/delivery_carrier.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def recompute_price_available(self, apply_product, price_dict, untaxed_in_dict):
5252

5353
def _get_price_from_picking(self, total, weight, volume, quantity):
5454
"Find price rule matching SO base on apply_product_domain"
55-
if self.free_over and total >= self.amount:
55+
if self.free_over and total >= self.amount or not self.price_rule_ids:
5656
return 0
5757
price_dict = self._get_price_dict(total, weight, volume, quantity)
5858
untaxed_in_dict = "untaxed_price" in price_dict

delivery_price_product_domain/tests/test_delivery_price_product_domain.py

+35
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ def setUpClass(cls):
4040
"fixed_price": 99.99,
4141
}
4242
)
43+
self.carrier_2 = self.env["delivery.carrier"].create(
44+
{
45+
"name": "Carrier based on rule without rule",
46+
"delivery_type": "base_on_rule",
47+
"product_id": product_shipping_cost.id,
48+
"fixed_price": 99.99,
49+
}
50+
)
4351
self.pricelist = self.env["product.pricelist"].create(
4452
{
4553
"name": "Test pricelist",
@@ -101,6 +109,23 @@ def setUpClass(cls):
101109
],
102110
}
103111
)
112+
self.sale_2 = self.env["sale.order"].create(
113+
{
114+
"partner_id": self.partner.id,
115+
"pricelist_id": self.pricelist.id,
116+
"carrier_id": self.carrier.id,
117+
"order_line": [
118+
(
119+
0,
120+
0,
121+
{
122+
"product_id": self.product_delivery_1.id,
123+
"product_uom_qty": 1,
124+
},
125+
),
126+
],
127+
}
128+
)
104129

105130
def _add_delivery(self):
106131
sale = self.sale
@@ -158,3 +183,13 @@ def test_apply_product_domain_service(self):
158183
self.assertEqual(
159184
len(delivery_lines), 1, msg="Must be 1 because add only 1 shipping"
160185
)
186+
187+
def test_add_delivery(self):
188+
sale = self.sale_2
189+
delivery_wizard = Form(
190+
self.env["choose.delivery.carrier"].with_context(
191+
{"default_order_id": sale.id, "default_carrier_id": self.carrier_2}
192+
)
193+
)
194+
choose_delivery_carrier = delivery_wizard.save()
195+
choose_delivery_carrier.button_confirm()

0 commit comments

Comments
 (0)