-
-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] crm_required_field_by_stage: Migration
- Loading branch information
Tiago Amaral
committed
Sep 25, 2024
1 parent
0ad4d03
commit e936673
Showing
8 changed files
with
110 additions
and
14 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
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 @@ | ||
from . import test_crm_required_field_by_stage |
51 changes: 51 additions & 0 deletions
51
crm_required_field_by_stage/tests/test_crm_required_field_by_stage.py
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 2024 KMEE | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.exceptions import UserError | ||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestCrmRequiredFieldByStage(TransactionCase): | ||
def setUp(self): | ||
super().setUp() | ||
|
||
self.crm_stage_model = self.env["crm.stage"] | ||
self.crm_lead_model = self.env["crm.lead"] | ||
self.crm_stage_1 = self.crm_stage_model.create( | ||
{ | ||
"name": "CRM Stage 1", | ||
"required_field_ids": [ | ||
(4, self.env.ref("crm.field_crm_lead__phone").id) | ||
], | ||
} | ||
) | ||
self.crm_lead_1 = self.crm_lead_model.create( | ||
{ | ||
"name": "CRM Lead 1", | ||
} | ||
) | ||
|
||
def test_locking(self): | ||
with self.assertRaises(UserError): | ||
self.crm_lead_1.write( | ||
{ | ||
"stage_id": self.crm_stage_1.id, | ||
} | ||
) | ||
self.assertTrue(self.crm_lead_1.stage_id) | ||
self.crm_lead_1.write( | ||
{ | ||
"phone": "(00) 0000-0000", | ||
} | ||
) | ||
self.crm_lead_1.write( | ||
{ | ||
"stage_id": self.crm_stage_1.id, | ||
} | ||
) | ||
self.assertEqual(self.crm_lead_1.stage_id.id, self.crm_stage_1.id) | ||
self.crm_lead_1.write( | ||
{ | ||
"phone": False, | ||
} | ||
) |
1 change: 1 addition & 0 deletions
1
setup/crm_required_field_by_stage/odoo/addons/crm_required_field_by_stage
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 @@ | ||
../../../../crm_required_field_by_stage |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |