From 458ccf74eb332128a3697c5620771d589f63df34 Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Mon, 25 Mar 2024 12:22:39 +0000 Subject: [PATCH] [FIX] delivery: revert method signature change 36e6728b2cac87c7cd922001be0222688ad52abb fixed an issue where the volume and weight were incorrectly computed for carriers based on rules. But it was done by changing the method api, which seems to break some custom modules using/extending the modified methods. This commit reverts the API change, conveying the needed information through the context for now (the api change will be done in master only). opw-3826165 closes odoo/odoo#159220 X-original-commit: d6e004b23822e98e8d1052b75b66a7d4f6d2c38c Signed-off-by: Victor Feyens (vfe) --- addons/delivery/models/delivery_carrier.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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: