From 52d19e6d58e769b60a77f2cb69f8612b0da5c541 Mon Sep 17 00:00:00 2001 From: Quentin De Paoli Date: Tue, 11 May 2010 14:31:49 +0200 Subject: [PATCH] [IMP] improved the constraint validation in order to accept multiple message bzr revid: qdp@cyan-20100511123149-tlmez9eg8k0vwk3y --- bin/osv/orm.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 6a96f22ff40..a5b7be89bdb 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -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) )