Skip to content
This repository was archived by the owner on Feb 13, 2024. It is now read-only.
This repository was archived by the owner on Feb 13, 2024. It is now read-only.

[RFC] new api.groups decorator #7

@legalsylvain

Description

@legalsylvain

Implementation

def groups(*groups):
    # check if current user are member of one of the given groups.
    # If not, raise an error. "To do this action, you should be member of ..."

Call sample

@oca.decorators.groups('group_1', 'group_2', '...')
def function_name(self, args):
    # custom action

Main interest

The check will be done if function is called by

  • (1) another function,
  • (2) an xml-rpc call,
  • (3) a button in a view. (<button name='function_name' />)

So it is a more secured approach that writing <button name='function_name' groups='group_xml_id'/> that does'nt prevent for the time being case 1 or 2.

Ref of the previous discussion

OCA/server-tools#944

CC : @NL66278, @ lasley, @pedrobaeza

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions