Skip to content

Commit

Permalink
[17.0][MIG] project_sequence: migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
astirpe committed Feb 8, 2024
1 parent 1dcde34 commit efe6d7c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 48 deletions.
3 changes: 3 additions & 0 deletions project_sequence/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ Contributors
- Andrea Cattalani (`Moduon <https://www.moduon.team/>`__)
- Jairo Llopis (`Moduon <https://www.moduon.team/>`__)
- Nils Coenen <[email protected]>
- `360ERP <https://www.360erp.com>`__:

- Andrea Stirpe

Other credits
-------------
Expand Down
2 changes: 1 addition & 1 deletion project_sequence/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Project Sequence",
"summary": "Add a sequence field to projects, filled automatically",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"development_status": "Alpha",
"category": "Services/Project",
"website": "https://github.com/OCA/project",
Expand Down
24 changes: 11 additions & 13 deletions project_sequence/models/project_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ def _sync_analytic_account_name(self):
continue
rec.analytic_account_id.name = rec.display_name

def name_get(self):
"""Prefix name with sequence code if they are different."""
old_result = super().name_get()
result = []
@api.depends("sequence_code", "name")
def _compute_display_name(self):
res = super()._compute_display_name()
sequence_pattern = (
self.env["ir.config_parameter"]
.sudo()
Expand All @@ -47,15 +46,14 @@ def name_get(self):
default="%(sequence_code)s - %(name)s",
)
)
for id_, name in old_result:
project = self.browse(id_)
if project.sequence_code and project.sequence_code != name:
name = sequence_pattern % {
"name": name,
"sequence_code": project.sequence_code,
}
result.append((id_, name))
return result
for project in self.filtered(
lambda pr: pr.sequence_code and pr.sequence_code != pr.name
):
project.display_name = sequence_pattern % {
"name": project.name,
"sequence_code": project.sequence_code,
}
return res

@api.model
def name_search(self, name="", args=None, operator="ilike", limit=100):
Expand Down
2 changes: 2 additions & 0 deletions project_sequence/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- Andrea Cattalani ([Moduon](https://www.moduon.team/))
- Jairo Llopis ([Moduon](https://www.moduon.team/))
- Nils Coenen \<<[email protected]>\>
- [360ERP](https://www.360erp.com):
- Andrea Stirpe
4 changes: 4 additions & 0 deletions project_sequence/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>Andrea Cattalani (<a class="reference external" href="https://www.moduon.team/">Moduon</a>)</li>
<li>Jairo Llopis (<a class="reference external" href="https://www.moduon.team/">Moduon</a>)</li>
<li>Nils Coenen &lt;<a class="reference external" href="mailto:nils.coenen&#64;nico-solutions.de">nils.coenen&#64;nico-solutions.de</a>&gt;</li>
<li><a class="reference external" href="https://www.360erp.com">360ERP</a>:<ul>
<li>Andrea Stirpe</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="other-credits">
Expand Down
26 changes: 2 additions & 24 deletions project_sequence/tests/test_project_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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["account.analytic.plan"].search([], limit=1)
cls.analytic_account = cls.env["account.analytic.account"].create(
{
"name": "aaa",
Expand Down Expand Up @@ -152,18 +141,7 @@ def test_custom_pattern(self):
def test_sync_analytic_account_name(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["account.analytic.plan"].search([], limit=1)
analytic_account = self.env["account.analytic.account"].create(
{
"name": proj.display_name,
Expand Down
14 changes: 4 additions & 10 deletions project_sequence/wizards/res_config_settings_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="project.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@id='tasks_management']" position="inside">
<div
id="project_display_name_pattern"
class="col-12 col-lg-6 o_setting_box"
>
<div class="o_setting_right_pane" name="pad_project_right_pane">
<label for="project_display_name_pattern" class="d-block" />
<field name="project_display_name_pattern" />
</div>
</div>
<xpath expr="//block[@id='tasks_management']" position="inside">
<setting id="project_display_name_pattern">
<field name="project_display_name_pattern" />
</setting>
</xpath>
</field>
</record>
Expand Down

0 comments on commit efe6d7c

Please sign in to comment.