diff options
| author | Denis Ledoux <dle@odoo.com> | 2015-01-16 17:24:47 +0100 |
|---|---|---|
| committer | Denis Ledoux <dle@odoo.com> | 2015-01-16 17:47:33 +0100 |
| commit | 5959c41631ccc2d5eb1225f37f7002d7890fed13 (patch) | |
| tree | 12252c77a9f43ac600975bfc4ebcf6614ed8037c | |
| parent | 2f5a7b63d33d4f25106c37eb807ec54e2c22d77b (diff) | |
[IMP] res_lang: constraint for grouping field
As entering a wrong value in the grouping field of res.lang,
for instance '[,]', leads to an unavailability of the web interface,
We add a constraint to prevent entering wrong values.
| -rw-r--r-- | openerp/addons/base/res/res_lang.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/openerp/addons/base/res/res_lang.py b/openerp/addons/base/res/res_lang.py index 78bb972d18d..73c14048672 100644 --- a/openerp/addons/base/res/res_lang.py +++ b/openerp/addons/base/res/res_lang.py @@ -123,6 +123,15 @@ class lang(osv.osv): return False return True + def _check_grouping(self, cr, uid, ids, context=None): + for lang in self.browse(cr, uid, ids, context=context): + try: + if not all(isinstance(x, int) for x in eval(lang.grouping)): + return False + except Exception: + return False + return True + def _get_default_date_format(self, cursor, user, context=None): return '%m/%d/%Y' @@ -158,7 +167,8 @@ class lang(osv.osv): ] _constraints = [ - (_check_format, 'Invalid date/time format directive specified. Please refer to the list of allowed directives, displayed when you edit a language.', ['time_format', 'date_format']) + (_check_format, 'Invalid date/time format directive specified. Please refer to the list of allowed directives, displayed when you edit a language.', ['time_format', 'date_format']), + (_check_grouping, "The Separator Format should be like [,n] where 0 < n :starting from Unit digit.-1 will end the separation. e.g. [3,2,-1] will represent 106500 to be 1,06,500;[1,2,-1] will represent it to be 106,50,0;[3] will represent it as 106,500. Provided ',' as the thousand separator in each case.", ['grouping']) ] @tools.ormcache(skiparg=3) |
