round unit_price of invoice-line by price_digits
This commit is contained in:
parent
ceb2a72fed
commit
02221601e7
2 changed files with 18 additions and 2 deletions
18
mixin.py
18
mixin.py
|
@ -4,12 +4,13 @@
|
|||
# full copyright notices and license terms.
|
||||
|
||||
|
||||
from decimal import Decimal
|
||||
from decimal import Decimal, ROUND_HALF_EVEN
|
||||
import html
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.i18n import gettext
|
||||
from trytond.tools import cached_property
|
||||
from trytond.pool import Pool
|
||||
from trytond.modules.product import price_digits
|
||||
|
||||
|
||||
class EdocumentMixin(object):
|
||||
|
@ -183,6 +184,21 @@ class EdocumentMixin(object):
|
|||
taxname=tax.rec_name))
|
||||
return unece_category_code
|
||||
|
||||
def round_unitprice(self, value):
|
||||
""" round value by digits in unit_price of account.invoice.line
|
||||
|
||||
Args:
|
||||
value (Decimal): unit-price
|
||||
|
||||
Returns:
|
||||
Decimal: rounded value
|
||||
"""
|
||||
if isinstance(value, Decimal):
|
||||
return value.quantize(
|
||||
Decimal(str(1/10 ** price_digits[1])),
|
||||
ROUND_HALF_EVEN)
|
||||
return value
|
||||
|
||||
def quote_text(self, text):
|
||||
""" replace critical chars
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue