[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.
This commit is contained in:
Rémy Baranx (bar)
2020-06-23 08:57:08 +00:00
committed by Yannick Tivisse
parent 972e097dbe
commit dfdeb34a89
2 changed files with 7 additions and 4 deletions
+3 -2
View File
@@ -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:
@@ -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()