[IMP] sale_timesheet: add project sharing views

task-2379518

closes #73341
This commit is contained in:
Xavier BOL (xbo)
2021-08-26 14:59:33 +02:00
parent 31d943666f
commit 0748caa97c
3 changed files with 46 additions and 0 deletions
+1
View File
@@ -27,6 +27,7 @@ have real delivered quantities in sales orders.
'views/res_config_settings_views.xml',
'views/hr_timesheet_templates.xml',
'views/sale_timesheet_portal_templates.xml',
'views/project_sharing_views.xml',
'report/project_profitability_report_analysis_views.xml',
'data/sale_timesheet_filters.xml',
'wizard/project_create_sale_order_views.xml',
+8
View File
@@ -354,6 +354,14 @@ class ProjectTask(models.Model):
remaining_hours_so = fields.Float('Remaining Hours on SO', compute='_compute_remaining_hours_so', compute_sudo=True)
remaining_hours_available = fields.Boolean(related="sale_line_id.remaining_hours_available")
@property
def SELF_READABLE_FIELDS(self):
return super().SELF_READABLE_FIELDS | {
'allow_billable',
'remaining_hours_available',
'remaining_hours_so',
}
@api.depends('sale_line_id', 'timesheet_ids', 'timesheet_ids.unit_amount')
def _compute_remaining_hours_so(self):
# TODO This is not yet perfectly working as timesheet.so_line stick to its old value although changed
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="project_sharing_inherit_project_task_view_form" model="ir.ui.view">
<field name="name">project.task.form.inherit.timesheet</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.project_sharing_project_task_view_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='timesheet_ids']/tree" position="attributes">
<attribute name="decoration-muted">timesheet_invoice_id != False</attribute>
</xpath>
<xpath expr="//field[@name='timesheet_ids']/tree/field[@name='unit_amount']" position="before">
<field name="timesheet_invoice_id" invisible="1"/>
<field name="so_line"
attrs="{'column_invisible': [('parent.allow_billable', '=', False)]}"
context="{'with_remaining_hours': True, 'with_price_unit': True}" options="{'no_create': True, 'no_open': True}"
optional="hide"/>
</xpath>
<xpath expr="//field[@name='remaining_hours']" position="after">
<field name="allow_billable" invisible="1" />
<field name="remaining_hours_available" invisible="1"/>
<span id="remaining_hours_so_label" attrs="{'invisible': ['|', '|', '|', '|', ('allow_billable', '=', False), ('sale_order_id', '=', False), ('partner_id', '=', False), ('sale_line_id', '=', False), ('remaining_hours_available', '=', False)]}">
<label class="font-weight-bold" for="remaining_hours_so" string="Remaining Hours on SO"
attrs="{'invisible': ['|', ('encode_uom_in_days', '=', True), ('remaining_hours_so', '&lt;', 0)]}"/>
<label class="font-weight-bold" for="remaining_hours_so" string="Remaining Days on SO"
attrs="{'invisible': ['|', ('encode_uom_in_days', '=', False), ('remaining_hours_so', '&lt;', 0)]}"/>
<label class="font-weight-bold text-danger" for="remaining_hours_so" string="Remaining Hours on SO"
attrs="{'invisible': ['|', ('encode_uom_in_days', '=', True), ('remaining_hours_so', '&gt;=', 0)]}"/>
<label class="font-weight-bold text-danger" for="remaining_hours_so" string="Remaining Days on SO"
attrs="{'invisible': ['|', ('encode_uom_in_days', '=', False), ('remaining_hours_so', '&gt;=', 0)]}"/>
</span>
<field name="remaining_hours_so" nolabel="1" widget="timesheet_uom" attrs="{'invisible': ['|', '|', '|', '|', ('allow_billable', '=', False), ('sale_order_id', '=', False), ('partner_id', '=', False), ('sale_line_id', '=', False), ('remaining_hours_available', '=', False)]}"></field>
</xpath>
</field>
</record>
</odoo>