From 4ca68886bf95aa6821d4744f0b1fa360893cfc52 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 24 Apr 2013 12:11:55 +0200 Subject: [PATCH] [IMP] ir_model_data: added raise_on_access_error as argument to check_object_reference() bzr revid: qdp-launchpad@openerp.com-20130424101155-1lu2jgceb022oc8u --- openerp/addons/base/ir/ir_model.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index 57c4607e09c..74a1d8a809d 100644 --- a/openerp/addons/base/ir/ir_model.py +++ b/openerp/addons/base/ir/ir_model.py @@ -869,7 +869,7 @@ class ir_model_data(osv.osv): raise ValueError('No such external ID currently defined in the system: %s.%s' % (module, xml_id)) return res['model'], res['res_id'] - def check_object_reference(self, cr, uid, module, xml_id): + def check_object_reference(self, cr, uid, module, xml_id, raise_on_access_error=False): """Returns (model, res_id) corresponding to a given module and xml_id (cached), if and only if the user has the necessary access rights to see that object, otherwise raise ValueError""" model, res_id = self.get_object_reference(cr, uid, module, xml_id) @@ -877,7 +877,9 @@ class ir_model_data(osv.osv): check_right = self.pool.get(model).search(cr, uid, [('id', '=', res_id)]) if check_right: return model, res_id - raise ValueError('Not enough access rights on the external ID: %s.%s' % (module, xml_id)) + if raise_on_access_error: + raise ValueError('Not enough access rights on the external ID: %s.%s' % (module, xml_id)) + return model, False def get_object(self, cr, uid, module, xml_id, context=None): """Returns a browsable record for the given module name and xml_id or raise ValueError if not found"""