From e7bc082aaf284e8f38eb6c2312f9ca23cc5bd9ea Mon Sep 17 00:00:00 2001 From: Florent THOMAS Date: Tue, 28 Jul 2020 21:30:22 +0200 Subject: [PATCH] Use currency and monetary so that rounding will be done by the ORM* add new line Pylint fix pylint --- .../wizards/pos_payment_change_wizard_new_line.py | 10 +++++++++- .../wizards/pos_payment_change_wizard_old_line.py | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pos_payment_change/wizards/pos_payment_change_wizard_new_line.py b/pos_payment_change/wizards/pos_payment_change_wizard_new_line.py index a9119c19..8d7a6b27 100644 --- a/pos_payment_change/wizards/pos_payment_change_wizard_new_line.py +++ b/pos_payment_change/wizards/pos_payment_change_wizard_new_line.py @@ -20,7 +20,15 @@ class PosPaymentChangeWizardLine(models.TransientModel): domain=lambda s: s._domain_new_journal_id(), ) - amount = fields.Float(string="Amount", required=True) + company_currency_id = fields.Many2one( + comodel_name='res.currency', store=True, + related='new_journal_id.currency_id', + string="Company Currency", readonly=True, + help='Utility field to express amount currency') + + amount = fields.Monetary(string="Amount", + required=True, default=0.0, + currency_field='company_currency_id') @api.model def _domain_new_journal_id(self): diff --git a/pos_payment_change/wizards/pos_payment_change_wizard_old_line.py b/pos_payment_change/wizards/pos_payment_change_wizard_old_line.py index b40c8601..82084aca 100644 --- a/pos_payment_change/wizards/pos_payment_change_wizard_old_line.py +++ b/pos_payment_change/wizards/pos_payment_change_wizard_old_line.py @@ -19,5 +19,13 @@ class PosPaymentChangeWizardOldLine(models.TransientModel): required=True, readonly=True, ) + + company_currency_id = fields.Many2one( + comodel_name='res.currency', store=True, + related='old_journal_id.currency_id', + string="Company Currency", readonly=True, + help='Utility field to express amount currency') - amount = fields.Float(string="Amount", required=True, readonly=True) + amount = fields.Monetary(string="Amount", required=True, + readonly=True, default=0.0, + currency_field='company_currency_id')