Replace round() to quantize()
This commit is contained in:
parent
a42839d979
commit
31ffb39a6c
13
invoice.py
13
invoice.py
|
@ -88,13 +88,17 @@ class InformationUomMixin(object):
|
|||
@fields.depends('product', 'unit_price', 'type', 'product', 'quantity', 'info_unit', 'unit')
|
||||
def on_change_with_info_unit_price(self, name=None):
|
||||
Uom = Pool().get('product.uom')
|
||||
|
||||
if not self.product or self.unit_price is None or not self.unit:
|
||||
return
|
||||
|
||||
price = self.unit_price
|
||||
if self.unit and self.unit != self.product.default_uom:
|
||||
price = Uom.compute_price(self.unit, price,
|
||||
self.product.default_uom)
|
||||
return self.product.template.get_info_unit_price(price, self.info_unit)
|
||||
DIGITS = price_digits[1]
|
||||
return self.product.template.get_info_unit_price(
|
||||
price, self.info_unit).quantize(Decimal(str(10 ** -DIGITS)))
|
||||
|
||||
@fields.depends('product', 'info_unit_price', 'unit',
|
||||
methods=['on_change_with_amount'])
|
||||
|
@ -102,11 +106,11 @@ class InformationUomMixin(object):
|
|||
if not self.product or not self.info_unit_price:
|
||||
return
|
||||
|
||||
DIGITS=price_digits[1]
|
||||
DIGITS = price_digits[1]
|
||||
self.unit_price = self.product.template.get_unit_price(
|
||||
self.info_unit_price, unit=self.unit)
|
||||
self.info_unit_price, unit=self.unit).quantize(
|
||||
Decimal(str(10 ** -DIGITS)))
|
||||
|
||||
self.unit_price = round(self.unit_price, DIGITS)
|
||||
if hasattr(self, 'gross_unit_price'):
|
||||
self.gross_unit_price = self.unit_price
|
||||
self.discount = Decimal('0.0')
|
||||
|
@ -130,7 +134,6 @@ class InformationUomMixin(object):
|
|||
self.info_unit_price = self.on_change_with_info_unit_price()
|
||||
self.info_quantity = self.on_change_with_info_quantity()
|
||||
|
||||
|
||||
@fields.depends('product', 'unit_price', 'info_unit', 'unit')
|
||||
def on_change_unit_price(self):
|
||||
Uom = Pool().get('product.uom')
|
||||
|
|
Loading…
Reference in New Issue