[FIX] sale_{project,timesheet}: hide SO stat button in project update
Before this commit, when the project has a SO related, the 'Sales Order' stat button is shown in right side panel in project update even if the allow_billable=False in this project. If `allow_billable=False` then the project should be non billable and thus this stat button should not be visible. This commit hides the stat button when the project is non billable. Steps to reproduce: ================== 1) Install sale_timesheet module 2) Create a billable Project 3) Edit the project to set a SOL (Set a customer and a SOL) and save. 4) Edit the project and set `allow_billable` to `False`. 5) Go to the kanban view of the Project Update. Expected Behaviour: ================== The 'x Sales Orders' stat button should not be visible. Actual Behaviour: ================ The 'x Sales Orders' stat button is visible. Part of task-2710808 Closes #81940 X-original-commit: bc0226583a48f9eefc79c3e2a8e7069d6181f8ea Part-of: odoo/odoo#82284
This commit is contained in:
@@ -126,10 +126,11 @@ class Project(models.Model):
|
||||
if self.user_has_groups('sales_team.group_sale_salesman_all_leads'):
|
||||
buttons.append({
|
||||
'icon': 'dollar',
|
||||
'text': _('Sales Order'),
|
||||
'text': _('Sales Orders'),
|
||||
'number': self.sale_order_count,
|
||||
'action_type': 'object',
|
||||
'action': 'action_view_sos',
|
||||
'show': bool(self.sale_order_id),
|
||||
'show': self.sale_order_count > 0,
|
||||
'sequence': 1,
|
||||
})
|
||||
return buttons
|
||||
|
||||
@@ -176,11 +176,15 @@ class Project(models.Model):
|
||||
project.sale_line_id = sol or project.sale_line_employee_ids.sale_line_id[:1] # get the first SOL containing in the employee mappings if no sol found in the search
|
||||
|
||||
def _get_all_sales_orders(self):
|
||||
return super()._get_all_sales_orders() | self.sale_line_employee_ids.sale_line_id.order_id
|
||||
if self.allow_billable:
|
||||
return super()._get_all_sales_orders() | self.sale_line_employee_ids.sale_line_id.order_id
|
||||
return self.env['sale.order']
|
||||
|
||||
@api.depends('sale_line_employee_ids.sale_line_id')
|
||||
@api.depends('sale_line_employee_ids.sale_line_id', 'allow_billable')
|
||||
def _compute_sale_order_count(self):
|
||||
super()._compute_sale_order_count()
|
||||
billable_projects = self.filtered('allow_billable')
|
||||
super(Project, billable_projects)._compute_sale_order_count()
|
||||
(self - billable_projects).sale_order_count = 0
|
||||
|
||||
@api.constrains('sale_line_id')
|
||||
def _check_sale_line_type(self):
|
||||
|
||||
Reference in New Issue
Block a user