summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorJulien Castiaux <juc@odoo.com>2019-05-16 07:46:38 +0000
committerJulien Castiaux <juc@odoo.com>2019-05-16 08:36:03 +0000
commit70e2636e1b19ed06d6a425615c4a3842d5356dc3 (patch)
tree0e873ed07136dab731a14dd4e5c6739a676a1e33 /addons
parent2c3451de12bd120d0d72f7b50803f42e89f2f141 (diff)
[FIX] sale_timesheet: duplicate project from Sale Order
1) In the settings of project, enable sub-tasks. 2) Create a new project with a sub-task. 3) Create a new product (type service). 4) In the "Sales" tab of the product check the "Create a new project but no task" in the service tracking options and select the created project as project template. 5) Create an invoice for that service and confirm it. The sale order is set on the tasks of the duplicated project but not on the sub-tasks. The `write` mechanic is override in project.task to apply modifications done on the parent task to its sub-tasks. The method `_subtask_write_values` is used to gather `{field: value}` pairs and update the sub-tasks. That method is override in `sale_timesheet` in order to force the `sale_line_id` to `False` when the project is duplicated because the duplicated project is not attached to the sale order of the original model. The fix has been re-write the `sale_line_id` value on sub-tasks. opw-1985484 closes odoo/odoo#33416 Signed-off-by: Jérome Maes (jem) <jem@openerp.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/sale_timesheet/models/sale_order.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/addons/sale_timesheet/models/sale_order.py b/addons/sale_timesheet/models/sale_order.py
index c76798bce10..1e1df8677a7 100644
--- a/addons/sale_timesheet/models/sale_order.py
+++ b/addons/sale_timesheet/models/sale_order.py
@@ -236,6 +236,10 @@ class SaleOrderLine(models.Model):
'partner_id': self.order_id.partner_id.id,
'email_from': self.order_id.partner_id.email,
})
+ # duplicating a project doesn't set the SO on sub-tasks
+ project.tasks.filtered(lambda task: task.parent_id != False).write({
+ 'sale_line_id': self.id,
+ })
else:
project = self.env['project.project'].create(values)
# link project as generated by current so line