[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
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user