[FIX] sale_{project,timesheet}: hide SOL field when task is not billable

This commit hide SOL field for project task form view and hide
it's value from tree view when task is not billable and give
correct xpath on SOL field attributes to display remaining hour
and price unit in name_search.

task-3018123

X-original-commit: https://github.com/odoo/odoo/commit/eeb53703c2603ec13a8e43cd68c79959d4b9fb57
Part-of: odoo/odoo#106956
This commit is contained in:
Kartik Chavda
2022-12-06 10:52:18 +01:00
parent f1257c8e1b
commit 6e13a10519
2 changed files with 4 additions and 6 deletions
@@ -75,7 +75,7 @@
<xpath expr="//field[@name='partner_phone']" position="after">
<field name="sale_order_id" attrs="{'invisible': True}" groups="sales_team.group_sale_salesman"/>
<field name="sale_line_id" groups="!sales_team.group_sale_salesman" string="Sales Order Item" options='{"no_open": True}' readonly="1" context="{'create': False, 'edit': False, 'delete': False}"/>
<field name="sale_line_id" groups="sales_team.group_sale_salesman" string="Sales Order Item" options='{"no_create": True}' readonly="0" context="{'create': False, 'edit': False, 'delete': False}" placeholder="Non-billable"/>
<field name="sale_line_id" groups="sales_team.group_sale_salesman" string="Sales Order Item" options='{"no_create": True}' readonly="0" context="{'create': False, 'edit': False, 'delete': False, 'with_price_unit': True}" placeholder="Non-billable"/>
<field name="commercial_partner_id" invisible="1" />
</xpath>
</field>
@@ -188,15 +188,13 @@
<field name="model">project.task</field>
<field name="inherit_id" ref="sale_project.view_sale_project_inherit_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='sale_line_id']" position="attributes">
<attribute name="context">{'with_remaining_hours': True, 'with_price_unit': True}</attribute>
<xpath expr="//field[@name='sale_line_id'][2]" position="attributes">
<attribute name="context">{'create': False, 'edit': False, 'delete': False, 'with_price_unit': True, 'with_remaining_hours': True}</attribute>
<!-- To do: move allow_billable field in sale_project and add attrs directly on field in master -->
<attribute name="attrs">
{'invisible': [('allow_billable', '=', False)]}
</attribute>
</xpath>
<xpath expr="//field[@name='sale_order_id']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>
</odoo>