[FIX] sale_project: not display project stat button when SO is draft

Before this commit, when the user creates a quotation and add a SOL with
product contained a project in `project_id` field, the
'Project Overview' stat button is shown even if the quotation is not
confirmed.

This commit changes the visibility condition of this button to display
it only if at least a project is contained in `project_ids` field of
`sale.order` model and if the quotation is confirmed that is when the
quotation becomes a sales order.

Step to reproduce:
=================
1) Go to the Sales app
2) Click on 'Create' button to create a quotation.
3) Add a SOL with 'Customer Care (Prepaid Hours)' product

Actual Behavior:
===============
The 'Project Overview' stat button is displayed.

Expected Behavior:
=================
This stat button should not be displayed while the quotation is not
confirmed to become a sales order.

task-2697063

closes odoo/odoo#80408

X-original-commit: ed58a99a235e4116a13982a4615c1fc8948a6ecd
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
Signed-off-by: Xavier <xbo@odoo.com>
This commit is contained in:
Xavier BOL (xbo)
2021-11-25 15:20:02 +00:00
parent 42331b3fb5
commit 15a62b155b
@@ -8,7 +8,7 @@
<field name="priority">10</field>
<field name="arch" type="xml">
<xpath expr="//button[@name='preview_sale_order']" position="before">
<button type="object" name="action_view_project_ids" class="oe_stat_button" icon="fa-puzzle-piece" attrs="{'invisible': [('project_ids', '=', [])]}" groups="project.group_project_manager">
<button type="object" name="action_view_project_ids" class="oe_stat_button" icon="fa-puzzle-piece" attrs="{'invisible': ['|', ('state', 'in', ['draft', 'sent']), ('project_ids', '=', [])]}" groups="project.group_project_manager">
<field name="project_ids" invisible="1"/>
<field name="project_count" widget="statinfo" string="Projects"/>
</button>