-
-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4383 from Tecnativa/16.0-ou_imp-delivery-carrier_…
…name [16.0][OU-IMP] delivery: Quick carrier_name population
- Loading branch information
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
openupgrade_scripts/scripts/delivery/16.0.1.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,27 @@ | ||
# SPDX-FileCopyrightText: 2024 Tecnativa - Pedro M. Baeza | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def _precreate_stock_move_line_carrier_name(env): | ||
"""It seems Odoo doesn't handle with a SQL related fields with more than one path | ||
(several dots), so let's do it here for optimizing times. | ||
""" | ||
openupgrade.logged_query( | ||
env.cr, "ALTER TABLE stock_move_line ADD carrier_name VARCHAR" | ||
) | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE stock_move_line sml | ||
SET carrier_name = dc.name | ||
FROM stock_picking sp | ||
JOIN delivery_carrier dc ON dc.id = sp.carrier_id | ||
WHERE sml.picking_id = sp.id | ||
""", | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
_precreate_stock_move_line_carrier_name(env) |
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