Skip to content

Commit

Permalink
[IMP] crm_project_create: add duplicate project option
Browse files Browse the repository at this point in the history
  • Loading branch information
Gokac9 committed Dec 16, 2024
1 parent 4187411 commit ed694d5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
39 changes: 23 additions & 16 deletions crm_project_create/wizards/crm_create_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ class CrmCreateProject(models.TransientModel):
project_name = fields.Char()
project_description = fields.Html()
lead_id = fields.Many2one("crm.lead")
duplicate_project_id = fields.Many2one("project.project", string="Duplicate Project")
duplicate_project_id = fields.Many2one(
"project.project", string="Duplicate Project"
)

def create_project(self):
if self.duplicate_project_id:
project = self.duplicate_project_id.copy({
"name": self.project_name,
"description": self.project_description,
"lead_id": self.lead_id.id,
})
project = self.duplicate_project_id.copy(
{
"name": self.project_name,
"description": self.project_description,
"lead_id": self.lead_id.id,
}
)
else:
project = (
self.env["project.project"]
Expand All @@ -42,15 +46,18 @@ def _prepare_create_project_values(self):
"allow_billable": True,
}
if self.duplicate_project_id:
values.update({
"name": self.project_name,
"description": self.project_description,
"lead_id": self.lead_id.id,
})
values.update(
{
"name": self.project_name,
"description": self.project_description,
"lead_id": self.lead_id.id,
}
)
else:
values.update({
"partner_id": self.lead_id.partner_id.id,
"company_id": self.lead_id.company_id.id,
})
values.update(
{
"partner_id": self.lead_id.partner_id.id,
"company_id": self.lead_id.company_id.id,
}
)
return values

2 changes: 1 addition & 1 deletion crm_project_create/wizards/crm_create_project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<group>
<field name="project_name" />
<field name="project_description" type="html" />
<field name="duplicate_project_id"/>
<field name="duplicate_project_id" />
</group>
<footer>
<button
Expand Down

0 comments on commit ed694d5

Please sign in to comment.