summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorXavier BOL (xbo) <xbo@odoo.com>2020-12-16 14:49:27 +0100
committerXavier BOL (xbo) <xbo@odoo.com>2020-12-21 15:35:21 +0100
commit69c7d96e1671266e939163bde05afe684f907606 (patch)
tree8f7afba4845a91ecae4fe3ae3bdcf0b456745cc2 /addons
parentd64dfb7d4309db1ad333d79d96e9bac889d4c83c (diff)
[IMP] sale_timesheet: change SO compute behaviour
Before this commit, the compute doesn't assigned an SO on a task when the project linked has not SO and the pricing type is not task rate. Because, we give only the SO of the project to the task when the project is employee rate or project rate. This commit changes the implementation of the _compute_sale_order_id in task. Now, if the allow_billable=False or non_allow_billable=True then the SO is False. Otherwise, we give the SO of the SOL selected in the task or the SO in the project. And moreover, if the partner_id is not set, we give the partner_id defined in the SO assigned. task-2409761
Diffstat (limited to 'addons')
-rw-r--r--addons/sale_timesheet/models/project.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/addons/sale_timesheet/models/project.py b/addons/sale_timesheet/models/project.py
index cf215b5dd09..35d4751731e 100644
--- a/addons/sale_timesheet/models/project.py
+++ b/addons/sale_timesheet/models/project.py
@@ -282,17 +282,18 @@ class ProjectTask(models.Model):
for task in self:
task.analytic_account_active = task.analytic_account_active or task.analytic_account_id.active
- @api.depends('sale_line_id', 'project_id', 'allow_billable', 'bill_type', 'pricing_type', 'non_allow_billable')
+ @api.depends('sale_line_id', 'project_id', 'allow_billable', 'non_allow_billable')
def _compute_sale_order_id(self):
for task in self:
- if task.allow_billable and task.bill_type == 'customer_project' and task.pricing_type == 'employee_rate' and task.non_allow_billable:
- task.sale_order_id = False
- elif task.allow_billable and task.bill_type == 'customer_project':
- task.sale_order_id = task.project_id.sale_order_id
- elif task.allow_billable and task.bill_type == 'customer_task':
- task.sale_order_id = task.sale_line_id.sudo().order_id
- elif not task.sale_order_id:
+ if not task.allow_billable or task.non_allow_billable:
task.sale_order_id = False
+ elif task.allow_billable:
+ if task.sale_line_id:
+ task.sale_order_id = task.sale_line_id.sudo().order_id
+ elif task.project_id.sale_order_id:
+ task.sale_order_id = task.project_id.sale_order_id
+ if task.sale_order_id and not task.partner_id:
+ task.partner_id = task.sale_order_id.partner_id
@api.depends('commercial_partner_id', 'sale_line_id.order_partner_id.commercial_partner_id', 'parent_id.sale_line_id', 'project_id.sale_line_id', 'allow_billable')
def _compute_sale_line(self):