From da8cf7a9725764aad5822f6eb23760eaeedbd995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 21 Aug 2021 09:09:56 +0200 Subject: [PATCH] Add monetary field issue10598 review338511002 --- purchase.py | 13 ++++--------- view/purchase_request_quotation_line_form.xml | 2 +- view/purchase_request_quotation_line_list.xml | 2 +- ...purchase_request_quotation_line_list_request.xml | 2 +- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/purchase.py b/purchase.py index 03c1bb9d79..060a4e290e 100644 --- a/purchase.py +++ b/purchase.py @@ -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() diff --git a/view/purchase_request_quotation_line_form.xml b/view/purchase_request_quotation_line_form.xml index 2b51731487..c800a0ed7c 100644 --- a/view/purchase_request_quotation_line_form.xml +++ b/view/purchase_request_quotation_line_form.xml @@ -16,7 +16,7 @@ this repository contains the full copyright notices and license terms. -->