From 695254f4feb0acc7ed56afa634e2a317353b2e4a Mon Sep 17 00:00:00 2001
From: Benjamin <benjamin@le-filament.com>
Date: Fri, 6 Dec 2019 20:29:46 +0100
Subject: [PATCH] Modifs suite recette

---
 __manifest__.py                 |  2 ++
 models/hr_timesheet.py          |  2 +-
 security/ir.model.access.csv    |  6 ++++++
 views/cgscop_timesheet_code.xml |  4 ++--
 views/hr_timesheet.xml          | 13 ++++++++-----
 views/hr_timesheet_cgscop.xml   |  2 +-
 views/res_partner.xml           | 21 +++++++++++++++++++++
 views/ur_financial_system.xml   | 32 ++++++++++++++++++++++++++++++++
 8 files changed, 73 insertions(+), 9 deletions(-)
 create mode 100644 views/res_partner.xml
 create mode 100644 views/ur_financial_system.xml

diff --git a/__manifest__.py b/__manifest__.py
index 301ddca..d26de54 100644
--- a/__manifest__.py
+++ b/__manifest__.py
@@ -19,6 +19,8 @@
         "views/cgscop_timesheet_code.xml",
         "views/hr_timesheet.xml",
         "views/hr_timesheet_cgscop.xml",
+        "views/res_partner.xml",
+        "views/ur_financial_system.xml",
         "datas/cgscop.timesheet.code.csv",
     ]
 }
diff --git a/models/hr_timesheet.py b/models/hr_timesheet.py
index 82f77c0..05e8fcd 100644
--- a/models/hr_timesheet.py
+++ b/models/hr_timesheet.py
@@ -10,7 +10,7 @@ class ScopHrTimesheet(models.Model):
     name = fields.Char(required=False)
     cgscop_timesheet_code_id = fields.Many2one(
         related='project_id.cgscop_timesheet_code_id',
-        string='Code Activité CG',
+        string='Code Activité National',
         store=True)
     ur_financial_system_id = fields.Many2one(
         comodel_name='ur.financial.system',
diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv
index a5416be..e34ddb6 100644
--- a/security/ir.model.access.csv
+++ b/security/ir.model.access.csv
@@ -1,3 +1,9 @@
 id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
 access_cgscop_timesheet_code,access_cgscop_timesheet_code,model_cgscop_timesheet_code,base.group_user,1,0,0,0
 access_ur_financial_system,access_ur_financial_system,model_ur_financial_system,base.group_user,1,0,0,0
+access_ur_financial_system_ur_manager,access_ur_financial_system_ur,model_ur_financial_system,cgscop_partner.group_ur_list_modif,1,1,1,1
+access_ur_financial_system_cg_manager,access_ur_financial_system_cg,model_ur_financial_system,cgscop_partner.group_cg_administrator,1,1,1,1
+access_project_project_ur_manager,access_project_project_ur,model_project_project,cgscop_partner.group_ur_list_modif,1,1,1,1
+access_project_project_cg_manager,access_project_project_cg,model_project_project,cgscop_partner.group_cg_administrator,1,1,1,1
+access_account_analytic_account_ur_manager,access_account_analytic_account_ur,analytic.model_account_analytic_account,cgscop_partner.group_ur_list_modif,1,1,1,1
+access_account_analytic_account_cg_manager,access_account_analytic_account_cg,analytic.model_account_analytic_account,cgscop_partner.group_cg_administrator,1,1,1,1
diff --git a/views/cgscop_timesheet_code.xml b/views/cgscop_timesheet_code.xml
index fbf5240..2e4caca 100644
--- a/views/cgscop_timesheet_code.xml
+++ b/views/cgscop_timesheet_code.xml
@@ -23,11 +23,11 @@
         </record>
 
         <menuitem id="menu_cgscop_timesheet_code"
-            name="Codes activité CG"
+            name="Codes activité National"
             parent="hr_timesheet.hr_timesheet_menu_configuration"
             action="action_cgscop_timesheet_code_tree"
             sequence="50"
-            groups="analytic.group_analytic_accounting"/>
+            groups="cgscop_partner.group_cg_administrator"/>
 
     </data>
 </odoo>
\ No newline at end of file
diff --git a/views/hr_timesheet.xml b/views/hr_timesheet.xml
index 570b1d2..b5d8a06 100644
--- a/views/hr_timesheet.xml
+++ b/views/hr_timesheet.xml
@@ -17,13 +17,16 @@
                     <attribute name="string">Code activité UR</attribute>
                 </field>
                 <field name="project_id" position="after" >
-                    <field name="cgscop_timesheet_code_id" readonly="1"  class="td-ellipsis"/>
-                    <field name="partner_id" domain="[('is_company', '=', True)]" class="td-ellipsis" />
+                    <field name="partner_id" domain="[('is_company', '=', True)]" required="True" class="td-ellipsis" />
                     <field name="name" class="td-minwidth" />
-                    <field name="ur_financial_system_id" options="{'no_create_edit': True}"/>
                 </field>
-                <field name="task_id" position="replace"/>
+                <field name="task_id" position="attributes">
+                    <attribute name="invisible">True</attribute>
+                </field>
                 <field name="unit_amount" widget="timesheet_uom" sum="Total"/>
+                <field name="unit_amount" position="after">
+                    <field name="ur_financial_system_id" options="{'no_create_edit': True}"/>
+                </field>
             </field>
         </record>
 
@@ -34,7 +37,7 @@
             <field name="model">account.analytic.line</field>
             <field name="arch" type="xml">
                 <pivot string="Rapport">
-                    <field name="project_id" type="row"/>
+                    <field name="project_id" type="row" string="Code activité UR" />
                     <field name="date" type="col"/>
                     <field name="unit_amount" type="measure"/>
                 </pivot>
diff --git a/views/hr_timesheet_cgscop.xml b/views/hr_timesheet_cgscop.xml
index f6ef5e9..ceb4682 100644
--- a/views/hr_timesheet_cgscop.xml
+++ b/views/hr_timesheet_cgscop.xml
@@ -150,7 +150,7 @@
             action="act_cgscop_project_timesheet"
             id="menu_action_project_lines_tree"
             sequence="35"
-            groups="analytic.group_analytic_accounting"/>
+            groups="cgscop_partner.group_ur_list_modif,cgscop_partner.group_cg_administrator"/>
 
     </data>
 </odoo>
\ No newline at end of file
diff --git a/views/res_partner.xml b/views/res_partner.xml
new file mode 100644
index 0000000..1e69861
--- /dev/null
+++ b/views/res_partner.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!-- Copyright 2019 Le Filament
+     License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
+
+<odoo>
+    <data>
+
+        <!-- Tree View Timesheet CG -->
+        <record id="view_cgscop_hr_timesheet_account_inherit" model="ir.ui.view">
+            <field name="name">res.partner.cgscop.timesheet.account.inherit</field>
+            <field name="model">res.partner</field>
+            <field name="inherit_id" ref="account.view_partner_property_form"/>
+            <field name="arch" type="xml">
+                <page name="accounting" position="attributes">
+                    <attribute name="invisible">True</attribute>
+                </page>
+            </field>
+        </record>
+
+    </data>
+</odoo>
\ No newline at end of file
diff --git a/views/ur_financial_system.xml b/views/ur_financial_system.xml
new file mode 100644
index 0000000..6986375
--- /dev/null
+++ b/views/ur_financial_system.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!-- Copyright 2019 Le Filament
+     License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
+
+<odoo>
+    <data>
+        <record id="view_ur_financial_system_tree" model="ir.ui.view">
+            <field name="name">ur.financial.system.tree</field>
+            <field name="model">ur.financial.system</field>
+            <field name="arch" type="xml">
+                <tree editable='top'>
+                    <field name="name" />
+                    <field name="company_id" groups="base.group_no_one" />
+                </tree>
+            </field>
+        </record>
+
+        <record id="action_ur_financial_system" model="ir.actions.act_window">
+            <field name="name">Dispositifs financiers</field>
+            <field name="res_model">ur.financial.system</field>
+            <field name="view_mode">tree</field>
+        </record>
+
+        <menuitem id="menu_ur_financial_system"
+            name="Dispositifs financiers"
+            parent="hr_timesheet.hr_timesheet_menu_configuration"
+            action="action_ur_financial_system"
+            sequence="45"
+            groups="cgscop_partner.group_ur_list_modif"/>
+
+    </data>
+</odoo>
\ No newline at end of file
-- 
GitLab