flectra/addons/product/models/decimal_precision.py

18 lines
751 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2018-01-16 11:34:37 +01:00
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
2018-01-16 11:34:37 +01:00
from flectra import api, models, tools, _
from flectra.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.user.company_id.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