Skip to content
Open
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
13 changes: 12 additions & 1 deletion delivery_price_method/models/delivery_carrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
# Trick the method for using all the upstream code for the
# price computation in case of using fixed or base_on_rule.
previous_method = False
if self.price_method in ("fixed", "base_on_rule"):
if self.price_method in ("fixed", "base_on_rule") and (
not self.free_over or not self.amount or order.amount_total < self.amount
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using self._compute_currency() as in base code ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that you mean changing the order.amount to self._compute_currency() right?

):
previous_method = self.delivery_type
self.sudo().delivery_type = self.price_method
res = super().rate_shipment(order)
Expand All @@ -37,3 +39,12 @@
del rate["tracking_number"] # remove offending key
res[index].update(rate)
return res

def _get_price_from_picking(self, total, weight, volume, quantity, wv=0.0):
if (
self.price_method == "base_on_rule"
and self.free_over
and total >= self.amount
):
return 0.0

Check warning on line 49 in delivery_price_method/models/delivery_carrier.py

View check run for this annotation

Codecov / codecov/patch

delivery_price_method/models/delivery_carrier.py#L49

Added line #L49 was not covered by tests
return super()._get_price_from_picking(total, weight, volume, quantity, wv)