From 193f220c866b35f6cbc640a74b57791b10024742 Mon Sep 17 00:00:00 2001 From: Vincent Larcin Date: Wed, 31 Aug 2022 06:18:55 +0000 Subject: [PATCH] [IMP] sale_project: add context key when creating projects from SOs This commit adds the `no_create_folder` context key when creating a project through a SO. This context key is used in documents_project to delay the folder creation until all projects of the SO have been created. Enterprise: https://github.com/odoo/enterprise/pull/30838 Upgrade: https://github.com/odoo/upgrade/pull/3749 Task-2944247 Part-of: odoo/odoo#99151 --- addons/sale_project/models/sale_order_line.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/sale_project/models/sale_order_line.py b/addons/sale_project/models/sale_order_line.py index 0af8ebb18d1..b9336a40b94 100644 --- a/addons/sale_project/models/sale_order_line.py +++ b/addons/sale_project/models/sale_order_line.py @@ -161,7 +161,8 @@ class SaleOrderLine(models.Model): values = self._timesheet_create_project_prepare_values() if self.product_id.project_template_id: values['name'] = "%s - %s" % (values['name'], self.product_id.project_template_id.name) - project = self.product_id.project_template_id.copy(values) + # The no_create_folder context key is used in documents_project + project = self.product_id.project_template_id.with_context(no_create_folder=True).copy(values) project.tasks.write({ 'sale_line_id': self.id, 'partner_id': self.order_id.partner_id.id, @@ -179,7 +180,8 @@ class SaleOrderLine(models.Model): ]) if project_only_sol_count == 1: values['name'] = "%s - [%s] %s" % (values['name'], self.product_id.default_code, self.product_id.name) if self.product_id.default_code else "%s - %s" % (values['name'], self.product_id.name) - project = self.env['project.project'].create(values) + # The no_create_folder context key is used in documents_project + project = self.env['project.project'].with_context(no_create_folder=True).create(values) # Avoid new tasks to go to 'Undefined Stage' if not project.type_ids: