summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjem-odoo <jem@openerp.com>2018-08-03 16:54:47 +0200
committerjem-odoo <jem@openerp.com>2018-08-13 17:32:22 +0200
commit67c8a60affea6077e5c386b6bf93d02f30201b47 (patch)
treec16673b752ed8253f9cd74f8c0266d4f540e0d46
parentcfbd57a96efec6c526042f5b8336b9baa9abb605 (diff)
[FIX] sale_timesheet: sale order line of subtasks
We want to set the sale line of the parent when changing the subtasks parent but not force changing it when modifying the SO line of the parent task, and we have to reset (empty) so line on subtasks when changing the customer of a task to avoid no seeing the current SO line in its domain (dropdown) since the customer has changed. Task #34703
-rw-r--r--addons/sale_timesheet/models/project.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/addons/sale_timesheet/models/project.py b/addons/sale_timesheet/models/project.py
index b8a1f0fc50f..0d06a4d069d 100644
--- a/addons/sale_timesheet/models/project.py
+++ b/addons/sale_timesheet/models/project.py
@@ -109,6 +109,13 @@ class ProjectTask(models.Model):
self.partner_id = self.sale_line_id.order_partner_id
return result
+ @api.onchange('partner_id')
+ def _onchange_partner_id(self):
+ result = super(ProjectTask, self)._onchange_partner_id()
+ if self.sale_line_id.order_partner_id != self.partner_id:
+ self.sale_line_id = False
+ return result
+
@api.multi
@api.constrains('sale_line_id')
def _check_sale_line_type(self):
@@ -152,6 +159,28 @@ class ProjectTask(models.Model):
raise ValidationError(_('You have to unlink the task from the sale order item in order to delete it.'))
return super(ProjectTask, self).unlink()
+ # ---------------------------------------------------
+ # Subtasks
+ # ---------------------------------------------------
+
+ @api.model
+ def _subtask_implied_fields(self):
+ result = super(ProjectTask, self)._subtask_implied_fields()
+ return result + ['sale_line_id']
+
+ def _subtask_write_values(self, values):
+ result = super(ProjectTask, self)._subtask_write_values(values)
+ # changing the partner on a task will reset the sale line of its subtasks
+ if 'partner_id' in result:
+ result['sale_line_id'] = False
+ elif 'sale_line_id' in result:
+ result.pop('sale_line_id')
+ return result
+
+ # ---------------------------------------------------
+ # Actions
+ # ---------------------------------------------------
+
@api.multi
def action_view_so(self):
self.ensure_one()