-
-
Notifications
You must be signed in to change notification settings - Fork 909
[IMP][16.0] project_sequence: set analytic's code as per project's sequence_code
#1658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 16.0
Are you sure you want to change the base?
Changes from all commits
e83198f
adcc9a5
db0704d
554c004
de82e12
be3950b
ab62cb9
8f4ab64
03036d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,18 +20,7 @@ def setUpClass(cls): | |
| ) | ||
| cls.pjr_seq = cls.env.ref("project_sequence.seq_project_sequence") | ||
| cls.pjr_seq.date_range_ids.unlink() | ||
| default_plan_id = ( | ||
| cls.env["account.analytic.plan"] | ||
| .sudo() | ||
| .search( | ||
| [ | ||
| "|", | ||
| ("company_id", "=", False), | ||
| ("company_id", "=", cls.env.company.id), | ||
| ], | ||
| limit=1, | ||
| ) | ||
| ) | ||
| default_plan_id = cls.env.company.analytic_plan_id | ||
| cls.analytic_account = cls.env["account.analytic.account"].create( | ||
| { | ||
| "name": "aaa", | ||
|
|
@@ -69,6 +58,7 @@ def test_analytic_account_after_creation_no_name(self): | |
| self.assertEqual(proj.name, "23-00011") | ||
| self.assertEqual(proj.display_name, "23-00011") | ||
| self.assertEqual(proj.analytic_account_id.name, "23-00011") | ||
| self.assertEqual(proj.analytic_account_id.code, "23-00011") | ||
|
|
||
| def test_analytic_account_after_creation_named(self): | ||
| """Project's analytic account is named like project's display name.""" | ||
|
|
@@ -78,7 +68,8 @@ def test_analytic_account_after_creation_named(self): | |
| self.assertEqual(proj.sequence_code, "23-00011") | ||
| self.assertEqual(proj.name, "whatever") | ||
| self.assertEqual(proj.display_name, "23-00011 - whatever") | ||
| self.assertEqual(proj.analytic_account_id.name, "23-00011 - whatever") | ||
| self.assertEqual(proj.analytic_account_id.name, "whatever") | ||
| self.assertEqual(proj.analytic_account_id.code, "23-00011") | ||
|
|
||
| @users("manager") | ||
| def test_sequence_copied_to_name_if_emptied(self): | ||
|
|
@@ -89,13 +80,15 @@ def test_sequence_copied_to_name_if_emptied(self): | |
| self.assertEqual(proj.name, "whatever") | ||
| self.assertEqual(proj.sequence_code, "23-00011") | ||
| self.assertEqual(proj.display_name, "23-00011 - whatever") | ||
| self.assertEqual(proj.analytic_account_id.name, "23-00011 - whatever") | ||
| self.assertEqual(proj.analytic_account_id.name, "whatever") | ||
| self.assertEqual(proj.analytic_account_id.code, "23-00011") | ||
| with Form(proj) as prj_f: | ||
| prj_f.name = False | ||
| self.assertEqual(proj.name, "23-00011") | ||
| self.assertEqual(proj.sequence_code, "23-00011") | ||
| self.assertEqual(proj.display_name, "23-00011") | ||
| self.assertEqual(proj.analytic_account_id.name, "23-00011") | ||
| self.assertEqual(proj.analytic_account_id.code, "23-00011") | ||
|
|
||
| @users("manager") | ||
| def test_sequence_not_copied_to_another_project(self): | ||
|
|
@@ -118,35 +111,16 @@ def test_sequence_unique(self): | |
| @users("manager") | ||
| def test_project_without_sequence(self): | ||
| """Preexisting projects had no sequence, and they should display fine.""" | ||
| proj1 = self.env["project.project"].search( | ||
| [ | ||
| ("sequence_code", "=", False), | ||
| ], | ||
| limit=1, | ||
| proj1 = self.env["project.project"].create( | ||
| {"name": "one", "sequence_code": False} | ||
| ) | ||
| proj1.name = "one" | ||
| self.assertFalse(proj1.sequence_code) | ||
| self.assertEqual(proj1.display_name, "one") | ||
| self.assertFalse(proj1.sequence_code) | ||
| # Make sure that the sequence is not increased | ||
| proj2 = self.env["project.project"].create({"name": "two"}) | ||
| self.assertEqual(proj2.sequence_code, "23-00011") | ||
| self.assertEqual(proj2.display_name, "23-00011 - two") | ||
|
|
||
| @users("manager") | ||
| def test_project_with_empty_sequence(self): | ||
| """Sequence is applied when creating project with an empty sequence""" | ||
| proj1 = self.env["project.project"].create( | ||
| {"name": "whatever", "sequence_code": ""} | ||
| ) | ||
| self.assertEqual(proj1.sequence_code, "23-00011") | ||
| self.assertEqual(proj1.display_name, "23-00011 - whatever") | ||
| # Sequence is applied when creating project with sequence in False | ||
| proj2 = self.env["project.project"].create( | ||
| {"name": "whatever", "sequence_code": False} | ||
| ) | ||
| self.assertEqual(proj2.sequence_code, "23-00012") | ||
| self.assertEqual(proj2.display_name, "23-00012 - whatever") | ||
|
|
||
|
yajo marked this conversation as resolved.
|
||
| def test_custom_pattern(self): | ||
| """Display name pattern can be customized.""" | ||
| self.env["ir.config_parameter"].set_param( | ||
|
|
@@ -168,21 +142,10 @@ def test_custom_pattern(self): | |
| self.assertEqual(proj.display_name, "23-00013") | ||
| self.assertEqual(proj.sequence_code, "23-00013") | ||
|
|
||
| def test_sync_analytic_account_name(self): | ||
| def test_sync_analytic_account(self): | ||
| """Set analytic account name equal to project's display name.""" | ||
| proj = self.env["project.project"].create({"name": "one"}) | ||
| default_plan_id = ( | ||
| self.env["account.analytic.plan"] | ||
| .sudo() | ||
| .search( | ||
| [ | ||
| "|", | ||
| ("company_id", "=", False), | ||
| ("company_id", "=", self.env.company.id), | ||
| ], | ||
| limit=1, | ||
| ) | ||
| ) | ||
| default_plan_id = self.env.company.analytic_plan_id | ||
| analytic_account = self.env["account.analytic.account"].create( | ||
| { | ||
| "name": proj.display_name, | ||
|
|
@@ -195,12 +158,13 @@ def test_sync_analytic_account_name(self): | |
| } | ||
| ) | ||
| proj.analytic_account_id = analytic_account | ||
| proj._sync_analytic_account_name() | ||
| self.assertEqual(proj.analytic_account_id.name, proj.display_name) | ||
| proj._sync_analytic_account() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method now syncs both self.assertEqual(proj.analytic_account_id.code, proj.sequence_code)The other test methods (
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (non-blocking): Since self.assertEqual(proj.analytic_account_id.code, proj.sequence_code)The other test methods (
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for review, indeed the analytic's code should be tested here too, it's now added |
||
| self.assertEqual(proj.analytic_account_id.name, proj.name) | ||
| self.assertEqual(proj.analytic_account_id.code, proj.sequence_code) | ||
|
|
||
| # Test when analytic_account_id is not set | ||
| proj.analytic_account_id = False | ||
| proj._sync_analytic_account_name() | ||
| proj._sync_analytic_account() | ||
| self.assertTrue(True) # Placeholder assertion to ensure the code execution | ||
|
|
||
| def test_name_search(self): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: regarding this change, I see a behavioral change. Before, an AAP without company would be considered as a default plan. Now, only the one from the company will be considered.
Could you please explain why this change?
Thanks!