diff --git a/addons/portal/portal.py b/addons/portal/portal.py index bbab8b16cd3..d94e541eb03 100644 --- a/addons/portal/portal.py +++ b/addons/portal/portal.py @@ -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) - diff --git a/addons/portal/portal_data.xml b/addons/portal/portal_data.xml index 35dee070c71..273d1a8c463 100644 --- a/addons/portal/portal_data.xml +++ b/addons/portal/portal_data.xml @@ -6,9 +6,6 @@ - - - diff --git a/addons/portal/portal_demo.xml b/addons/portal/portal_demo.xml index 3abc9c8cef5..f6e46708bbc 100644 --- a/addons/portal/portal_demo.xml +++ b/addons/portal/portal_demo.xml @@ -22,7 +22,6 @@ Mr Demo Portal - diff --git a/addons/portal/wizard/portal_wizard.py b/addons/portal/wizard/portal_wizard.py index 3973bf6b131..3422a41baff 100644 --- a/addons/portal/wizard/portal_wizard.py +++ b/addons/portal/wizard/portal_wizard.py @@ -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) diff --git a/addons/share/res_users.py b/addons/share/res_users.py index 30200133f8e..702522478dd 100644 --- a/addons/share/res_users.py +++ b/addons/share/res_users.py @@ -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: diff --git a/addons/share/share_data.xml b/addons/share/share_data.xml index aba154a6403..c64a9099721 100644 --- a/addons/share/share_data.xml +++ b/addons/share/share_data.xml @@ -3,7 +3,6 @@ - diff --git a/addons/share/wizard/share_wizard.py b/addons/share/wizard/share_wizard.py index 10937015dd6..551b08d02cf 100644 --- a/addons/share/wizard/share_wizard.py +++ b/addons/share/wizard/share_wizard.py @@ -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)