Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ addon | version | maintainers | summary
[project_task_parent_due_auto](project_task_parent_due_auto/) | 16.0.1.0.1 | <a href='https://github.com/david-banon-tecnativa'><img src='https://github.com/david-banon-tecnativa.png' width='32' height='32' style='border-radius:50%;' alt='david-banon-tecnativa'/></a> | Recalculates parent task's due date when child task changes
[project_task_personal_stage_auto_fold](project_task_personal_stage_auto_fold/) | 16.0.1.0.0 | | Moves task to the first fold personal stage when done
[project_task_project_required](project_task_project_required/) | 16.0.1.0.0 | | Set project on task as a mandatory field
[project_task_pull_request](project_task_pull_request/) | 16.0.1.0.0 | | Adds a field for a PR URI to project tasks
[project_task_pull_request](project_task_pull_request/) | 16.0.1.1.0 | | Adds a field for a PR URI to project tasks
[project_task_pull_request_state](project_task_pull_request_state/) | 16.0.1.0.0 | | Track Pull Request state in tasks
[project_task_recurring_activity](project_task_recurring_activity/) | 16.0.1.0.0 | <a href='https://github.com/dessanhemrayev'><img src='https://github.com/dessanhemrayev.png' width='32' height='32' style='border-radius:50%;' alt='dessanhemrayev'/></a> <a href='https://github.com/CetmixGitDrone'><img src='https://github.com/CetmixGitDrone.png' width='32' height='32' style='border-radius:50%;' alt='CetmixGitDrone'/></a> | Project Task Recurring Activity
[project_task_stage_change_restriction](project_task_stage_change_restriction/) | 16.0.1.0.0 | | Restrict project task stage
Expand Down
22 changes: 12 additions & 10 deletions project_sequence/models/project_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ class ProjectProject(models.Model):
required=False,
)

def _sync_analytic_account_name(self):
"""Set analytic account name equal to project's display name."""
def _sync_analytic_account(self):
"""Set analytic account name & code equal to project's name & sequence"""
for rec in self:
if not rec.analytic_account_id:
continue
rec.analytic_account_id.name = rec.display_name
if rec.analytic_account_id:
rec.analytic_account_id.write(
{
"name": rec.name,
"code": rec.sequence_code,
}
)

def name_get(self):
"""Prefix name with sequence code if they are different."""
Expand Down Expand Up @@ -72,16 +76,14 @@ def create(self, vals_list):
# It is important to set sequence_code before calling super() because
# other modules such as hr_timesheet expect the name to always have a value
for vals in vals_list:
if not vals.get("sequence_code", False):
if "sequence_code" not in vals:
vals["sequence_code"] = self.env["ir.sequence"].next_by_code(
"project.sequence"
)
if not vals.get("name"):
vals["name"] = vals["sequence_code"]
res = super().create(vals_list)
# The analytic account is created with just the project name, but
# it is more useful to let it contain the project sequence too
res._sync_analytic_account_name()
res._sync_analytic_account()
return res

def write(self, vals):
Expand All @@ -94,5 +96,5 @@ def write(self, vals):
sequence_code = vals.get("sequence_code", one.sequence_code)
name = vals.get("name") or sequence_code
super().write(dict(vals, name=name))
self._sync_analytic_account_name()
self._sync_analytic_account()
return True
68 changes: 16 additions & 52 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.company.analytic_plan_id
Copy link
Copy Markdown
Member

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!

