The goal is to be coherent with the user property. Actually, company_id and company_ids on the environment are no fields. Calling env.company_id returns a browse record, not an id.
18 lines
728 B
Python
18 lines
728 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, models, tools, _
|
|
from odoo.exceptions import ValidationError
|
|
|
|
|
|
class DecimalPrecision(models.Model):
|
|
_inherit = 'decimal.precision'
|
|
|
|
@api.constrains('digits')
|
|
def _check_main_currency_rounding(self):
|
|
if any(precision.name == 'Account' and
|
|
tools.float_compare(self.env.company.currency_id.rounding, 10 ** - precision.digits, precision_digits=6) == -1
|
|
for precision in self):
|
|
raise ValidationError(_("You cannot define the decimal precision of 'Account' as greater than the rounding factor of the company's main currency"))
|
|
return True
|