Skip to content

Commit

Permalink
[IMP] spreadsheet_oca: Add company_id on spreadsheet.spreadsheet mode…
Browse files Browse the repository at this point in the history
…l and related classic ir.rules
  • Loading branch information
legalsylvain committed Jan 27, 2025
1 parent 89676f1 commit 33aeaa4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spreadsheet_oca/models/spreadsheet_spreadsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ class SpreadsheetSpreadsheet(models.Model):
string="Readers",
)

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):
for record in self:
Expand Down
6 changes: 6 additions & 0 deletions spreadsheet_oca/security/security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"
/>
</record>

<record model="ir.rule" id="spreadsheet_company_rule">
<field name="name">Spreadsheet Company Rule</field>
<field name="model_id" ref="model_spreadsheet_spreadsheet" />
<field name="domain_force">[('company_id', 'in', company_ids + [False])]</field>
</record>
<record model="ir.rule" id="spreadsheet_owner_rule">
<field name="name">Spreadsheet Owner</field>
<field name="model_id" ref="model_spreadsheet_spreadsheet" />
Expand Down
2 changes: 2 additions & 0 deletions spreadsheet_oca/views/spreadsheet_spreadsheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<field name="arch" type="xml">
<tree js_class="spreadsheet_tree">
<field name="name" />
<field name="company_id" groups="base.group_multi_company" />
<button
name="open_spreadsheet"
type="object"
Expand Down Expand Up @@ -49,6 +50,7 @@
</h1>
<group>
<field name="owner_id" />
<field name="company_id" groups="base.group_multi_company" />
<field name="contributor_ids" widget="many2many_tags" />
<field name="reader_ids" widget="many2many_tags" />
<field
Expand Down

0 comments on commit 33aeaa4

Please sign in to comment.