diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2019-06-03 08:12:48 +0000 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2019-06-04 06:02:24 +0000 |
| commit | fea84b57576c05cfd02cf9ff2ec7fc6b10d84119 (patch) | |
| tree | 86d1a7e46f6f19c9be66a236c2c62d658be48e0d | |
| parent | 0e403f8d8aa702b1111f56e2e750729d982ab8f2 (diff) | |
[FIX] sale_timesheet: multiple lines create new project
- Create 2 products A & B set as:
Service Invoicing Policy: Milestones (manually set quantities on order)
Service Tracking: Create a new project but no task
- Create a SO with A & B, validate
- Set a delivered quantity for both products
- Go to the project overview
Only the delivered quantity of a single SO line is retrieved in the 'To
invoice'.
It occurs because only a single SO line is linked to the project, while
both are expected to be linked to it.
opw-2003097
closes odoo/odoo#33815
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
| -rw-r--r-- | addons/sale_timesheet/models/sale_order.py | 6 | ||||
| -rw-r--r-- | addons/sale_timesheet/tests/test_sale_service.py | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/addons/sale_timesheet/models/sale_order.py b/addons/sale_timesheet/models/sale_order.py index 1e1df8677a7..940fe7390ef 100644 --- a/addons/sale_timesheet/models/sale_order.py +++ b/addons/sale_timesheet/models/sale_order.py @@ -327,6 +327,12 @@ class SaleOrderLine(models.Model): map_so_project_templates[(so_line.order_id.id, so_line.product_id.project_template_id.id)] = project else: map_so_project[so_line.order_id.id] = project + elif not project: + # Attach subsequent SO lines to the created project + so_line.project_id = ( + map_so_project_templates.get((so_line.order_id.id, so_line.product_id.project_template_id.id)) + or map_so_project.get(so_line.order_id.id) + ) if so_line.product_id.service_tracking == 'task_new_project': if not project: if so_line.product_id.project_template_id: diff --git a/addons/sale_timesheet/tests/test_sale_service.py b/addons/sale_timesheet/tests/test_sale_service.py index e13dd6c56c0..b1a65796fa6 100644 --- a/addons/sale_timesheet/tests/test_sale_service.py +++ b/addons/sale_timesheet/tests/test_sale_service.py @@ -363,8 +363,8 @@ class TestSaleService(TestCommonSaleTimesheetNoChart): # check each line has or no generate something self.assertTrue(so_line1.project_id, "Line1 should have create a project based on template A") self.assertTrue(so_line2.project_id, "Line2 should have create an empty project") - self.assertFalse(so_line3.project_id, "Line3 should not have create a project, since line1 already create a project based on template A") - self.assertFalse(so_line4.project_id, "Line4 should not have create a project, since line1 already create an empty project") + self.assertEqual(so_line3.project_id, so_line1.project_id, "Line3 should reuse project of line1") + self.assertEqual(so_line4.project_id, so_line2.project_id, "Line4 should reuse project of line2") self.assertTrue(so_line4.task_id, "Line4 should have create a new task, even if no project created.") self.assertTrue(so_line5.project_id, "Line5 should have create a project based on template B") |
