[CLEAN] res_config, res_users: cleaned call to imd.get_object() + code cleaning
- res_config: raise by default, no need to set the argument at True - res_users: directly embedded get_user_groups_view code inside update_user_groups_view. The try / except is still necessary, because when installing a new db, groups and users are created before the user_groups_view view effectively exist. Due to some circular references, the try / except is therefore necessary to install a new db. bzr revid: tde@openerp.com-20140116134056-nyiybx7zsr8rhkiv
This commit is contained in:
parent
051ef6d01f
commit
2c32d92ee5
|
@ -446,7 +446,7 @@ class res_config_settings(osv.osv_memory, res_config_module_installation_mixin):
|
|||
ir_module = self.pool['ir.module.module']
|
||||
def ref(xml_id):
|
||||
mod, xml = xml_id.split('.', 1)
|
||||
return ir_model_data.get_object(cr, uid, mod, xml, context=context, check_existence_and_raise=True)
|
||||
return ir_model_data.get_object(cr, uid, mod, xml, context=context)
|
||||
|
||||
defaults, groups, modules, others = [], [], [], []
|
||||
for name, field in self._columns.items():
|
||||
|
|
|
@ -681,8 +681,13 @@ class groups_view(osv.osv):
|
|||
def update_user_groups_view(self, cr, uid, context=None):
|
||||
# the view with id 'base.user_groups_view' inherits the user form view,
|
||||
# and introduces the reified group fields
|
||||
view = self.get_user_groups_view(cr, uid, context)
|
||||
if view:
|
||||
# we have to try-catch this, because at first init the view does not exist
|
||||
# but we are already creating some basic groups
|
||||
try:
|
||||
view = self.pool['ir.model.data'].get_object(cr, SUPERUSER_ID, 'base', 'user_groups_view', context=context, check_existence_and_raise=False)
|
||||
except ValueError:
|
||||
view = False
|
||||
if view and view.exists() and view._table_name == 'ir.ui.view':
|
||||
xml1, xml2 = [], []
|
||||
xml1.append(E.separator(string=_('Application'), colspan="4"))
|
||||
for app, kind, gs in self.get_groups_by_application(cr, uid, context):
|
||||
|
@ -707,14 +712,6 @@ class groups_view(osv.osv):
|
|||
view.write({'arch': xml_content})
|
||||
return True
|
||||
|
||||
def get_user_groups_view(self, cr, uid, context=None):
|
||||
try:
|
||||
view = self.pool['ir.model.data'].get_object(cr, SUPERUSER_ID, 'base', 'user_groups_view', context=context, check_existence_and_raise=False)
|
||||
assert view and view.exists() and view._table_name == 'ir.ui.view'
|
||||
except Exception:
|
||||
view = False
|
||||
return view
|
||||
|
||||
def get_application_groups(self, cr, uid, domain=None, context=None):
|
||||
return self.search(cr, uid, domain or [])
|
||||
|
||||
|
|
Loading…
Reference in New Issue