Skip to content

Commit

Permalink
Merge PR #611 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Aug 19, 2024
2 parents 7e7873e + fe139b9 commit d130dad
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion helpdesk_mgmt_project/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Helpdesk Project",
"summary": "Add the option to select project in the tickets.",
"version": "16.0.2.1.0",
"version": "16.0.2.2.0",
"license": "AGPL-3",
"category": "After-Sales",
"author": "PuntSistemes S.L.U., " "Odoo Community Association (OCA)",
Expand Down
20 changes: 20 additions & 0 deletions helpdesk_mgmt_project/migrations/16.0.2.2.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
"""Set the default_project_id value in the project company."""
env.cr.execute(
"""
SELECT htt.id, htt.old_default_project_id, pp.company_id
FROM helpdesk_ticket_team htt
JOIN project_project pp ON htt.old_default_project_id = pp.id
WHERE htt.old_default_project_id IS NOT NULL
"""
)
for team_id, old_default_project_id, company_id in env.cr.fetchall():
team = env["helpdesk.ticket.team"].with_company(company_id).browse(team_id)
team.write({"default_project_id": old_default_project_id})
14 changes: 14 additions & 0 deletions helpdesk_mgmt_project/migrations/16.0.2.2.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade

column_renames = {
"helpdesk_ticket_team": [("default_project_id", "old_default_project_id")],
}


@openupgrade.migrate()
def migrate(env, version):
"""Rename the column to keep the old value."""
openupgrade.rename_columns(env.cr, column_renames)
5 changes: 4 additions & 1 deletion helpdesk_mgmt_project/models/helpdesk_ticket_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ class HelpdeskTeam(models.Model):
_inherit = "helpdesk.ticket.team"

default_project_id = fields.Many2one(
"project.project", string="Project", readonly=False
comodel_name="project.project",
string="Project",
readonly=False,
company_dependent=True,
)

0 comments on commit d130dad

Please sign in to comment.