-
-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] helpdesk_mgmt_project: Multi-company compatibility
Example of use case with helpdesk_mgmt_timesheet: - Create a team with no company defined. - Create a project A for company A. - Create a project B for company A. - [Company A] In the created team we define the project A. - [Company B] In the created team we define project B - [Company A] We create a ticket and assign the team, project A will be defined. - [Company B] We create a ticket and assign the team, project B will be defined. TT50251
- Loading branch information
1 parent
5c54bd0
commit d7c6620
Showing
4 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
helpdesk_mgmt_project/migrations/16.0.2.2.0/post-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 team.id, team.old_default_project_id, project.company_id | ||
FROM helpdesk_ticket_team AS team | ||
JOIN project_project AS project ON team.old_default_project_id = project.id | ||
WHERE team.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}) |
23 changes: 23 additions & 0 deletions
23
helpdesk_mgmt_project/migrations/16.0.2.2.0/pre-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# 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): | ||
"""Create a column with the old data and we fill it in.""" | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE helpdesk_ticket_team | ||
ADD COLUMN IF NOT EXISTS old_default_project_id INTEGER DEFAULT 0; | ||
""", | ||
) | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE helpdesk_ticket_team | ||
SET old_default_project_id = default_project_id | ||
""", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters