diff options
| author | Martin Trigaux <mat@odoo.com> | 2015-06-23 14:39:37 +0200 |
|---|---|---|
| committer | Antony Lesuisse <al@openerp.com> | 2015-07-09 13:50:28 +0200 |
| commit | cf63d4d277ef1ba02ff4ebcdae8583332a1775b1 (patch) | |
| tree | 0714792d825a301cf290d6e06701674630cc67ad /addons/share | |
| parent | 10f81cce31880468f3a871da99f7851aaa7f3f43 (diff) | |
[FIX] share,base: avoid loading order issues
Move share column to base instead of module share.
The column is used to filter some groups and make them hidden from the res.users
form. However, if a module was loaded before the module share (e.g. depends only
from base), when upgraded, the eventual update of a res.group regenerated the
res.user view (to compute in_group_XX fields). This recomputation was done
before the module share was loaded in the registry (due to the dependency graph)
and the override of get_application_groups was not done, including shared groups
in the user form.
As we can not guarantee that a module is loaded, better to move to base module.
As share depends only of mail and is autoinstall, it was installed on most
instances anyway.
Fixes #6324
Fixes #5820
Diffstat (limited to 'addons/share')
| -rw-r--r-- | addons/share/__init__.py | 1 | ||||
| -rw-r--r-- | addons/share/res_users.py | 53 | ||||
| -rw-r--r-- | addons/share/res_users_view.xml | 57 |
3 files changed, 0 insertions, 111 deletions
diff --git a/addons/share/__init__.py b/addons/share/__init__.py index dd5cb0e353b..62d47e36261 100644 --- a/addons/share/__init__.py +++ b/addons/share/__init__.py @@ -2,5 +2,4 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. import ir_model -import res_users import wizard diff --git a/addons/share/res_users.py b/addons/share/res_users.py deleted file mode 100644 index f0fcb6afdf4..00000000000 --- a/addons/share/res_users.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. -from openerp.osv import fields, osv -from openerp import SUPERUSER_ID - -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() - groups = self.pool['res.groups'].browse(cr, uid, ids, context=context) - # Clear cache to avoid perf degradation on databases with thousands of users - groups.invalidate_cache() - for group in groups: - result.update(user.id for user in group.users) - return list(result) - - _columns = { - '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."), - } - - -class res_groups(osv.osv): - _name = "res.groups" - _inherit = 'res.groups' - _columns = { - 'share': fields.boolean('Share Group', readonly=True, - help="Group created to set access rights for sharing data with some users.") - } - - def init(self, cr): - # force re-generation of the user groups view without the shared groups - self.update_user_groups_view(cr, SUPERUSER_ID) - parent_class = super(res_groups, self) - if hasattr(parent_class, 'init'): - parent_class.init(cr) - - def get_application_groups(self, cr, uid, domain=None, context=None): - if domain is None: - domain = [] - domain.append(('share', '=', False)) - return super(res_groups, self).get_application_groups(cr, uid, domain=domain, context=context) diff --git a/addons/share/res_users_view.xml b/addons/share/res_users_view.xml deleted file mode 100644 index cd9f7ad4f4c..00000000000 --- a/addons/share/res_users_view.xml +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<openerp> - <data> - <record model="ir.ui.view" id="res_users_search_sharing"> - <field name="name">res.users.search.share</field> - <field name="model">res.users</field> - <field name="inherit_id" ref="base.view_users_search"/> - <field name="arch" type="xml"> - <xpath expr="//field[@name='company_ids']" position="after"> - <filter name="no_share" string="Regular users only (no share user)" icon="terp-partner" - domain="[('share','=',False)]"/> - </xpath> - <xpath expr="//field[@name='company_ids']" position="after"> - <field name="share"/> - </xpath> - </field> - </record> - - <!-- Hide share users/groups by default --> - <record model="ir.actions.act_window" id="base.action_res_users"> - <field name="name">Users</field> - <field name="context">{'search_default_no_share': 1}</field> - </record> - - <record model="ir.ui.view" id="res_groups_search_sharing"> - <field name="name">res.groups.search.share</field> - <field name="model">res.groups</field> - <field name="inherit_id" ref="base.view_groups_search"/> - <field name="arch" type="xml"> - <field name="name" position="after"> - <filter name="share" string="Share Groups" domain="[('share','=',True)]"/> - <filter name="no_share" string="Non-Share Groups" domain="[('share','=',False)]"/> - <separator orientation="vertical"/> - </field> - </field> - </record> - - <!-- Hide share users/groups by default --> - <record model="ir.actions.act_window" id="base.action_res_groups"> - <field name="name">Groups</field> - <field name="context">{'search_default_no_share': 1}</field> - </record> - <record id="view_groups_form_share" model="ir.ui.view"> - <field name="name">res.groups.form</field> - <field name="model">res.groups</field> - <field name="inherit_id" ref="base.view_groups_form"/> - <field name="arch" type="xml"> - <field name="users" position="attributes"> - <attribute name="context">{'search_default_no_share':1}</attribute> - </field> - <field name="name" position="after"> - <field name="share"/> - </field> - </field> - </record> - </data> -</openerp> |
