docuement: armor the ir.action.report.xml code

It was a little careless, better have an assertion there, at least, for
the cases we don't cover.

Historically, it has been here since commit: efeed12bea5c008ed6 ;)

bzr revid: p_christ@hol.gr-20110118164956-vboodk5j4g9eofix
This commit is contained in:
P. Christeas 2011-01-18 18:49:56 +02:00
parent 29721236fc
commit e9b56eafe2
1 changed files with 4 additions and 0 deletions

View File

@ -42,8 +42,12 @@ class ir_action_report_xml(osv.osv):
def _model_search(self, cr, uid, obj, name, args, context=None):
if not len(args):
return []
assert len(args) == 1 and args[0][1] == '=', 'expression is not what we expect: %r' % args
model_id= args[0][2]
if not model_id:
# a deviation from standard behavior: when searching model_id = False
# we return *all* reports, not just ones with empty model.
# One reason is that 'model' is a required field so far
return []
model = self.pool.get('ir.model').read(cr, uid, [model_id])[0]['model']
report_id = self.search(cr, uid, [('model','=',model)])