You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have found uncovered case. When add a product to a basket and then change its price next time you open a basket you will see a warning about changing in price. The price will be in the wrong currency. This happens because the method get_warning doesn't take into account the line currency and asummes it always default.
The solution is to override the method and pass correct currency.
# apps/basket/models.pyclassLine(AbstractLine):
defget_warning(self):
""" Return a warning message about this basket line if one is applicable This could be things like the price has changed """ifisinstance(self.purchase_info.availability, Unavailable):
msg="'%(product)s' is no longer available"return_(msg) % {'product': self.product.get_title()}
ifnotself.price_incl_tax:
returnifnotself.purchase_info.price.is_tax_known:
return# Compare current price to price when added to basketcurrent_price_incl_tax=self.purchase_info.price.incl_taxifcurrent_price_incl_tax!=self.price_incl_tax:
product_prices= {
'product': self.product.get_title(),
'old_price': currency(self.price_incl_tax, self.price_currency), # pass the line price currency'new_price': currency(current_price_incl_tax, self.price_currency) # pass the line price currency
}
ifcurrent_price_incl_tax>self.price_incl_tax:
warning=_("The price of '%(product)s' has increased from"" %(old_price)s to %(new_price)s since you added"" it to your basket")
returnwarning%product_priceselse:
warning=_("The price of '%(product)s' has decreased from"" %(old_price)s to %(new_price)s since you added"" it to your basket")
returnwarning%product_prices
The text was updated successfully, but these errors were encountered:
Hi,
I have found uncovered case. When add a product to a basket and then change its price next time you open a basket you will see a warning about changing in price. The price will be in the wrong currency. This happens because the method
get_warning
doesn't take into account the line currency and asummes it always default.The solution is to override the method and pass correct currency.
The text was updated successfully, but these errors were encountered: