From 86aa170cf90306f22dc768df704f7aabc5ab5d60 Mon Sep 17 00:00:00 2001
From: hsilvant <hsilvant@scop.coop>
Date: Tue, 21 Feb 2023 12:07:49 +0100
Subject: [PATCH] =?UTF-8?q?Ajout=20d'un=20champ=20d=C3=A9l=C3=A9gu=C3=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 models/scop_gendoc_file.py       |  7 +++++++
 views/scop_gendoc_file_views.xml | 15 +++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/models/scop_gendoc_file.py b/models/scop_gendoc_file.py
index 15d443a..f8df15a 100644
--- a/models/scop_gendoc_file.py
+++ b/models/scop_gendoc_file.py
@@ -43,6 +43,13 @@ class ScopGendocFile(models.Model):
         string="Type de dossier",
         tracking=True,
     )
+    delegate_id = fields.Many2one(
+        "res.users",
+        string="Délégué",
+        domain=[("active", "=", True)],
+        ondelete="restrict",
+        tracking=True,
+    )
     ur_id = fields.Many2one(
         comodel_name="union.regionale",
         string="Union Régionale",
diff --git a/views/scop_gendoc_file_views.xml b/views/scop_gendoc_file_views.xml
index 95b88a7..b29e284 100644
--- a/views/scop_gendoc_file_views.xml
+++ b/views/scop_gendoc_file_views.xml
@@ -10,7 +10,7 @@
                     <field name="ur_id" />
                     <field name="partner_id" />
                     <field name="file_type" />
-                    <field name="member_number_int" />
+                    <field name="delegate_id" />
                 </tree>
             </field>
         </record>
@@ -54,6 +54,11 @@
                                     attrs="{'readonly': [('id','!=',False)]}"
                                 />
                                 <field name="ur_id" />
+                                <field
+                                    name="delegate_id"
+                                    options="{'no_create': True}"
+                                    required="1"
+                                />
                             </group>
                             <group col="1">
                                 <group string="Coopérative">
@@ -302,10 +307,16 @@
                     />
                     <separator />
                     <filter
-                        string="Mon UR"
+                        string="Dossiers de mon UR"
                         name="my_ur"
                         domain="[('current_user_ur_id', '=', 'ur_id')]"
                     />
+                    <filter
+                        string="Mes dossiers"
+                        name="my_files"
+                        domain="[('delegate_id','=',uid)]"
+                    />
+
                 </search>
             </field>
         </record>
-- 
GitLab