summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorRémy Baranx (bar) <bar@odoo.com>2020-02-18 14:01:14 +0000
committerYannick Tivisse <yti@odoo.com>2020-06-23 08:57:08 +0000
commitdfdeb34a89aabf13d783dbdb1dd38a0abf5eef29 (patch)
treecc85e7523cd9eafb1dae120051c25386da76b3e8 /addons
parent972e097dbe7cdc7afdae722391692f9b3bf063b8 (diff)
[IMP] sale_timesheet: convert onchanges to stored-editable computed fields.
As now the partner_id field is fully computed and not modified by an onchange method anymore, some tests have been updated.
Diffstat (limited to 'addons')
-rw-r--r--addons/sale_timesheet/models/project.py5
-rw-r--r--addons/sale_timesheet/tests/test_project_billing.py6
2 files changed, 7 insertions, 4 deletions
diff --git a/addons/sale_timesheet/models/project.py b/addons/sale_timesheet/models/project.py
index e27af7c4ff4..411e2f82202 100644
--- a/addons/sale_timesheet/models/project.py
+++ b/addons/sale_timesheet/models/project.py
@@ -263,11 +263,12 @@ class ProjectTask(models.Model):
def write(self, values):
old_sale_line_id = dict([(t.id, t.sale_line_id.id) for t in self])
+ res = super(ProjectTask, self).write(values)
+ # Done after super to avoid constraints on field recomputation
if values.get('project_id'):
project_dest = self.env['project.project'].browse(values['project_id'])
if project_dest.billable_type == 'employee_rate':
- values['sale_line_id'] = False
- res = super(ProjectTask, self).write(values)
+ self.write({'sale_line_id': False})
if 'sale_line_id' in values and self.filtered('allow_timesheets').sudo().timesheet_ids:
so = self.env['sale.order.line'].browse(values['sale_line_id']).order_id
if so and not so.analytic_account_id:
diff --git a/addons/sale_timesheet/tests/test_project_billing.py b/addons/sale_timesheet/tests/test_project_billing.py
index a7c1514a8d5..c618997c40d 100644
--- a/addons/sale_timesheet/tests/test_project_billing.py
+++ b/addons/sale_timesheet/tests/test_project_billing.py
@@ -340,7 +340,10 @@ class TestProjectBilling(TestCommonSaleTimesheetNoChart):
self.assertEqual(timesheet4.so_line, self.so1_line_deliver_no_task, "The timesheet should be linked to SOL on the project, as no entry for TDE in project map and no SOL on task")
def test_billing_task_rate(self):
- """ Check task and subtask creation, and timesheeting in a project billed at 'task rate'. Then move the task into a 'employee rate' project then, 'non billable'. """
+ """
+ Check task and subtask creation, and timesheeting in a project billed at 'task rate'.
+ Then move the task into a 'employee rate' project then, 'non billable'.
+ """
Task = self.env['project.task'].with_context(tracking_disable=True)
Timesheet = self.env['account.analytic.line']
@@ -350,7 +353,6 @@ class TestProjectBilling(TestCommonSaleTimesheetNoChart):
# create a task
task = Task.with_context(default_project_id=self.project_task_rate.id).create({
'name': 'first task',
- 'partner_id': self.partner_customer_usd.id,
})
task._onchange_project()