[IMP] expression.py: add a check to forbid records in domains
authorRaphael Collet <rco@openerp.com>
Wed, 15 Oct 2014 10:29:33 +0000 (12:29 +0200)
committerRaphael Collet <rco@openerp.com>
Thu, 16 Oct 2014 08:22:23 +0000 (10:22 +0200)
Records in domains cause a "maximum recursion depth exceeded" error when
converted to SQL. Simply add a test to show a better error message.

addons/crm/crm_lead.py
openerp/osv/expression.py

index cb21f7a..c5aa47f 100644 (file)
@@ -957,7 +957,7 @@ class crm_lead(format_address, osv.osv):
         lead = self.browse(cr, uid, id, context=context)
         local_context = dict(context)
         local_context.setdefault('default_type', lead.type)
-        local_context.setdefault('default_section_id', lead.section_id)
+        local_context.setdefault('default_section_id', lead.section_id.id)
         if lead.type == 'opportunity':
             default['date_open'] = fields.datetime.now()
         else:
index 8515c65..9bf4083 100644 (file)
@@ -1108,6 +1108,8 @@ class expression(object):
             "Invalid operator %r in domain term %r" % (operator, leaf)
         assert leaf in (TRUE_LEAF, FALSE_LEAF) or left in model._all_columns \
             or left in MAGIC_COLUMNS, "Invalid field %r in domain term %r" % (left, leaf)
+        assert not isinstance(right, BaseModel), \
+            "Invalid value %r in domain term %r" % (right, leaf)
 
         table_alias = '"%s"' % (eleaf.generate_alias())