[REF] *: share field is now a computed field, if the user is in the employee group or not

bzr revid: dle@openerp.com-20140324143558-jqdm33c0i7wna3va
This commit is contained in:
Denis Ledoux 2014-03-24 15:35:58 +01:00
parent 5692dbdb5e
commit 6cf9867f15
7 changed files with 18 additions and 17 deletions

View File

@ -30,10 +30,3 @@ class portal(osv.osv):
_columns = {
'is_portal': fields.boolean('Portal', help="If checked, this group is usable as a portal."),
}
class res_users(osv.Model):
_inherit = 'res.users'
def _signup_create_user(self, cr, uid, values, context=None):
values['share'] = True
return super(res_users, self)._signup_create_user(cr, uid, values, context=context)

View File

@ -6,9 +6,6 @@
<record id="base.group_portal" model="res.groups">
<field name="is_portal" eval="True"/>
</record>
<record id="auth_signup.default_template_user" model="res.users">
<field name="share" eval="True"/>
</record>
</data>
</openerp>

View File

@ -22,7 +22,6 @@
Mr Demo Portal</field>
<!-- Avoid auto-including this user in any default group -->
<field name="groups_id" eval="[(5,)]"/>
<field name="share" eval="True" />
</record>
<!-- Add the demo user to the portal (and therefore to the portal member group) -->

View File

@ -209,7 +209,6 @@ class wizard_user(osv.osv_memory):
'login': extract_email(wizard_user.email),
'partner_id': wizard_user.partner_id.id,
'groups_id': [(6, 0, [])],
'share': True,
}
user_id = res_users.create(cr, uid, values, context=create_context)
return res_users.browse(cr, uid, user_id, context)

View File

@ -38,9 +38,25 @@ class res_groups(osv.osv):
class res_users(osv.osv):
_name = 'res.users'
_inherit = 'res.users'
def _is_share(self, cr, uid, ids, name, args, context=None):
res = {}
for user in self.browse(cr, uid, ids, context=context):
res[user.id] = not self.has_group(cr, user.id, 'base.group_user')
return res
def _get_users_from_group(self, cr, uid, ids, context=None):
result = set()
for group in self.pool['res.groups'].browse(cr, uid, ids, context=context):
result.update(user.id for user in group.users)
return list(result)
_columns = {
'share': fields.boolean('Share User', readonly=True,
help="External user with limited access, created only for the purpose of sharing data.")
'share': fields.function(_is_share, string='Share User', type='boolean',
store={
'res.users': (lambda self, cr, uid, ids, c={}: ids, None, 50),
'res.groups': (_get_users_from_group, None, 50),
}, help="External user with limited access, created only for the purpose of sharing data."),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -3,7 +3,6 @@
<data noupdate="1">
<record id="base.public_user" model="res.users">
<field eval="[(4, ref('group_share_user'))]" name="groups_id"/>
<field name="share" eval="True" />
</record>
</data>
</openerp>

View File

@ -258,7 +258,6 @@ class share_wizard(osv.TransientModel):
'name': new_user,
'email': new_user,
'groups_id': [(6,0,[group_id])],
'share': True,
'company_id': current_user.company_id.id,
'company_ids': [(6, 0, [current_user.company_id.id])],
}, context)
@ -276,7 +275,6 @@ class share_wizard(osv.TransientModel):
'password': new_pass,
'name': new_login,
'groups_id': [(6,0,[group_id])],
'share': True,
'company_id': current_user.company_id.id,
'company_ids': [(6, 0, [current_user.company_id.id])],
}, context)