[FIX] delivery: price rule name not formatted if no delivery product
This trace back raises when we try to create delivery price rule,
while delivery product is not selected in the delivery carrier.
Steps to produce:
* Install delivery,sales modules
* Open Sales/Configuration/Shipping Methods
* Create a new shipping method keep provider as 'Based on Rules'
* Try to add a line for pricing
* At this moment trace back raises ('Expected singleton: res.currency')
We resolve this issue by not formatting the name if the currency does
not exist yet, as the currency is related to the one of the product.
Sentry :- 4067992652
closes odoo/odoo#119958
X-original-commit: d20431758c0c4943394a63250ad0a83894b795c8
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
committed by
Valentin Vallaeys (vava)
parent
1baeea454f
commit
77f7cc2eb1
@@ -22,20 +22,19 @@ class PriceRule(models.Model):
|
||||
def _compute_name(self):
|
||||
for rule in self:
|
||||
name = 'if %s %s %.02f then' % (rule.variable, rule.operator, rule.max_value)
|
||||
if rule.currency_id:
|
||||
base_price = format_amount(self.env, rule.list_base_price, rule.currency_id)
|
||||
price = format_amount(self.env, rule.list_price, rule.currency_id)
|
||||
else:
|
||||
base_price = "%.2f" % rule.list_base_price
|
||||
price = "%.2f" % rule.list_price
|
||||
if rule.list_base_price and not rule.list_price:
|
||||
name = '%s fixed price %s' % (
|
||||
name, format_amount(self.env, rule.list_base_price, rule.currency_id)
|
||||
)
|
||||
name = '%s fixed price %s' % (name, base_price)
|
||||
elif rule.list_price and not rule.list_base_price:
|
||||
name = '%s %s times %s' % (name, format_amount(
|
||||
self.env, rule.list_price, rule.currency_id
|
||||
), rule.variable_factor)
|
||||
name = '%s %s times %s' % (name, price, rule.variable_factor)
|
||||
else:
|
||||
name = '%s fixed price %s plus %s times %s' % (
|
||||
name,
|
||||
format_amount(self.env, rule.list_base_price, rule.currency_id),
|
||||
format_amount(self.env, rule.list_price, rule.currency_id),
|
||||
rule.variable_factor,
|
||||
name, base_price, price, rule.variable_factor
|
||||
)
|
||||
rule.name = name
|
||||
|
||||
|
||||
Reference in New Issue
Block a user