[FW][FIX] sale_project,sale_timesheet: display Sale Order button w/o need for Billable

Previously, the button Sale Order in a Project form could only be seen when the sale_timesheet module (installed automatically with the Timesheet, Sales and Project apps) is installed.
Now, only the Sales and Project apps are needed to be able to display the Sale Order button.

opw-2530161

closes odoo/odoo#74048

X-original-commit: 42fcb59373fda8c82b2402b5524160215553df68
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
Signed-off-by: prro-odoo <proose@users.noreply.github.com>
This commit is contained in:
prro-odoo
2021-07-22 15:52:42 +00:00
parent d570c7eba5
commit 7af4feb078
4 changed files with 22 additions and 19 deletions
+13
View File
@@ -42,6 +42,19 @@ class Project(models.Model):
overview.project_overview = True
(self - overview).project_overview = False
def action_view_so(self):
self.ensure_one()
action_window = {
"type": "ir.actions.act_window",
"res_model": "sale.order",
"name": "Sales Order",
"views": [[False, "form"]],
"context": {"create": False, "show_sale": True},
"res_id": self.sale_order_id.id
}
return action_window
class ProjectTask(models.Model):
_inherit = "project.task"
@@ -28,6 +28,15 @@
<field name="model">project.project</field>
<field name="inherit_id" ref="project.edit_project"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='%(project.act_project_project_2_project_task_all)d']" position="before">
<button class="d-none d-md-inline oe_stat_button"
type="object" name="action_view_so" icon="fa-dollar"
attrs="{'invisible': [('sale_order_id', '=', False)]}"
string="Sales Order"
groups="sales_team.group_sale_salesman_all_leads">
<field name="sale_order_id" attrs="{'invisible': True}"/>
</button>
</xpath>
<xpath expr="//field[@name='partner_id']" position="attributes">
<attribute name="options">{'always_reload': True}</attribute>
<attribute name="context">{'res_partner_search_mode': 'customer'}</attribute>
-12
View File
@@ -241,18 +241,6 @@ class Project(models.Model):
},
}
def action_view_so(self):
self.ensure_one()
action_window = {
"type": "ir.actions.act_window",
"res_model": "sale.order",
"name": "Sales Order",
"views": [[False, "form"]],
"context": {"create": False, "show_sale": True},
"res_id": self.sale_order_id.id
}
return action_window
# ----------------------------
# Project Updates
# ----------------------------
@@ -9,13 +9,6 @@
<xpath expr="//button[@name='%(project.action_project_task_burndown_chart_report)d']" position="after">
<button string="Costs / Revenues" class="oe_stat_button" type="object" name="action_view_timesheet" icon="fa-puzzle-piece" attrs="{'invisible': [('allow_billable', '=', False)]}" groups="project.group_project_manager"/>
</xpath>
<xpath expr="//button[@name='%(project.act_project_project_2_project_task_all)d']" position="before">
<button class="d-none d-md-inline oe_stat_button"
type="object" name="action_view_so" icon="fa-dollar"
attrs="{'invisible': ['|', ('allow_billable', '=', False), ('sale_order_id', '=', False)]}"
string="Sales Order"
groups="sales_team.group_sale_salesman_all_leads"/>
</xpath>
<xpath expr="//header" position="inside">
<button name="action_make_billable" string="Create Sales Order" type="object" attrs="{'invisible': [('display_create_order', '=', False)]}" groups="sales_team.group_sale_salesman"/>
</xpath>