Skip to content

Commit

Permalink
[FIX] sale_stock: finish migration
Browse files Browse the repository at this point in the history
  • Loading branch information
MiquelRForgeFlow committed Mar 6, 2023
1 parent b99a8fc commit 8d12ffb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 52 deletions.
2 changes: 1 addition & 1 deletion docsource/modules140-150.rst
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ Module coverage 14.0 -> 15.0
+-------------------------------------------------+----------------------+-------------------------------------------------+
| |new| sale_sms | | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| sale_stock | | |
| sale_stock | Done | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| sale_stock_margin | | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
10 changes: 0 additions & 10 deletions openupgrade_scripts/scripts/sale_stock/15.0.1.0/end-migration.py

This file was deleted.

24 changes: 5 additions & 19 deletions openupgrade_scripts/scripts/sale_stock/15.0.1.0/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,12 @@


def date_to_datetime_fields(env):
# convert column from date to datetime
openupgrade.logged_query(
openupgrade.date_to_datetime_tz(
env.cr,
"""
ALTER TABLE sale_order ALTER COLUMN effective_date TYPE TIMESTAMP WITHOUT TIME ZONE
""",
)
openupgrade.logged_query(
env.cr,
"""
WITH subquery (sale_id, date_done) AS (
SELECT sale_id, MIN(date_done)
FROM stock_picking AS sp
WHERE date_done IS NOT NULL AND sale_id IS NOT NULL
GROUP BY sale_id
)
UPDATE sale_order so
SET effective_date = sub.date_done
FROM subquery sub
WHERE sub.sale_id = so.id""",
"sale_order",
"create_uid",
openupgrade.get_legacy_name("effective_date"),
"effective_date",
)


Expand Down
20 changes: 1 addition & 19 deletions openupgrade_scripts/scripts/sale_stock/15.0.1.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
from openupgradelib import openupgrade


def _rename_field_product_packaging_to_product_packaging_id(env):
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE sale_order_line
ADD COLUMN IF NOT EXISTS product_packaging_id integer
""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE sale_order_line
SET product_packaging_id = product_packaging
WHERE product_packaging IS NOT NULL
""",
)


@openupgrade.migrate()
def migrate(env, version):
_rename_field_product_packaging_to_product_packaging_id(env)
openupgrade.rename_columns(env.cr, {"sale_order": [("effective_date", None)]})
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
---Models in module 'sale_stock'---
---Fields in module 'sale_stock'---
sale_stock / sale.order / effective_date (date) : type is now 'datetime' ('date')
# DONE: post-migration: set effective_date = min(pickings.date_done)
# DONE: post-migration: turned into datetime

sale_stock / sale.order.line / product_packaging (many2one) : DEL relation: product.packaging
# DONE: pre-migration: rename to product_packaging_id, call _onchange_update_product_packaging_qty to compute product_packaging_qty
# NOTHING TO DO: handled in sale

---XML records in module 'sale_stock'---
NEW ir.model.access: sale_stock.access_stock_package_type_salesman
DEL ir.ui.view: sale_stock.sale_order_line_view_list
DEL ir.ui.view: sale_stock.sale_stock_report_invoice_document
DEL res.groups: sale_stock.group_lot_on_invoice [renamed to stock_account module]
# NOTHING TO DO

DEL res.groups: sale_stock.group_lot_on_invoice [renamed to stock_account module]
# NOTHING TO DO: handled in stock_account

0 comments on commit 8d12ffb

Please sign in to comment.