[IMP]able to pass context into record tag in xml file and pass context {"noadmin":True} in extended group data for not allocate that group to admin user
bzr revid: hmo@tinyerp.com-20091103064636-0v855wtnh06l0zop
This commit is contained in:
parent
69036a94e0
commit
5561c46196
|
@ -60,14 +60,15 @@ class groups(osv.osv):
|
||||||
if vals['name'].startswith('-'):
|
if vals['name'].startswith('-'):
|
||||||
raise osv.except_osv(_('Error'),
|
raise osv.except_osv(_('Error'),
|
||||||
_('The name of the group can not start with "-"'))
|
_('The name of the group can not start with "-"'))
|
||||||
gid = super(groups, self).create(cr, uid, vals, context=context)
|
gid = super(groups, self).create(cr, uid, vals, context=context)
|
||||||
|
if context and context.get('noadmin', False):
|
||||||
# assign this new group to user_root
|
pass
|
||||||
user_obj = self.pool.get('res.users')
|
else:
|
||||||
aid = user_obj.browse(cr, 1, user_obj._get_admin_id(cr))
|
# assign this new group to user_root
|
||||||
if aid:
|
user_obj = self.pool.get('res.users')
|
||||||
aid.write({'groups_id': [(4, gid)]})
|
aid = user_obj.browse(cr, 1, user_obj._get_admin_id(cr))
|
||||||
|
if aid:
|
||||||
|
aid.write({'groups_id': [(4, gid)]})
|
||||||
return gid
|
return gid
|
||||||
|
|
||||||
groups()
|
groups()
|
||||||
|
|
|
@ -17,15 +17,15 @@
|
||||||
<field name="name">Employee</field>
|
<field name="name">Employee</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="res.groups" id="group_extended">
|
<record model="res.groups" context="{'noadmin':True}" id="group_extended">
|
||||||
<field name="name">Useability / Extended View</field>
|
<field name="name">Useability / Extended View</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="res.groups" id="group_extended_menu">
|
<record model="res.groups" context="{'noadmin':True}" id="group_extended_menu">
|
||||||
<field name="name">Useability / Extended Menu</field>
|
<field name="name">Useability / Extended Menu</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="res.groups" id="group_no_one">
|
<record model="res.groups" id="group_no_one" context="{'noadmin':True}">
|
||||||
<field name="name">Useability / No One</field>
|
<field name="name">Useability / No One</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,7 @@
|
||||||
<rng:zeroOrMore>
|
<rng:zeroOrMore>
|
||||||
<rng:ref name="field" />
|
<rng:ref name="field" />
|
||||||
</rng:zeroOrMore>
|
</rng:zeroOrMore>
|
||||||
|
<rng:optional><rng:attribute name="context"/></rng:optional>
|
||||||
</rng:element>
|
</rng:element>
|
||||||
</rng:define>
|
</rng:define>
|
||||||
|
|
||||||
|
|
|
@ -663,6 +663,9 @@ form: module.record_id""" % (xml_id,)
|
||||||
model = self.pool.get(rec_model)
|
model = self.pool.get(rec_model)
|
||||||
assert model, "The model %s does not exist !" % (rec_model,)
|
assert model, "The model %s does not exist !" % (rec_model,)
|
||||||
rec_id = rec.get("id",'').encode('ascii')
|
rec_id = rec.get("id",'').encode('ascii')
|
||||||
|
rec_context = rec.get("context", None)
|
||||||
|
if rec_context:
|
||||||
|
rec_context = eval(rec_context)
|
||||||
self._test_xml_id(rec_id)
|
self._test_xml_id(rec_id)
|
||||||
|
|
||||||
if self.isnoupdate(data_node) and self.mode != 'init':
|
if self.isnoupdate(data_node) and self.mode != 'init':
|
||||||
|
@ -731,7 +734,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
f_val = int(f_val)
|
f_val = int(f_val)
|
||||||
res[f_name] = f_val
|
res[f_name] = f_val
|
||||||
|
|
||||||
id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode )
|
id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
|
||||||
if rec_id:
|
if rec_id:
|
||||||
self.idref[rec_id] = int(id)
|
self.idref[rec_id] = int(id)
|
||||||
if config.get('import_partial', False):
|
if config.get('import_partial', False):
|
||||||
|
|
Loading…
Reference in New Issue