Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP] helpdesk_mgmt_project: Multi-company compatibility #611

Merged
Merged
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 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,
)
Loading