cls.analytic_account = cls.env["account.analytic.account"].create(
{
"name": "aaa",
Expand Down Expand Up @@ -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."""
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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")

Comment thread
yajo marked this conversation as resolved.
def test_custom_pattern(self):
"""Display name pattern can be customized."""
self.env["ir.config_parameter"].set_param(
Expand All @@ -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,
Expand All @@ -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()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method now syncs both name and code, but this test only asserts name. Consider adding:

self.assertEqual(proj.analytic_account_id.code, proj.sequence_code)

The other test methods (test_analytic_account_after_creation_named, test_sequence_copied_to_name_if_emptied) already verify both fields.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): Since _sync_analytic_account() now writes both name and code, consider adding:

self.assertEqual(proj.analytic_account_id.code, proj.sequence_code)

The other test methods (test_analytic_account_after_creation_named, test_sequence_copied_to_name_if_emptied) already verify both fields -- this would keep coverage consistent.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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):
Expand Down
8 changes: 6 additions & 2 deletions project_task_pull_request/README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=========================
Project Task Pull Request
=========================
Expand All @@ -7,13 +11,13 @@ Project Task Pull Request
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:8571ef2dc90d493ebc070e652c90164379e98c3554cb2548de56232b46769014
!! source digest: sha256:fa52e56d7d384619d9e9d1358c4e400decb5c85659968e94294954338cc04e02
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github
Expand Down
2 changes: 1 addition & 1 deletion project_task_pull_request/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Project Task Pull Request",
"summary": "Adds a field for a PR URI to project tasks",
"version": "16.0.1.0.0",
"version": "16.0.1.1.0",
"category": "Project Management",
"website": "https://github.com/OCA/project",
"author": "SMDrugstore, " "Tecnativa, " "Odoo Community Association (OCA)",
Expand Down
5 changes: 5 additions & 0 deletions project_task_pull_request/i18n/ar.po
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ msgstr ""
msgid "Project"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.view_task_form2
msgid "Pull Request"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.edit_project
msgid "Pull Request URIs"
Expand Down
5 changes: 5 additions & 0 deletions project_task_pull_request/i18n/ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ msgstr ""
msgid "Project"
msgstr "Projecte"

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.view_task_form2
msgid "Pull Request"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.edit_project
msgid "Pull Request URIs"
Expand Down
5 changes: 5 additions & 0 deletions project_task_pull_request/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ msgstr ""
msgid "Project"
msgstr "Projekt"

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.view_task_form2
msgid "Pull Request"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.edit_project
msgid "Pull Request URIs"
Expand Down
5 changes: 5 additions & 0 deletions project_task_pull_request/i18n/el.po
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ msgstr ""
msgid "Project"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.view_task_form2
msgid "Pull Request"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.edit_project
msgid "Pull Request URIs"
Expand Down
5 changes: 5 additions & 0 deletions project_task_pull_request/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ msgstr ""
msgid "Project"
msgstr "Proyecto"

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.view_task_form2
msgid "Pull Request"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.edit_project
msgid "Pull Request URIs"
Expand Down
5 changes: 5 additions & 0 deletions project_task_pull_request/i18n/es_AR.po
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ msgstr ""
msgid "Project"
msgstr "Proyecto"

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.view_task_form2
msgid "Pull Request"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.edit_project
msgid "Pull Request URIs"
Expand Down
5 changes: 5 additions & 0 deletions project_task_pull_request/i18n/es_CR.po
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ msgstr ""
msgid "Project"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.view_task_form2
msgid "Pull Request"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.edit_project
msgid "Pull Request URIs"
Expand Down
5 changes: 5 additions & 0 deletions project_task_pull_request/i18n/es_MX.po
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ msgstr ""
msgid "Project"
msgstr "Proyecto"

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.view_task_form2
msgid "Pull Request"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.edit_project
msgid "Pull Request URIs"
Expand Down
5 changes: 5 additions & 0 deletions project_task_pull_request/i18n/es_VE.po
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ msgstr ""
msgid "Project"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.view_task_form2
msgid "Pull Request"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.edit_project
msgid "Pull Request URIs"
Expand Down
5 changes: 5 additions & 0 deletions project_task_pull_request/i18n/fi.po
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ msgstr ""
msgid "Project"
msgstr "Projekti"

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.view_task_form2
msgid "Pull Request"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.edit_project
msgid "Pull Request URIs"
Expand Down
5 changes: 5 additions & 0 deletions project_task_pull_request/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ msgstr ""
msgid "Project"
msgstr "Projet"

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.view_task_form2
msgid "Pull Request"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.edit_project
msgid "Pull Request URIs"
Expand Down
5 changes: 5 additions & 0 deletions project_task_pull_request/i18n/gl.po
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ msgstr ""
msgid "Project"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.view_task_form2
msgid "Pull Request"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.edit_project
msgid "Pull Request URIs"
Expand Down
9 changes: 7 additions & 2 deletions project_task_pull_request/i18n/hr.po
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"

#. module: project_task_pull_request
#: model:ir.model.fields,field_description:project_task_pull_request.field_project_project__pr_required_states
Expand All @@ -44,6 +44,11 @@ msgstr "Molimo dodajte URL zahtijevu prije prebacivanja zadatka u ovu fazu"
msgid "Project"
msgstr "Projekt"

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.view_task_form2
msgid "Pull Request"
msgstr ""

#. module: project_task_pull_request
#: model_terms:ir.ui.view,arch_db:project_task_pull_request.edit_project
msgid "Pull Request URIs"
Expand Down
Loading