Merge branch 'main' into 6.8
This commit is contained in:
commit
7f092befca
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
|
||||
"""
|
||||
|
|
|
@ -76,7 +76,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
</ram:SpecifiedTradeProduct>
|
||||
<ram:SpecifiedLineTradeAgreement>
|
||||
<ram:NetPriceProductTradePrice>
|
||||
<ram:ChargeAmount py:attrs="{'currencyID': this.invoice.currency.code}">${this.invoice.currency.round(line.unit_price)}</ram:ChargeAmount>
|
||||
<ram:ChargeAmount py:attrs="{'currencyID': this.invoice.currency.code}">${this.round_unitprice(line.unit_price)}</ram:ChargeAmount>
|
||||
</ram:NetPriceProductTradePrice>
|
||||
</ram:SpecifiedLineTradeAgreement>
|
||||
<ram:SpecifiedLineTradeDelivery>
|
||||
|
|
Loading…
Reference in a new issue