From 8ccca4c6c5c236a2fc39b29f1d0c8076aa3d7b5e Mon Sep 17 00:00:00 2001 From: Benjamin <benjamin@le-filament.com> Date: Thu, 5 Mar 2020 17:51:20 +0100 Subject: [PATCH] [cgscop #129] Blocage lignes de temps + modif search view --- models/hr_timesheet.py | 5 +++-- views/cgscop_timesheet_sheet.xml | 4 ++-- views/hr_timesheet.xml | 23 ++++++++++++++++++----- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/models/hr_timesheet.py b/models/hr_timesheet.py index 42ec164..aedc05c 100644 --- a/models/hr_timesheet.py +++ b/models/hr_timesheet.py @@ -31,6 +31,7 @@ class ScopHrTimesheet(models.Model): readonly=True, copy=False) state = fields.Selection([ + ('to_report', 'A rapporter'), ('draft', 'Brouillon'), ('submit', 'Soumis'), ('valid', 'Validé')], @@ -47,8 +48,8 @@ class ScopHrTimesheet(models.Model): @api.depends('sheet_id', 'sheet_id.state') def _compute_state(self): for timesheet in self: - if not timesheet.sheet_id or timesheet.sheet_id.state == 'draft': - timesheet.state = "draft" + if not timesheet.sheet_id: + timesheet.state = "to_report" else: timesheet.state = timesheet.sheet_id.state diff --git a/views/cgscop_timesheet_sheet.xml b/views/cgscop_timesheet_sheet.xml index 91dbf12..be17a39 100644 --- a/views/cgscop_timesheet_sheet.xml +++ b/views/cgscop_timesheet_sheet.xml @@ -38,7 +38,7 @@ <div class="oe_title"> <label for="name" class="oe_edit_only"/> <h1> - <field name="name"/> + <field name="name" attrs="{'readonly': [('can_edit','=', False), ('state','!=', 'draft')]}"/> </h1> </div> <group> @@ -54,7 +54,7 @@ </group> </group> <field name="can_edit" invisible="1"/> - <field name="timesheet_line_ids" widget="many2many" domain="[('sheet_id', '=', False), ('employee_id', '=', employee_id)]" options="{'reload_on_button': True}" attrs="{'readonly': [('can_edit','=', False)]}" context="{'form_view_ref' : 'hr_timesheet.timesheet_view_form_user'}"> + <field name="timesheet_line_ids" widget="many2many" domain="[('sheet_id', '=', False), ('employee_id', '=', employee_id)]" options="{'reload_on_button': True}" attrs="{'readonly': [('can_edit','=', False), ('state','!=', 'draft')]}" context="{'form_view_ref' : 'hr_timesheet.timesheet_view_form_user'}"> <tree editable="top"> <field name="date"/> <field name="employee_id" readonly="1"/> diff --git a/views/hr_timesheet.xml b/views/hr_timesheet.xml index b3eebd6..276590a 100644 --- a/views/hr_timesheet.xml +++ b/views/hr_timesheet.xml @@ -14,10 +14,18 @@ <field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_search"/> <field name="arch" type="xml"> <field name="task_id" position="replace"/> + <field name="project_id" position="attributes"> + <attribute name="string">Code activité UR</attribute> + </field> + <field name="project_id" position="after"> + <field name="partner_id" string="Contact"/> + </field> <xpath expr="//filter[@name='mine']" position="after"> <separator></separator> <filter domain="[('sheet_id', '=', False)]" string="A soumettre" name="no_report"/> - <filter domain="[('sheet_id', '!=', False)]" string="Soumis" name="submitted"/> + <filter domain="[('state', '=', 'draft')]" string="En brouillon" name="draft"/> + <filter domain="[('state', '=', 'submit')]" string="Soumis" name="submitted"/> + <filter domain="[('state', '=', 'valid')]" string="Validé" name="validated"/> </xpath> <xpath expr="//filter[@name='groupby_task']" position="replace"> <filter string="Contact" name="groupby_partner" domain="[]" context="{'group_by':'partner_id'}"/> @@ -59,24 +67,29 @@ <field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_tree"/> <field name="arch" type="xml"> <field name="name" position="replace"/> + <field name="date" position="attributes" > + <attribute name="attrs">{'readonly': [('state', 'in', ('submit', 'valid'))]}</attribute> + </field> <field name="project_id" position="attributes" > <attribute name="options">{'no_open': True, 'no_create': True}</attribute> <attribute name="string">Code activité UR</attribute> + <attribute name="attrs">{'readonly': [('state', 'in', ('submit', 'valid'))]}</attribute> </field> <field name="project_id" position="after" > - <field name="partner_id" domain="[('is_company', '=', True), ('ur_id', '=', ur_id)]" required="True" class="td-ellipsis" options="{'no_open': True, 'no_create': True}" string="Contact"/> - <field name="name" class="td-minwidth" /> + <field name="partner_id" domain="[('is_company', '=', True), ('ur_id', '=', ur_id)]" required="True" class="td-ellipsis" options="{'no_open': True, 'no_create': True}" string="Contact" attrs="{'readonly': [('state', 'in', ('submit', 'valid'))]}"/> + <field name="name" class="td-minwidth" attrs="{'readonly': [('state', 'in', ('submit', 'valid'))]}"/> </field> <field name="task_id" position="attributes"> <attribute name="invisible">True</attribute> </field> <field name="unit_amount" position="attributes"> <attribute name="widget">float_time</attribute> + <attribute name="attrs">{'readonly': [('state', 'in', ('submit', 'valid'))]}</attribute> </field> <field name="unit_amount" position="after"> - <field name="ur_financial_system_id" options="{'no_open': True, 'no_create': True}"/> + <field name="ur_financial_system_id" options="{'no_open': True, 'no_create': True}" attrs="{'readonly': [('state', 'in', ('submit', 'valid'))]}"/> <field name="state" /> - <field name="ur_id" /> + <field name="ur_id" attrs="{'readonly': [('state', 'in', ('submit', 'valid'))]}"/> </field> </field> </record> -- GitLab