Merge branch 'main' into 6.0
This commit is contained in:
commit
996c6ddeef
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.
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal, ROUND_HALF_EVEN
|
||||||
import html
|
import html
|
||||||
from trytond.exceptions import UserError
|
from trytond.exceptions import UserError
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
from trytond.tools import cached_property
|
from trytond.tools import cached_property
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
|
from trytond.modules.product import price_digits
|
||||||
|
|
||||||
|
|
||||||
class EdocumentMixin(object):
|
class EdocumentMixin(object):
|
||||||
|
@ -183,6 +184,21 @@ class EdocumentMixin(object):
|
||||||
taxname=tax.rec_name))
|
taxname=tax.rec_name))
|
||||||
return unece_category_code
|
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):
|
def quote_text(self, text):
|
||||||
""" replace critical chars
|
""" replace critical chars
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -76,7 +76,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
</ram:SpecifiedTradeProduct>
|
</ram:SpecifiedTradeProduct>
|
||||||
<ram:SpecifiedLineTradeAgreement>
|
<ram:SpecifiedLineTradeAgreement>
|
||||||
<ram:NetPriceProductTradePrice>
|
<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:NetPriceProductTradePrice>
|
||||||
</ram:SpecifiedLineTradeAgreement>
|
</ram:SpecifiedLineTradeAgreement>
|
||||||
<ram:SpecifiedLineTradeDelivery>
|
<ram:SpecifiedLineTradeDelivery>
|
||||||
|
|
Loading…
Reference in a new issue