forked from OCA/sale-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] sale_order_secondary_unit: Add migration script to adapt secod …
…uom to variants TT45597
- Loading branch information
1 parent
1e10d30
commit 703ec24
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
sale_order_secondary_unit/migrations/15.0.2.0.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,17 @@ | ||
# Copyright 2023 Tecnativa - Sergio Teruel | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
# Set default sale secondary uom from template to variants | ||
sql = """ | ||
UPDATE product_product pp | ||
SET sale_secondary_uom_id = pt.sale_secondary_uom_id | ||
FROM product_template pt | ||
WHERE pt.id = pp.product_tmpl_id | ||
AND pt.sale_secondary_uom_id IS NOT NULL | ||
""" | ||
openupgrade.logged_query(env.cr, sql) |