From fb2225ccc4e6eeb3cb294d2311f12326044f98ee Mon Sep 17 00:00:00 2001
From: benjamin <benjamin@le-filament.com>
Date: Wed, 27 Sep 2023 15:55:00 +0200
Subject: [PATCH] [update] access rights

---
 models/scop_cotisation_cg_exo.py | 10 ----------
 security/security_rules.xml      | 14 ++++++++++----
 views/res_partner.xml            |  2 +-
 3 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/models/scop_cotisation_cg_exo.py b/models/scop_cotisation_cg_exo.py
index f6cd070..3958a22 100644
--- a/models/scop_cotisation_cg_exo.py
+++ b/models/scop_cotisation_cg_exo.py
@@ -119,16 +119,6 @@ class ScopCotisationExo(models.Model):
         column1="exo_id",
         string="Bordereaux",
     )
-    company_id = fields.Many2one(
-        comodel_name="res.company",
-        string="Company",
-        change_default=True,
-        required=True,
-        readonly=True,
-        default=lambda self: self.env["res.company"]._company_default_get(
-            "scop.cotisation.cg.followup"
-        ),
-    )
     exo_line_ids = fields.One2many(
         comodel_name="scop.cotisation.cg.exo.line",
         inverse_name="exo_id",
diff --git a/security/security_rules.xml b/security/security_rules.xml
index 0dbebc3..6bd7c56 100644
--- a/security/security_rules.xml
+++ b/security/security_rules.xml
@@ -2,13 +2,19 @@
 <odoo>
 
     <data noupdate="1">
-        <record id="invoice_comp_rule" model="ir.rule">
-            <field name="name">CG Scop - Cotisation - Exonérations multi-company</field>
+        <record id="cotisation_exo_user_rule" model="ir.rule">
+            <field name="name">CG Scop - Cotisation - Exonérations multi-company user</field>
             <field name="model_id" ref="model_scop_cotisation_cg_exo" />
-            <field name="global" eval="True" />
+            <field name="groups" eval="[(6, 0, [ref('base.group_user')])]" />
             <field
                 name="domain_force"
-            >['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
+            >['|',('partner_id.ur_id','=',False),('partner_id.ur_id','=',user.ur_id.id)]</field>
+        </record>
+        <record id="cotisation_exo_admin_rule" model="ir.rule">
+            <field name="name">CG Scop - Cotisation - Exonérations multi-company admin</field>
+            <field name="model_id" ref="model_scop_cotisation_cg_exo" />
+            <field name="domain_force">[(1,'=',1)]</field>
+            <field name="groups" eval="[(6, 0, [ref('cgscop_partner.group_cg_administrative')])]" />
         </record>
     </data>
 </odoo>
diff --git a/views/res_partner.xml b/views/res_partner.xml
index 18864fb..902f6b9 100644
--- a/views/res_partner.xml
+++ b/views/res_partner.xml
@@ -13,7 +13,7 @@
                     <page
                         name='scop_exo'
                         string="Exonérations"
-                        attrs="{'invisible': ['|', ('is_cooperative', '!=', True), ('project_status', '!=', '4_suivi')]}"
+                        attrs="{'invisible': ['|', ('is_cooperative', '!=', True), ('project_status', 'not in', ['4_suivi', '6_decede'])]}"
                     >
                             <field name="exo_ids" mode="tree,form" readonly="1">
                                 <tree create="false" edit="false" delete="false">
-- 
GitLab