Skip to content

Commit b922525

Browse files
committed
[FIX] project_sequence: support preexisting sequenceless projects
1 parent 51659ff commit b922525

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

project_sequence/models/project_project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def create(self, vals_list):
7676
# It is important to set sequence_code before calling super() because
7777
# other modules such as hr_timesheet expect the name to always have a value
7878
for vals in vals_list:
79-
if not vals.get("sequence_code", False):
79+
if "sequence_code" not in vals:
8080
vals["sequence_code"] = self.env["ir.sequence"].next_by_code(
8181
"project.sequence"
8282
)

project_sequence/tests/test_project_sequence.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -111,35 +111,16 @@ def test_sequence_unique(self):
111111
@users("manager")
112112
def test_project_without_sequence(self):
113113
"""Preexisting projects had no sequence, and they should display fine."""
114-
proj1 = self.env["project.project"].search(
115-
[
116-
("sequence_code", "=", False),
117-
],
118-
limit=1,
114+
proj1 = self.env["project.project"].create(
115+
{"name": "one", "sequence_code": False}
119116
)
120-
proj1.name = "one"
121-
self.assertFalse(proj1.sequence_code)
122117
self.assertEqual(proj1.display_name, "one")
118+
self.assertFalse(proj1.sequence_code)
123119
# Make sure that the sequence is not increased
124120
proj2 = self.env["project.project"].create({"name": "two"})
125121
self.assertEqual(proj2.sequence_code, "23-00011")
126122
self.assertEqual(proj2.display_name, "23-00011 - two")
127123

128-
@users("manager")
129-
def test_project_with_empty_sequence(self):
130-
"""Sequence is applied when creating project with an empty sequence"""
131-
proj1 = self.env["project.project"].create(
132-
{"name": "whatever", "sequence_code": ""}
133-
)
134-
self.assertEqual(proj1.sequence_code, "23-00011")
135-
self.assertEqual(proj1.display_name, "23-00011 - whatever")
136-
# Sequence is applied when creating project with sequence in False
137-
proj2 = self.env["project.project"].create(
138-
{"name": "whatever", "sequence_code": False}
139-
)
140-
self.assertEqual(proj2.sequence_code, "23-00012")
141-
self.assertEqual(proj2.display_name, "23-00012 - whatever")
142-
143124
def test_custom_pattern(self):
144125
"""Display name pattern can be customized."""
145126
self.env["ir.config_parameter"].set_param(

0 commit comments

Comments
 (0)