[IMP] improved the constraint validation in order to accept multiple message

bzr revid: qdp@cyan-20100511123149-tlmez9eg8k0vwk3y
This commit is contained in:
Quentin De Paoli 2010-05-11 14:31:49 +02:00
parent 2ceb51f030
commit 52d19e6d58
1 changed files with 6 additions and 1 deletions

View File

@ -1023,7 +1023,12 @@ class orm_template(object):
for constraint in self._constraints:
fun, msg, fields = constraint
if not fun(self, cr, uid, ids):
translated_msg = trans._get_source(cr, uid, self._name, 'constraint', lng, source=msg) or msg
if hasattr(msg, '__call__'):
txt_msg, params = msg(self, cr, uid, ids)
tmp_msg = trans._get_source(cr, uid, self._name, 'constraint', lng, source=txt_msg) or txt_msg
translated_msg = tmp_msg % params
else:
translated_msg = trans._get_source(cr, uid, self._name, 'constraint', lng, source=msg) or msg
error_msgs.append(
_("Error occurred while validating the field(s) %s: %s") % (','.join(fields), translated_msg)
)