diff --git a/spreadsheet_oca/models/spreadsheet_spreadsheet.py b/spreadsheet_oca/models/spreadsheet_spreadsheet.py index 5c56917e..6f8bd740 100644 --- a/spreadsheet_oca/models/spreadsheet_spreadsheet.py +++ b/spreadsheet_oca/models/spreadsheet_spreadsheet.py @@ -29,6 +29,13 @@ class SpreadsheetSpreadsheet(models.Model): column2="user_id", string="Contributors", ) + contributor_group_ids = fields.Many2many( + "res.groups", + relation="spreadsheet_group_contributor", + column1="spreadsheet_id", + column2="group_id", + string="Contributors Groups", + ) reader_ids = fields.Many2many( "res.users", relation="spreadsheet_reader", @@ -36,6 +43,19 @@ class SpreadsheetSpreadsheet(models.Model): column2="user_id", string="Readers", ) + reader_group_ids = fields.Many2many( + "res.groups", + relation="spreadsheet_group_reader", + column1="spreadsheet_id", + column2="group_id", + string="Readers Groups", + ) + + company_id = fields.Many2one( + comodel_name="res.company", + help="If set, the spreadsheet will be available only" + " if this company is in the current companies.", + ) @api.depends("name") def _compute_filename(self): diff --git a/spreadsheet_oca/security/security.xml b/spreadsheet_oca/security/security.xml index 6b7998af..3344672c 100644 --- a/spreadsheet_oca/security/security.xml +++ b/spreadsheet_oca/security/security.xml @@ -20,6 +20,12 @@ eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]" /> + + + Spreadsheet Company Rule + + [('company_id', 'in', company_ids + [False])] + Spreadsheet Owner @@ -30,7 +36,9 @@ Spreadsheet Contributor - [('contributor_ids','=', user.id)] + ['|', ('contributor_ids','=', user.id), ('contributor_group_ids','in', user.groups_id.ids)] @@ -38,7 +46,9 @@ Spreadsheet Reader - [('reader_ids','=', user.id)] + ['|', ('reader_ids','=', user.id), ('reader_group_ids','in', user.groups_id.ids)] diff --git a/spreadsheet_oca/views/spreadsheet_spreadsheet.xml b/spreadsheet_oca/views/spreadsheet_spreadsheet.xml index 7d289c3e..cc19ca29 100644 --- a/spreadsheet_oca/views/spreadsheet_spreadsheet.xml +++ b/spreadsheet_oca/views/spreadsheet_spreadsheet.xml @@ -19,6 +19,7 @@ +