~clearcorp-drivers/openobject-server/5.0-ccorp

« back to all changes in this revision

Viewing changes to bin/addons/base/ir/ir_rule.py

  • Committer: Jay Vora(OpenERP)
  • Date: 2011-02-28 09:46:53 UTC
  • Revision ID: jvo@tinyerp.com-20110228094653-y8hhu2v9bggh9nve
[FIX] Record rule/Expression : If wrong domain is supplied,system should notify instead of crashing with an integrity error or a traceback (Ref : Case 4131)

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import time
25
25
import tools
26
26
from tools.safe_eval import safe_eval as eval
 
27
from tools.translate import _
27
28
 
28
29
class ir_rule_group(osv.osv):
29
30
    _name = 'ir.rule.group'
114
115
        'domain_force': fields.char('Force Domain', size=250),
115
116
        'domain': fields.function(_domain_force_get, method=True, string='Domain', type='char', size=250)
116
117
    }
117
 
 
 
118
    
 
119
    def _check_domain_validity(self, cr, uid, ids, context={}):
 
120
        for record in self.browse(cr, uid, ids, context=context):
 
121
            dom = record.domain
 
122
            if dom:
 
123
                try:
 
124
                    rule_domain = self.pool.get(record.rule_group.model_id.model)._where_calc(cr, uid, dom, active_test=False)
 
125
                except Exception:
 
126
                    return False
 
127
        return True
 
128
    
 
129
    _constraints = [
 
130
        (_check_domain_validity, _('The domain contains wrong reference of fields! Kindly double check the domain you provided !'),['domain_force']),
 
131
    ]
 
132
    
118
133
    def onchange_all(self, cr, uid, ids, field_id, operator, operand):
119
134
        if not (field_id or operator or operand):
120
135
            return {}