Skip to content

Commit

Permalink
Merge PR #2105 into 12.0
Browse files Browse the repository at this point in the history
Signed-off-by StefanRijnhart
  • Loading branch information
OCA-git-bot committed Dec 7, 2019
2 parents 8187780 + bc3b9ab commit 4155dfb
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions addons/stock/migrations/12.0.1.1/post-migration.py
Expand Up @@ -2,6 +2,7 @@
# Copyright 2019 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade, openupgrade_merge_records
from psycopg2 import sql
from psycopg2.extensions import AsIs


Expand Down Expand Up @@ -143,16 +144,29 @@ def fill_stock_package_level(env):

def merge_stock_putaway_product(cr):
if openupgrade.table_exists(cr, 'stock_product_putaway_strategy'):
openupgrade.logged_query(
cr, """
INSERT INTO stock_fixed_putaway_strat (product_id, putaway_id,
column_name = openupgrade.get_legacy_name('old_strat_id')
openupgrade.logged_query(cr, sql.SQL(
"""INSERT INTO stock_fixed_putaway_strat (product_id, putaway_id,
fixed_location_id, sequence,
create_uid, create_date, write_uid, write_date, %s)
create_uid, create_date, write_uid, write_date, {})
SELECT product_product_id, putaway_id, fixed_location_id, sequence,
create_uid, create_date, write_uid, write_date, id
FROM stock_product_putaway_strategy
""", (AsIs(openupgrade.get_legacy_name('old_strat_id')), ),
)
WHERE product_product_id IS NOT NULL"""
).format(sql.Identifier(column_name)))
# We put sequence + 1 for giving more priority by default to product
# specific rules
openupgrade.logged_query(cr, sql.SQL(
"""INSERT INTO stock_fixed_putaway_strat (product_id, putaway_id,
fixed_location_id, sequence,
create_uid, create_date, write_uid, write_date, {})
SELECT pp.id, spps.putaway_id, spps.fixed_location_id,
spps.sequence + 1, spps.create_uid, spps.create_date,
spps.write_uid, spps.write_date, spps.id
FROM stock_product_putaway_strategy spps
JOIN product_template pt ON pt.id = spps.product_tmpl_id
JOIN product_product pp ON pp.product_tmpl_id = pt.id"""
).format(sql.Identifier(column_name)))


@openupgrade.migrate()
Expand Down

0 comments on commit 4155dfb

Please sign in to comment.