diff --git a/addons/delivery/models/delivery_carrier.py b/addons/delivery/models/delivery_carrier.py index b8b6c29fddc..31e9e1419c8 100644 --- a/addons/delivery/models/delivery_carrier.py +++ b/addons/delivery/models/delivery_carrier.py @@ -357,23 +357,23 @@ class DeliveryCarrier(models.Model): # 2- saved weight to use on sale order # 3- total order line weight as fallback weight = self.env.context.get('order_weight') or order.shipping_weight or weight - return self._get_price_from_picking(total, weight, volume, quantity, wv=wv) + return self.with_context(wv=wv)._get_price_from_picking(total, weight, volume, quantity) - def _get_price_dict(self, total, weight, volume, quantity, wv=0.): + def _get_price_dict(self, total, weight, volume, quantity): '''Hook allowing to retrieve dict to be used in _get_price_from_picking() function. Hook to be overridden when we need to add some field to product and use it in variable factor from price rules. ''' return { 'price': total, 'volume': volume, 'weight': weight, - 'wv': wv or volume * weight, + 'wv': self.env.context.get('wv') or volume * weight, 'quantity': quantity } - def _get_price_from_picking(self, total, weight, volume, quantity, wv=0.): + def _get_price_from_picking(self, total, weight, volume, quantity): price = 0.0 criteria_found = False - price_dict = self._get_price_dict(total, weight, volume, quantity, wv=wv) + price_dict = self._get_price_dict(total, weight, volume, quantity) if self.free_over and total >= self.amount: return 0 for line in self.price_rule_ids: