From 0fe2b4530f97de35a7aa78beb6265f4a5dcef55d Mon Sep 17 00:00:00 2001 From: Naglis Jonaitis Date: Wed, 31 Jul 2019 12:11:56 +0000 Subject: [PATCH] [IMP] *: remove `digits` attribute from Monetary fields * account, hr_contract, hr_expense, point_of_sale, sale_margin, website_sale_delivery, website_sale_wishlist digits only works on Float fields, on Monetary fields it has no effect: - The column_type of a monetary field is always numeric - It is not applied in `convert_to_column()` or `convert_to_cache()` - It is not part of `description_attrs`, so it will not be included in the output of `fields_get()` closes odoo/odoo#35336 Signed-off-by: Martin Trigaux (mat) --- addons/account/models/account_bank_statement.py | 2 +- addons/hr_contract/models/hr_contract.py | 2 +- addons/hr_expense/models/hr_expense.py | 6 +++--- addons/point_of_sale/models/pos_session.py | 1 - addons/sale_margin/models/sale_order.py | 2 +- addons/website_sale_delivery/models/sale_order.py | 2 +- addons/website_sale_wishlist/models/product_wishlist.py | 2 +- 7 files changed, 8 insertions(+), 9 deletions(-) diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index c4b5a113fcf..6747a97110f 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -338,7 +338,7 @@ class AccountBankStatementLine(models.Model): name = fields.Char(string='Label', required=True) date = fields.Date(required=True, default=lambda self: self._context.get('date', fields.Date.context_today(self))) - amount = fields.Monetary(digits=0, currency_field='journal_currency_id') + amount = fields.Monetary(currency_field='journal_currency_id') journal_currency_id = fields.Many2one('res.currency', string="Journal's Currency", related='statement_id.currency_id', help='Utility field to express amount currency', readonly=True) partner_id = fields.Many2one('res.partner', string='Partner') diff --git a/addons/hr_contract/models/hr_contract.py b/addons/hr_contract/models/hr_contract.py index b9a54ff2871..64aec5ea1b8 100644 --- a/addons/hr_contract/models/hr_contract.py +++ b/addons/hr_contract/models/hr_contract.py @@ -28,7 +28,7 @@ class Contract(models.Model): resource_calendar_id = fields.Many2one( 'resource.calendar', 'Working Schedule', default=lambda self: self.env.company.resource_calendar_id.id) - wage = fields.Monetary('Wage', digits=(16, 2), required=True, tracking=True, help="Employee's monthly gross wage.") + wage = fields.Monetary('Wage', required=True, tracking=True, help="Employee's monthly gross wage.") advantages = fields.Text('Advantages') notes = fields.Text('Notes') state = fields.Selection([ diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index 7de93802d74..8784b192414 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -53,9 +53,9 @@ class HrExpense(models.Model): quantity = fields.Float(required=True, readonly=True, states={'draft': [('readonly', False)], 'reported': [('readonly', False)], 'refused': [('readonly', False)]}, digits='Product Unit of Measure', default=1) tax_ids = fields.Many2many('account.tax', 'expense_tax', 'expense_id', 'tax_id', string='Taxes') untaxed_amount = fields.Float("Subtotal", store=True, compute='_compute_amount', digits='Account') - total_amount = fields.Monetary("Total", compute='_compute_amount', store=True, currency_field='currency_id', digits='Account') + total_amount = fields.Monetary("Total", compute='_compute_amount', store=True, currency_field='currency_id') company_currency_id = fields.Many2one('res.currency', string="Report Company Currency", related='sheet_id.currency_id', store=True, readonly=False) - total_amount_company = fields.Monetary("Total (Company Currency)", compute='_compute_total_amount_company', store=True, currency_field='company_currency_id', digits='Account') + total_amount_company = fields.Monetary("Total (Company Currency)", compute='_compute_total_amount_company', store=True, currency_field='company_currency_id') company_id = fields.Many2one('res.company', string='Company', readonly=True, states={'draft': [('readonly', False)], 'refused': [('readonly', False)]}, default=lambda self: self.env.company) currency_id = fields.Many2one('res.currency', string='Currency', readonly=True, states={'draft': [('readonly', False)], 'refused': [('readonly', False)]}, default=lambda self: self.env.company.currency_id) analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account', oldname='analytic_account') @@ -618,7 +618,7 @@ class HrExpenseSheet(models.Model): address_id = fields.Many2one('res.partner', string="Employee Home Address") payment_mode = fields.Selection(related='expense_line_ids.payment_mode', default='own_account', readonly=True, string="Paid By") user_id = fields.Many2one('res.users', 'Manager', readonly=True, copy=False, states={'draft': [('readonly', False)]}, tracking=True, oldname='responsible_id') - total_amount = fields.Monetary('Total Amount', currency_field='currency_id', compute='_compute_amount', store=True, digits='Account') + total_amount = fields.Monetary('Total Amount', currency_field='currency_id', compute='_compute_amount', store=True) company_id = fields.Many2one('res.company', string='Company', readonly=True, states={'draft': [('readonly', False)]}, default=lambda self: self.env.company) currency_id = fields.Many2one('res.currency', string='Currency', readonly=True, states={'draft': [('readonly', False)]}, default=lambda self: self.env.company.currency_id) attachment_number = fields.Integer(compute='_compute_attachment_number', string='Number of Attachments') diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index 230aa667ab8..86e4661433b 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -89,7 +89,6 @@ class PosSession(models.Model): help="Total of all paid sales orders") cash_register_balance_end = fields.Monetary( related='cash_register_id.balance_end', - digits=0, string="Theoretical Closing Balance", help="Sum of opening balance and transactions.", readonly=True) diff --git a/addons/sale_margin/models/sale_order.py b/addons/sale_margin/models/sale_order.py index b22fd023da3..6c7f9d10dc7 100644 --- a/addons/sale_margin/models/sale_order.py +++ b/addons/sale_margin/models/sale_order.py @@ -66,7 +66,7 @@ class SaleOrderLine(models.Model): class SaleOrder(models.Model): _inherit = "sale.order" - margin = fields.Monetary(compute='_product_margin', help="It gives profitability by calculating the difference between the Unit Price and the cost.", currency_field='currency_id', digits='Product Price', store=True) + margin = fields.Monetary(compute='_product_margin', help="It gives profitability by calculating the difference between the Unit Price and the cost.", currency_field='currency_id', store=True) @api.depends('order_line.margin') def _product_margin(self): diff --git a/addons/website_sale_delivery/models/sale_order.py b/addons/website_sale_delivery/models/sale_order.py index e79805195f5..ff2ceb747ca 100644 --- a/addons/website_sale_delivery/models/sale_order.py +++ b/addons/website_sale_delivery/models/sale_order.py @@ -11,7 +11,7 @@ class SaleOrder(models.Model): _inherit = 'sale.order' amount_delivery = fields.Monetary( - compute='_compute_amount_delivery', digits=0, + compute='_compute_amount_delivery', string='Delivery Amount', help="The amount without tax.", store=True, tracking=True) diff --git a/addons/website_sale_wishlist/models/product_wishlist.py b/addons/website_sale_wishlist/models/product_wishlist.py index 678bace4cb1..962d7982931 100644 --- a/addons/website_sale_wishlist/models/product_wishlist.py +++ b/addons/website_sale_wishlist/models/product_wishlist.py @@ -17,7 +17,7 @@ class ProductWishlist(models.Model): product_id = fields.Many2one('product.product', string='Product', required=True) currency_id = fields.Many2one('res.currency', related='pricelist_id.currency_id', readonly=True) pricelist_id = fields.Many2one('product.pricelist', string='Pricelist', help='Pricelist when added') - price = fields.Monetary(digits=0, currency_field='currency_id', string='Price', help='Price of the product when it has been added in the wishlist') + price = fields.Monetary(currency_field='currency_id', string='Price', help='Price of the product when it has been added in the wishlist') website_id = fields.Many2one('website', required=True) active = fields.Boolean(default=True, required=True)