-
-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[16.0][IMP] crm_project_create: Archive or reactive the project and i…
…ts analytical account from lead. @moduon MT-8265
- Loading branch information
Showing
9 changed files
with
142 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
- Emilio Pascual ([Moduon](https://www.moduon.team/)) | ||
- Eduardo López ([Moduon](https://www.moduon.team/)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
This module extends the functionality of crm and project and allow you to create a project from opportunity or lead. | ||
|
||
It also allows archiving or reactivating the project and its analytical account from the lead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
from . import common | ||
from . import test_crm_create_project | ||
from . import test_crm_lead |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright 2024 Moduon Team S.L. | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) | ||
|
||
from odoo.tests.common import TransactionCase | ||
|
||
from odoo.addons.mail.tests.common import mail_new_test_user | ||
|
||
|
||
class TestCrmLeadCommon(TransactionCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.company = cls.env["res.company"].create( | ||
{ | ||
"name": "Company Test", | ||
} | ||
) | ||
cls.user_salesman = mail_new_test_user( | ||
cls.env, | ||
login="user_salesman", | ||
name="User Salesman", | ||
email="user_salesman@test.example.com", | ||
company_id=cls.company.id, | ||
groups="sales_team.group_sale_salesman", | ||
) | ||
cls.partner = cls.env["res.partner"].create( | ||
{ | ||
"name": "Partner Test", | ||
} | ||
) | ||
cls.lead = cls.env["crm.lead"].create( | ||
{ | ||
"name": "Test Lead", | ||
"type": "lead", | ||
"partner_id": cls.partner.id, | ||
"user_id": cls.user_salesman.id, | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright 2025 Moduon Team S.L. | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) | ||
|
||
from odoo.tests.common import Form, users | ||
|
||
from .common import TestCrmLeadCommon | ||
|
||
|
||
class TestCrmLead(TestCrmLeadCommon): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
wizard_form = Form( | ||
cls.env["crm.create.project"].with_context( | ||
active_model="crm.lead", | ||
active_id=cls.lead.id, | ||
default_lead_id=cls.lead.id, | ||
default_project_name=cls.lead.name, | ||
) | ||
) | ||
wizard = wizard_form.save() | ||
wizard.create_project() | ||
|
||
@users("user_salesman") | ||
def test_crm_lead_lost(self): | ||
"""When a lead is lost, so it's project and their analytic account.""" | ||
self.assertTrue(self.lead.project_id.active) | ||
self.assertTrue(self.lead.project_id.analytic_account_id.active) | ||
# Use the cancel wizard to archive the lead | ||
wizard_lost = self.env["crm.lead.lost"].create( | ||
{ | ||
"lost_reason_id": self.env.ref("crm.lost_reason_1").id, | ||
} | ||
) | ||
wizard_lost.with_context(active_ids=self.lead.ids).action_lost_reason_apply() | ||
self.assertFalse(self.lead.project_id.active) | ||
self.assertFalse(self.lead.project_id.analytic_account_id.active) | ||
|
||
@users("user_salesman") | ||
def test_crm_lead_archive(self): | ||
"""When a lead is archived, so it's project and their analytic account. | ||
And viceversa""" | ||
self.assertTrue(self.lead.project_id.active) | ||
self.assertTrue(self.lead.project_id.analytic_account_id.active) | ||
self.lead.action_archive() | ||
self.assertFalse(self.lead.project_id.active) | ||
self.assertFalse(self.lead.project_id.analytic_account_id.active) | ||
# Reactivate the lead | ||
self.lead.toggle_active() | ||
self.assertTrue(self.lead.project_id.active) | ||
self.assertTrue(self.lead.project_id.analytic_account_id.active) |