Add monetary field

issue10598
review338511002
This commit is contained in:
Cédric Krier
2021-08-21 09:09:56 +02:00
parent 50f8ae6dc8
commit c095080678
3 changed files with 9 additions and 8 deletions
+5 -4
View File
@@ -6,14 +6,15 @@ from trytond.model import fields
from trytond.pool import PoolMeta, Pool
from trytond.pyson import Eval
from trytond.modules.currency.fields import Monetary
from trytond.modules.product import price_digits, round_price
class Line(metaclass=PoolMeta):
__name__ = 'sale.line'
base_price = fields.Numeric(
"Base Price", digits=price_digits,
base_price = Monetary(
"Base Price", currency='currency', digits=price_digits,
states={
'invisible': Eval('type') != 'line',
'readonly': Eval('sale_state') != 'draft',
@@ -28,8 +29,8 @@ class Line(metaclass=PoolMeta):
},
depends=['type', 'sale_state']),
'on_change_with_discount_rate', setter='set_discount_rate')
discount_amount = fields.Function(fields.Numeric(
"Discount Amount", digits=price_digits,
discount_amount = fields.Function(Monetary(
"Discount Amount", currency='currency', digits=price_digits,
states={
'invisible': Eval('type') != 'line',
'readonly': Eval('sale_state') != 'draft',
+2 -2
View File
@@ -4,14 +4,14 @@ this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="//label[@name='unit_price']" position="before">
<label name="base_price"/>
<field name="base_price" symbol="currency"/>
<field name="base_price"/>
<label id="discount" string="Discount"/>
<group col="-1" id="discounts">
<group col="-1" id="discount_rate">
<field name="discount_rate" factor="100" xexpand="0"/>
<label name="discount_rate" string="%" xalign="0.0" xexpand="1"/>
</group>
<field name="discount_amount" symbol="currency"/>
<field name="discount_amount"/>
</group>
</xpath>
</data>
+2 -2
View File
@@ -3,10 +3,10 @@
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="//field[@name='unit_price']" position="before">
<field name="base_price" symbol="currency"/>
<field name="base_price"/>
<field name="discount_rate" factor="100">
<suffix name="discount_rate" string="%"/>
</field>
<field name="discount_amount" symbol="currency"/>
<field name="discount_amount"/>
</xpath>
</data>