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