[IMP] in ir_model_data.get_object(), rename parameter 'check' into 'raise_exception'
bzr revid: rco@openerp.com-20140127151726-if92mwiu3xawr8ge
This commit is contained in:
parent
0ffa561bbf
commit
9518e6c323
|
@ -884,24 +884,24 @@ class ir_model_data(osv.osv):
|
||||||
raise ValueError('Not enough access rights on the external ID: %s.%s' % (module, xml_id))
|
raise ValueError('Not enough access rights on the external ID: %s.%s' % (module, xml_id))
|
||||||
return model, False
|
return model, False
|
||||||
|
|
||||||
def get_object(self, cr, uid, module, xml_id, context=None, check=True):
|
def get_object(self, cr, uid, module, xml_id, context=None, raise_exception=True):
|
||||||
""" Returns a browsable record for the given module name and xml_id.
|
""" Returns a browsable record for the given module name and xml_id.
|
||||||
If not found, raise a ValueError or return a browse_null, depending
|
If not found, raise a ValueError or return a browse_null, depending
|
||||||
on the value of `check`.
|
on the value of `raise_exception`.
|
||||||
|
|
||||||
:param check: when true, check whether record exists and raise a
|
:param raise_exception: when true, check whether record exists and
|
||||||
ValueError if it does not; otherwise return a browse_null or
|
raise a ValueError if it does not; otherwise return a browse_null
|
||||||
non-existing record.
|
or non-existing record.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
res_model, res_id = self.get_object_reference(cr, uid, module, xml_id)
|
res_model, res_id = self.get_object_reference(cr, uid, module, xml_id)
|
||||||
record = self.pool[res_model].browse(cr, uid, res_id, context=context)
|
record = self.pool[res_model].browse(cr, uid, res_id, context=context)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
if check:
|
if raise_exception:
|
||||||
raise
|
raise
|
||||||
return browse_null()
|
return browse_null()
|
||||||
|
|
||||||
if check and not record.exists():
|
if raise_exception and not record.exists():
|
||||||
raise ValueError('No record found for unique ID %s.%s. It may have been deleted.' % (module, xml_id))
|
raise ValueError('No record found for unique ID %s.%s. It may have been deleted.' % (module, xml_id))
|
||||||
return record
|
return record
|
||||||
|
|
||||||
|
|
|
@ -685,7 +685,7 @@ class groups_view(osv.osv):
|
||||||
# and introduces the reified group fields
|
# and introduces the reified group fields
|
||||||
# we have to try-catch this, because at first init the view does not exist
|
# we have to try-catch this, because at first init the view does not exist
|
||||||
# but we are already creating some basic groups
|
# but we are already creating some basic groups
|
||||||
view = self.pool['ir.model.data'].get_object(cr, SUPERUSER_ID, 'base', 'user_groups_view', context=context, check=False)
|
view = self.pool['ir.model.data'].get_object(cr, SUPERUSER_ID, 'base', 'user_groups_view', context=context, raise_exception=False)
|
||||||
if view and view.exists() and view._table_name == 'ir.ui.view':
|
if view and view.exists() and view._table_name == 'ir.ui.view':
|
||||||
xml1, xml2 = [], []
|
xml1, xml2 = [], []
|
||||||
xml1.append(E.separator(string=_('Application'), colspan="4"))
|
xml1.append(E.separator(string=_('Application'), colspan="4"))
|
||||||
|
|
Loading…
Reference in New Issue