Support empty list price on product

issue10244
review350341002
This commit is contained in:
Cédric Krier
2021-09-13 23:29:57 +02:00
parent 7951c50d23
commit ca42e85c6d
2 changed files with 13 additions and 12 deletions
+12 -11
View File
@@ -144,21 +144,22 @@ class Product(metaclass=PoolMeta):
user = User(Transaction().user)
for product in products:
prices[product.id] = product._get_sale_unit_price(
quantity=quantity)
if uom and product.default_uom.category == uom.category:
prices[product.id] = Uom.compute_price(
product.default_uom, prices[product.id], uom)
else:
prices[product.id] = Uom.compute_price(
product.default_uom, prices[product.id], product.sale_uom)
if currency and user.company:
unit_price = product._get_sale_unit_price(quantity=quantity)
if unit_price is not None:
if uom and product.default_uom.category == uom.category:
unit_price = Uom.compute_price(
product.default_uom, unit_price, uom)
else:
unit_price = Uom.compute_price(
product.default_uom, unit_price, product.sale_uom)
if currency and user.company and unit_price is not None:
if user.company.currency != currency:
date = Transaction().context.get('sale_date') or today
with Transaction().set_context(date=date):
prices[product.id] = Currency.compute(
user.company.currency, prices[product.id],
unit_price = Currency.compute(
user.company.currency, unit_price,
currency, round=False)
prices[product.id] = unit_price
return prices
@property
+1 -1
View File
@@ -1310,7 +1310,7 @@ class SaleLine(TaxableMixin, sequence_ordered(), ModelSQL, ModelView):
self._get_context_sale_price()):
unit_price = Product.get_sale_price([self.product],
self.quantity or 0)[self.product.id]
if unit_price:
if unit_price is not None:
unit_price = round_price(unit_price)
return unit_price