Skip to content

Commit

Permalink
[MIG] project_sequence: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BT-mchechlacz committed Nov 20, 2024
1 parent 18471d5 commit caebc6c
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 82 deletions.
24 changes: 13 additions & 11 deletions project_sequence/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Project Sequence
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github
:target: https://github.com/OCA/project/tree/17.0/project_sequence
:target: https://github.com/OCA/project/tree/18.0/project_sequence
:alt: OCA/project
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/project-17-0/project-17-0-project_sequence
:target: https://translation.odoo-community.org/projects/project-18-0/project-18-0-project_sequence
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/project&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/project&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -70,7 +70,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/project/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/project/issues/new?body=module:%20project_sequence%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/project/issues/new?body=module:%20project_sequence%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -85,19 +85,21 @@ Authors
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 Cattalani (`Moduon <https://www.moduon.team/>`__)
- Jairo Llopis (`Moduon <https://www.moduon.team/>`__)
- Nils Coenen <[email protected]>
- `360ERP <https://www.360erp.com>`__:

- Andrea Stirpe
- Andrea Stirpe

- Marcin Chechłacz <[email protected]>

Other credits
-------------

The development of this module has been financially supported by:

- Moduon
- Moduon

Maintainers
-----------
Expand All @@ -123,6 +125,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-yajo| |maintainer-anddago78|

