-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] resource_booking: Add multiples requesters in booking
- Loading branch information
1 parent
8d6f440
commit 1a645fe
Showing
13 changed files
with
151 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2023 Tecnativa - Carolina Fernandez | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from psycopg2.extensions import AsIs | ||
|
||
from odoo import SUPERUSER_ID, api | ||
|
||
|
||
def migrate(cr, version): | ||
"""Put partner_id in partner_ids""" | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
m2m_table = env["resource.booking"]._fields["partner_ids"].relation | ||
column1 = env["resource.booking"]._fields["partner_ids"].column1 | ||
column2 = env["resource.booking"]._fields["partner_ids"].column2 | ||
cr.execute( | ||
"SELECT rb.id FROM resource_booking rb " | ||
"INNER JOIN %s rel ON rel.%s = rb.migrated_partner_id"( | ||
AsIs(m2m_table), AsIs(column2) | ||
) | ||
) | ||
exclude_ids = [x[0] for x in cr.fetchall()] | ||
cr.execute( | ||
"INSERT INTO %s " | ||
"(%s, %s) " | ||
"VALUES " | ||
"SELECT id, migrated_partner_id FROM %s", | ||
"WHERE id NOT IN %s"( | ||
AsIs(m2m_table), | ||
AsIs(column1), | ||
AsIs(column2), | ||
AsIs(env["resource.booking"]._table), | ||
tuple(exclude_ids), | ||
), | ||
) |
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,10 @@ | ||
# Copyright 2023 Tecnativa - Carolina Fernandez | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
|
||
def migrate(env): | ||
env.cr.execute( | ||
""" | ||
ALTER TABLE resource_booking RENAME partner_id TO migrated_partner_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
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
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
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
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
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
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
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
Oops, something went wrong.