From 045ed49d15362e25d8f9ac0ffbae3bc1cb55a592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Mon, 2 Aug 2021 06:33:00 +0000 Subject: [PATCH] [IMP] delivery: 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. closes odoo/odoo#74561 X-original-commit: 6ec768d084da6bd7344c45750a2a5037ec366143 Signed-off-by: Arnold Moyaux --- addons/delivery/models/delivery_grid.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/addons/delivery/models/delivery_grid.py b/addons/delivery/models/delivery_grid.py index cee239daec4..5f52494ddb3 100644 --- a/addons/delivery/models/delivery_grid.py +++ b/addons/delivery/models/delivery_grid.py @@ -93,10 +93,21 @@ class ProviderGrid(models.Model): return self._get_price_from_picking(total, weight, volume, quantity) + 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': volume * weight, + 'quantity': quantity + } + def _get_price_from_picking(self, total, weight, volume, quantity): price = 0.0 criteria_found = False - price_dict = {'price': total, 'volume': volume, 'weight': weight, 'wv': volume * weight, 'quantity': quantity} + 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: