From c10435494cd82b174a9dbe1d1531a4733a149bce Mon Sep 17 00:00:00 2001
From: Benjamin <35699580+benj-filament@users.noreply.github.com>
Date: Fri, 29 Nov 2019 18:49:41 +0100
Subject: [PATCH] modification vues et ajout fonctions

---
 models/cgscop_timesheet_code.py |  5 +++++
 models/hr_timesheet.py          |  4 ----
 models/project.py               |  8 +-------
 views/cgscop_timesheet_code.xml |  1 +
 views/hr_timesheet.xml          | 19 +++++++++++++++++++
 views/hr_timesheet_cgscop.xml   | 22 +++++++++++++++-------
 6 files changed, 41 insertions(+), 18 deletions(-)

diff --git a/models/cgscop_timesheet_code.py b/models/cgscop_timesheet_code.py
index 76dc8fe..d41441c 100644
--- a/models/cgscop_timesheet_code.py
+++ b/models/cgscop_timesheet_code.py
@@ -10,3 +10,8 @@ class ScopTimesheetCode(models.Model):
     _order = 'name'
 
     name = fields.Char('Nom')
+    company_id = fields.Many2one(
+        comodel_name='res.company',
+        string='Company',
+        required=True,
+        default=lambda self: self.env.user.company_id)
diff --git a/models/hr_timesheet.py b/models/hr_timesheet.py
index 5770f42..82f77c0 100644
--- a/models/hr_timesheet.py
+++ b/models/hr_timesheet.py
@@ -16,10 +16,6 @@ class ScopHrTimesheet(models.Model):
         comodel_name='ur.financial.system',
         string='Dispositif Financier')
 
-    # ------------------------------------------------------
-    # Compute Functions
-    # ------------------------------------------------------
-
     # ------------------------------------------------------
     # OnChange Functions
     # ------------------------------------------------------
diff --git a/models/project.py b/models/project.py
index 412a08d..332c5d5 100644
--- a/models/project.py
+++ b/models/project.py
@@ -10,13 +10,7 @@ class ScopProjectTimesheet(models.Model):
     cgscop_timesheet_code_id = fields.Many2one(
         comodel_name='cgscop.timesheet.code',
         string='Code Activité CG')
+    privacy_visibility = fields.Selection(default="employees")
 
-    # ------------------------------------------------------
-    # Compute Functions
-    # ------------------------------------------------------
-
-    # ------------------------------------------------------
-    # Onchange Functions
-    # ------------------------------------------------------
 
 
diff --git a/views/cgscop_timesheet_code.xml b/views/cgscop_timesheet_code.xml
index 481a673..fbf5240 100644
--- a/views/cgscop_timesheet_code.xml
+++ b/views/cgscop_timesheet_code.xml
@@ -10,6 +10,7 @@
             <field name="arch" type="xml">
                 <tree editable='top'>
                     <field name="name" />
+                    <field name="company_id" groups="base.group_no_one" />
                 </tree>
             </field>
         </record>
diff --git a/views/hr_timesheet.xml b/views/hr_timesheet.xml
index 61d5b7d..570b1d2 100644
--- a/views/hr_timesheet.xml
+++ b/views/hr_timesheet.xml
@@ -27,5 +27,24 @@
             </field>
         </record>
 
+
+        <!-- Pivot View Timesheet CG -->
+        <record id="view_cgscop_hr_timesheet_line_pivot" model="ir.ui.view">
+            <field name="name">account.analytic.line.timesheet.cgscop.pivot</field>
+            <field name="model">account.analytic.line</field>
+            <field name="arch" type="xml">
+                <pivot string="Rapport">
+                    <field name="project_id" type="row"/>
+                    <field name="date" type="col"/>
+                    <field name="unit_amount" type="measure"/>
+                </pivot>
+            </field>
+        </record>
+
+        <!-- Hérite l'action de la fenetre -->
+        <record id="hr_timesheet.act_hr_timesheet_line" model="ir.actions.act_window">
+            <field name="view_mode">tree,form,pivot,graph</field>
+        </record>
+
     </data>
 </odoo>
\ No newline at end of file
diff --git a/views/hr_timesheet_cgscop.xml b/views/hr_timesheet_cgscop.xml
index ac9b5d7..f6ef5e9 100644
--- a/views/hr_timesheet_cgscop.xml
+++ b/views/hr_timesheet_cgscop.xml
@@ -37,6 +37,21 @@
                                 <field name="allow_timesheets" invisible="1"/>
                             </group>
                         </group>
+
+                        <group string="Configuration" name="project_config" groups="base.group_no_one">
+                            <group>
+                                <field name="user_id" string="Project Manager"
+                                        attrs="{'readonly':[('active','=',False)]}"/>
+                                <field name="sequence" groups="base.group_no_one"/>
+                                <field name="company_id" groups="base.group_multi_company"/>
+                            </group>
+                            <group >
+                                <field name="allow_timesheets" />
+                                <field name="privacy_visibility" widget="radio"/>
+                                <field name="resource_calendar_id" groups="base.group_no_one"/>
+                            </group>
+                        </group>
+
                     </sheet>
                     <div class="oe_chatter">
                         <field name="message_follower_ids" widget="mail_followers" help="Follow this project to automatically track the events associated to tasks and issues of this project." groups="base.group_user"/>
@@ -127,13 +142,6 @@
                 'default_privacy_visibility': 'employees',
                 'default_allow_timesheets': True,
             }</field>
-            <field name="help" type="html">
-                <p class="o_view_nocontent_empty_folder">
-                    Create a new project
-                </p><p>
-                    Organize your activities (plan tasks, track issues, invoice timesheets) for internal, personal or customer projects.
-                </p>
-            </field>
         </record>
 
         <menuitem
-- 
GitLab