[FIX] sale_timesheet: generated project must be active
When choosing a project template on a service (product config), and then archive it, the generated project on sale line confirmation will be inactive too. This commit forces the generated project to be active. Task #1884328
This commit is contained in:
@@ -223,6 +223,7 @@ class SaleOrderLine(models.Model):
|
||||
'partner_id': self.order_id.partner_id.id,
|
||||
'sale_line_id': self.id,
|
||||
'sale_order_id': self.order_id.id,
|
||||
'active': True,
|
||||
}
|
||||
if self.product_id.project_template_id:
|
||||
values['name'] = "%s - %s" % (values['name'], self.product_id.project_template_id.name)
|
||||
|
||||
@@ -287,6 +287,7 @@ class TestSaleService(TestCommonSaleTimesheetNoChart):
|
||||
project_template2 = self.env['project.project'].create({
|
||||
'name': 'Second Project TEMPLATE for services',
|
||||
'allow_timesheets': True,
|
||||
'active': False, # this template is archived
|
||||
})
|
||||
Stage = self.env['project.task.type'].with_context(default_project_id=project_template2.id)
|
||||
stage1_tmpl2 = Stage.create({
|
||||
@@ -367,6 +368,11 @@ class TestSaleService(TestCommonSaleTimesheetNoChart):
|
||||
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")
|
||||
|
||||
# check all generated project should be active, even if the template is not
|
||||
self.assertTrue(so_line1.project_id.active, "Project of Line1 should be active")
|
||||
self.assertTrue(so_line2.project_id.active, "Project of Line2 should be active")
|
||||
self.assertTrue(so_line5.project_id.active, "Project of Line5 should be active")
|
||||
|
||||
# check generated stuff are correct
|
||||
self.assertTrue(so_line1.project_id in self.project_template_state.project_ids, "Stage 1 from template B should be part of project from so line 1")
|
||||
self.assertTrue(so_line1.project_id in self.project_template_state.project_ids, "Stage 1 from template B should be part of project from so line 1")
|
||||
|
||||
Reference in New Issue
Block a user