Add monetary field

issue10598
review338511002
This commit is contained in:
Cédric Krier
2021-08-21 09:09:56 +02:00
parent d0d40e2776
commit da8cf7a972
4 changed files with 7 additions and 12 deletions
+4 -9
View File
@@ -15,6 +15,8 @@ from trytond.tools import sortable_values
from trytond.transaction import Transaction
from trytond.wizard import Wizard, StateView, StateTransition, Button
from trytond.modules.currency.fields import Monetary
from .exceptions import PreviousQuotation
@@ -289,14 +291,13 @@ class QuotationLine(ModelSQL, ModelView):
product_uom_category = fields.Function(
fields.Many2One('product.uom.category', 'Product Uom Category'),
'on_change_with_product_uom_category')
unit_price = fields.Numeric('Unit Price', digits=price_digits)
unit_price = Monetary(
"Unit Price", currency='currency', digits=price_digits)
currency = fields.Many2One('currency.currency', 'Currency',
states={
'required': Bool(Eval('unit_price')),
},
depends=['unit_price'])
currency_digits = fields.Function(
fields.Integer('Currency Digits'), 'on_change_with_currency_digits')
request = fields.Many2One('purchase.request', 'Request',
ondelete='CASCADE', select=True, required=True,
domain=[
@@ -364,12 +365,6 @@ class QuotationLine(ModelSQL, ModelView):
if self.product:
return self.product.default_uom_category.id
@fields.depends('currency')
def on_change_with_currency_digits(self, name=None):
if self.currency:
return self.currency.digits
return None
@classmethod
def get_quotation_state(cls):
pool = Pool()
@@ -16,7 +16,7 @@ this repository contains the full copyright notices and license terms. -->
<label name="unit"/>
<field name="unit"/>
<label name="unit_price"/>
<field name="unit_price"/>
<field name="unit_price" symbol=""/>
<label name="currency"/>
<field name="currency"/>
@@ -7,5 +7,5 @@ this repository contains the full copyright notices and license terms. -->
<field name="product" expand="1"/>
<field name="description" expand="1"/>
<field name="quantity" symbol="unit"/>
<field name="unit_price" symbol="currency"/>
<field name="unit_price"/>
</tree>
@@ -6,6 +6,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="supply_date"/>
<field name="supplier" expand="1"/>
<field name="quantity" symbol="unit"/>
<field name="unit_price" symbol="currency"/>
<field name="unit_price"/>
<field name="quotation_state"/>
</tree>