[IMP] base: warning on decimal precision change
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models, tools
|
||||
from odoo import api, fields, models, tools, _
|
||||
import odoo.addons
|
||||
|
||||
import logging
|
||||
@@ -49,6 +49,23 @@ class DecimalPrecision(models.Model):
|
||||
self.clear_caches()
|
||||
return res
|
||||
|
||||
@api.onchange('digits')
|
||||
def _onchange_digits_warning(self):
|
||||
if self.digits < self._origin.digits:
|
||||
return {
|
||||
'warning': {
|
||||
'title': _("Warning for %s", self.name),
|
||||
'message': _(
|
||||
"The precision has been reduced for %s.\n"
|
||||
"Note that existing data WON'T be updated by this change.\n\n"
|
||||
"As decimal precisions impact the whole system, this may cause critical issues.\n"
|
||||
"E.g. reducing the precision could disturb your financial balance.\n\n"
|
||||
"Therefore, changing decimal precisions in a running database is not recommended.",
|
||||
self.name,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
# compatibility for decimal_precision.get_precision(): expose the module in addons namespace
|
||||
dp = sys.modules['odoo.addons.base.models.decimal_precision']
|
||||
odoo.addons.decimal_precision = dp
|
||||
|
||||
Reference in New Issue
Block a user