This module is part of the `OCA/project <https://github.com/OCA/project/tree/17.0/project_sequence>`_ project on GitHub.
This module is part of the `OCA/project <https://github.com/OCA/project/tree/18.0/project_sequence>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
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": "17.0.1.0.0",
"version": "18.0.1.0.0",
"development_status": "Alpha",
"category": "Services/Project",
"website": "https://github.com/OCA/project",
Expand Down
4 changes: 2 additions & 2 deletions project_sequence/data/ir_sequence.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Moduon Team S.L.
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) -->
<data noupdate="1">
<odoo noupdate="1">
<record id="seq_project_sequence" model="ir.sequence">
<field name="name">Project sequence</field>
<field name="code">project.sequence</field>
Expand All @@ -10,4 +10,4 @@
<field name="padding">5</field>
<field name="company_id" eval="False" />
</record>
</data>
</odoo>
7 changes: 0 additions & 7 deletions project_sequence/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,3 @@ msgid ""
msgstr ""
"Verwenden Sie %(sequence_code)s und %(name)s, um den Sequenzcode und den "
"Namen des Projekts in den Anzeigenamen aufzunehmen."

#~ msgid ""
#~ "Name of your project. It can be anything you want e.g. the name of a "
#~ "customer or a service."
#~ msgstr ""
#~ "Name Ihres Projekts. Es kann alles sein, was Sie wollen, z.B. der Name "
#~ "eines Kunden oder einer Dienstleistung."
19 changes: 0 additions & 19 deletions project_sequence/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,3 @@ msgid ""
msgstr ""
"Utilice %(sequence_code)s y %(name)s para incluir el código de secuencia y "
"el nombre del proyecto en el nombre de visualización."

#~ msgid ""
#~ "Name of your project. It can be anything you want e.g. the name of a "
#~ "customer or a service."
#~ msgstr ""
#~ "Nombre de su proyecto. Puede ser cualquier cosa, por ejemplo, el nombre "
#~ "de un cliente o de un servicio."

#~ msgid "Display Name"
#~ msgstr "Nombre"

#~ msgid "ID"
#~ msgstr "ID"

#~ msgid "Last Modified on"
#~ msgstr "Última modificación el"

#~ msgid "Code"
#~ msgstr "Código"
10 changes: 0 additions & 10 deletions project_sequence/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,3 @@ msgid ""
msgstr ""
"Utilizzare %(sequence_code)s e %(name)s per includere il codice sequenza e "
"il nome del progetto nel nome visualizzato."

#~ msgid ""
#~ "Name of your project. It can be anything you want e.g. the name of a "
#~ "customer or a service."
#~ msgstr ""
#~ "Nome del progetto. Può essere qualsiasi cosa es. il nome di un cliente o "
#~ "di un servizio."

#~ msgid "WBS element"
#~ msgstr "Elemento WBS"
7 changes: 0 additions & 7 deletions project_sequence/i18n/nl.po
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,3 @@ msgid ""
msgstr ""
"Gebruik %(sequence_code)s en %(name)s om de sequentiecode en de naam van het "
"project op te nemen in de weergavenaam."

#~ msgid ""
#~ "Name of your project. It can be anything you want e.g. the name of a "
#~ "customer or a service."
#~ msgstr ""
#~ "Naam van uw project. Het kan alles zijn wat je wilt, b.v. de naam van een "
#~ "klant of dienst."
21 changes: 16 additions & 5 deletions project_sequence/models/project_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class ProjectProject(models.Model):
def _sync_analytic_account_name(self):
"""Set analytic account name equal to project's display name."""
for rec in self:
if not rec.analytic_account_id:
if not rec.account_id:
continue
rec.analytic_account_id.name = rec.display_name
rec.account_id.name = rec.display_name

@api.depends("sequence_code", "name")
def _compute_display_name(self):
Expand All @@ -58,11 +58,22 @@ def _compute_display_name(self):
@api.model
def name_search(self, name="", args=None, operator="ilike", limit=100):
"""Allow searching by sequence code by default."""
result = super().name_search(name, args, operator, limit)
# Do not add any domain when user just clicked on search widget
if not (name == "" and operator == "ilike"):
# The dangling | is needed to combine with the domain added by super()
args = (args or []) + ["|", ("sequence_code", operator, name)]
return super().name_search(name, args, operator, limit)
# We need additional search, as in super() method call expression
# `AND` is used and there is no easy way to add `OR` in the final domain
projects = self.search_fetch(
[
("sequence_code", operator, name),
"!",
("display_name", operator, name),
],
["display_name"],
limit=limit,
).mapped(lambda p: (p.id, p.display_name))
result.extend(projects)
return result

@api.model_create_multi
def create(self, vals_list):
Expand Down
1 change: 1 addition & 0 deletions project_sequence/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
- Nils Coenen \<<[email protected]>\>
- [360ERP](https://www.360erp.com):
- Andrea Stirpe
- Marcin Chechłacz <<[email protected]>>
18 changes: 11 additions & 7 deletions project_sequence/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -368,7 +369,7 @@ <h1 class="title">Project Sequence</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1f5fa8a055e490ef71c2d3615c282b279ff28686293e63917c5379f3a97c3484
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/project/tree/17.0/project_sequence"><img alt="OCA/project" src="https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/project-17-0/project-17-0-project_sequence"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/project&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/project/tree/18.0/project_sequence"><img alt="OCA/project" src="https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/project-18-0/project-18-0-project_sequence"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/project&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Add a sequence field to projects, filled automatically and add a code
sequence filter in tree view project.</p>
<div class="admonition important">
Expand Down Expand Up @@ -420,7 +421,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/project/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/project/issues/new?body=module:%20project_sequence%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/project/issues/new?body=module:%20project_sequence%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -441,6 +442,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>Andrea Stirpe</li>
</ul>
</li>
<li>Marcin Chechłacz &lt;<a class="reference external" href="mailto:marcin.chechlacz&#64;braintec.com">marcin.chechlacz&#64;braintec.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
Expand All @@ -453,13 +455,15 @@ <h2><a class="toc-backref" href="#toc-entry-7">Other credits</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/yajo"><img alt="yajo" src="https://github.com/yajo.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/anddago78"><img alt="anddago78" src="https://github.com/anddago78.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/project/tree/17.0/project_sequence">OCA/project</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/project/tree/18.0/project_sequence">OCA/project</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
23 changes: 12 additions & 11 deletions project_sequence/tests/test_project_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from psycopg2 import IntegrityError

from odoo import fields
from odoo.tests.common import Form, TransactionCase, new_test_user, users
from odoo.tests import Form
from odoo.tests.common import TransactionCase, new_test_user, users
from odoo.tools import mute_logger


Expand Down Expand Up @@ -52,39 +53,39 @@ def test_sequence_after_creation(self):
def test_analytic_account_after_creation_no_name(self):
"""Project's analytic account is named like project's default name."""
proj = self.env["project.project"].create(
{"analytic_account_id": self.analytic_account.id}
{"account_id": self.analytic_account.id}
)
self.assertEqual(proj.sequence_code, "23-00011")
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.account_id.name, "23-00011")

def test_analytic_account_after_creation_named(self):
"""Project's analytic account is named like project's display name."""
proj = self.env["project.project"].create(
{"name": "whatever", "analytic_account_id": self.analytic_account.id}
{"name": "whatever", "account_id": self.analytic_account.id}
)
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.account_id.name, "23-00011 - whatever")

@users("manager")
def test_sequence_copied_to_name_if_emptied(self):
"""Sequence is copied to project name if user removes it."""
proj = self.env["project.project"].create(
{"name": "whatever", "analytic_account_id": self.analytic_account.id}
{"name": "whatever", "account_id": self.analytic_account.id}
)
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.account_id.name, "23-00011 - whatever")
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.account_id.name, "23-00011")

@users("manager")
def test_sequence_not_copied_to_another_project(self):
Expand Down Expand Up @@ -153,12 +154,12 @@ def test_sync_analytic_account_name(self):
"write_date": fields.Datetime.now(),
}
)
proj.analytic_account_id = analytic_account
proj.account_id = analytic_account
proj._sync_analytic_account_name()
self.assertEqual(proj.analytic_account_id.name, proj.display_name)
self.assertEqual(proj.account_id.name, proj.display_name)

# Test when analytic_account_id is not set
proj.analytic_account_id = False
proj.account_id = False
proj._sync_analytic_account_name()
self.assertTrue(True) # Placeholder assertion to ensure the code execution

Expand Down
4 changes: 2 additions & 2 deletions project_sequence/views/project_project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
<field name="name" />
</xpath>
<xpath
expr="//span[t[@t-esc='record.display_name.value']]"
expr="//span[@t-att-title='record.display_name.value']"
position="attributes"
>
<attribute name="invisible">1</attribute>
</xpath>
<xpath
expr="//span[t[@t-esc='record.display_name.value']]"
expr="//span[@t-att-title='record.display_name.value']"
position="after"
>
<span>
Expand Down

0 comments on commit caebc6c

Please sign in to comment.