Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][FIX] delivery_price_product_domain: fix shipping without rule #772

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions delivery_price_product_domain/models/delivery_carrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _get_price_from_picking(self, total, weight, volume, quantity):
price_dict = self._get_price_dict(total, weight, volume, quantity)
untaxed_in_dict = "untaxed_price" in price_dict
test = False
rule_line = self.price_rule_ids[0]
rule_line = self.price_rule_ids.browse()
for line in self.price_rule_ids:
apply_product_domain_char = line.apply_product_domain
if apply_product_domain_char and self.order_id:
Expand All @@ -74,7 +74,7 @@ def _get_price_from_picking(self, total, weight, volume, quantity):
rule_line = line
break

if test and untaxed_in_dict:
if test and untaxed_in_dict and rule_line:
return (
rule_line.list_base_price
+ rule_line.list_price * price_dict[rule_line.variable_factor]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ def setUpClass(cls):
"fixed_price": 99.99,
}
)
self.carrier_2 = self.env["delivery.carrier"].create(
{
"name": "Carrier based on rule without rule",
"delivery_type": "base_on_rule",
"product_id": product_shipping_cost.id,
"fixed_price": 99.99,
}
)
self.pricelist = self.env["product.pricelist"].create(
{
"name": "Test pricelist",
Expand Down Expand Up @@ -101,6 +109,23 @@ def setUpClass(cls):
],
}
)
self.sale_2 = self.env["sale.order"].create(
{
"partner_id": self.partner.id,
"pricelist_id": self.pricelist.id,
"carrier_id": self.carrier.id,
"order_line": [
(
0,
0,
{
"product_id": self.product_delivery_1.id,
"product_uom_qty": 1,
},
),
],
}
)

def _add_delivery(self):
sale = self.sale
Expand Down Expand Up @@ -158,3 +183,13 @@ def test_apply_product_domain_service(self):
self.assertEqual(
len(delivery_lines), 1, msg="Must be 1 because add only 1 shipping"
)

def test_add_delivery(self):
sale = self.sale_2
delivery_wizard = Form(
self.env["choose.delivery.carrier"].with_context(
{"default_order_id": sale.id, "default_carrier_id": self.carrier_2}
)
)
choose_delivery_carrier = delivery_wizard.save()
choose_delivery_carrier.button_confirm()
Loading