odoo/enterprise#74122

Created by Framework (ORM), Christophe Matthieu (chm)
Merged at d66b77ca639b5f506cd4f050efc40212f7463fa1

Statuses:

label
odoo-dev:master-groups_id-chm
head
18c93ee15d578f49f34b2c348b6a757988b8945b
merged
2 months ago by Framework (ORM), Raphael Collet
odoo/odoo odoo/enterprise odoo/upgrade odoo/upgrade-util
master #179354 #74122 #6841 #169

Rename groups_id into group_ids and all_group_ids

see: odoo/odoo#179354

The groups_id from res.groups fields have been removed and replaced by group_ids and all_group_ids.
The users from res.groups fields have been removed and replaced by user_ids and all_user_ids.

Models:

<res.groups>:
  implied_ids        = Many2many <res.groups> Users of this group are also implicitely part of these inherited groups
  all_implied_ids    = Many2many <res.groups> Transitive and recursive closure
  implied_by_ids     = Many2many <res.groups> Automatically added from
  all_implied_by_ids = Many2many <res.groups> Reversed transitive and recursive closure

  user_ids           = Many2many <res.users>  Users with this group specifically
  all_user_ids       = Many2many <res.users>  Users and implied users

<res.users>:
  group_ids          = Many2many <res.groups> Group added directly to this user
  all_group_ids      = Many2many <res.groups> Groups and implied groups

Concept:

The groups involved are to be interpreted as sets.
Thus we can define groups that we will call for example N, Z... such as mathematical sets.
        ┌──────────────────────────────────────────┐
        │ C  ┌──────────────────────────┐          │
        │    │ R  ┌───────────────────┐ │ ┌──────┐ |   "C"
        │    │    │ Q  ┌────────────┐ │ │ │ I    | |   "I" implied "C"
        │    │    │    │ Z  ┌─────┐ │ │ │ │      | |   "R" implied "C"
        │    │    │    │    │ N   │ │ │ │ │      │ │   "Q" implied "R"
        │    │    │    │    └─────┘ │ │ │ │      │ │   "P" implied "R"
        │    │    │    └────────────┘ │ │ │      │ │   "Z" implied "Q"
        │    │    └───────────────────┘ │ │      │ │   "N" implied "Z"
        │    │      ┌───────────────┐   │ │      │ │
        │    │      │ P             │   │ │      │ │
        │    │      └───────────────┘   │ └──────┘ │
        │    └──────────────────────────┘          │
        └──────────────────────────────────────────┘
    For example:
    * A manager group will imply a user group: all managers are users (like Z imply C);
    * A group "computer developer employee" will imply that he is an employee group, a user
      group, that he has access to the timesheet user group.... "computer developer employee"
      is therefore a set of users in the intersection of these groups. These users will
      therefore have all the rights of these groups in addition to their own access rights.

XML data example:

<record model="res.groups" id="group_system">
    <field name="name">Settings</field>
    <field name="implied_ids" eval="[Command.link(ref('group_erp_manager')), Command.link(ref('group_sanitize_override'))]"/>
    <field name="user_ids" eval="[Command.link(ref('base.user_root')), Command.link(ref('base.user_admin'))]"/>
</record>
<record model="res.groups" id="group_no_one">
    <field name="name">Technical Features</field>
    <field name="implied_by_ids" eval="[Command.link(ref('group_user')), Command.link(ref('group_system'))]"/>
</record>

or

<record model="res.groups" id="group_no_one">
    <field name="name">Technical Features</field>
</record>
<record id="group_user">
    <field name="implied_ids" eval="[Command.link(ref('group_no_one'))]"/>
</record>
<record id="group_system">
    <field name="implied_ids" eval="[Command.link(ref('group_no_one'))]"/>
</record>

PY example:

group_helpdesk = self.env.ref('helpdesk.group_helpdesk_user')
group_export = self.env.ref('base.group_allow_export')
group_portal = self.env.ref('base.group_portal')

# we want all users having helpdesk and portal (directly or by implication).
user_portal_helpdesck = self.env['res.users'].search([('all_group_ids', 'in', group_helpdesk.id), ('all_group_ids', 'in', group_portal.id)])

# For these users we want to add access to export.
user_portal_helpdesck.group_ids += group_export

# we want all users having export
user_export = group_export.all_user_ids

# we want all users having specifically export (not by imply)
user_has_export = group_export.user_ids