-
-
Notifications
You must be signed in to change notification settings - Fork 696
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
360c08c
commit 5113f75
Showing
3 changed files
with
121 additions
and
1 deletion.
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
96 changes: 96 additions & 0 deletions
96
openupgrade_scripts/scripts/purchase_stock/16.0.1.2/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,96 @@ | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def _update_purchase_order_receipt_status(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE purchase_order | ||
ADD COLUMN IF NOT EXISTS receipt_status character varying | ||
""", | ||
) | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE purchase_order as po | ||
SET receipt_status = | ||
CASE | ||
WHEN | ||
( | ||
SELECT COUNT(*) | ||
FROM stock_picking AS sp | ||
JOIN purchase_order_stock_picking_rel AS rel | ||
ON rel.stock_picking_id = sp.id | ||
WHERE rel.purchase_order_id = po.id) = 0 | ||
OR | ||
( | ||
SELECT COUNT(*) | ||
FROM stock_picking AS sp | ||
JOIN purchase_order_stock_picking_rel AS rel | ||
ON rel.stock_picking_id = sp.id | ||
WHERE rel.purchase_order_id = po.id AND sp.state = 'cancel' | ||
) = ( | ||
SELECT COUNT(*) | ||
FROM stock_picking AS sp | ||
JOIN purchase_order_stock_picking_rel AS rel | ||
ON rel.stock_picking_id = sp.id | ||
WHERE rel.purchase_order_id = po.id | ||
) THEN NULL | ||
WHEN | ||
( | ||
SELECT COUNT(*) | ||
FROM stock_picking AS sp | ||
JOIN purchase_order_stock_picking_rel AS rel | ||
ON rel.stock_picking_id = sp.id | ||
WHERE rel.purchase_order_id = po.id AND sp.state IN ('done', 'cancel') | ||
) = ( | ||
SELECT COUNT(*) | ||
FROM stock_picking AS sp | ||
JOIN purchase_order_stock_picking_rel AS rel | ||
ON rel.stock_picking_id = sp.id | ||
WHERE rel.purchase_order_id = po.id | ||
) THEN 'full' | ||
WHEN | ||
( | ||
SELECT COUNT(*) | ||
FROM stock_picking AS sp | ||
JOIN purchase_order_stock_picking_rel AS rel | ||
ON rel.stock_picking_id = sp.id | ||
WHERE rel.purchase_order_id = po.id AND sp.state = 'done' | ||
) > 0 THEN 'partial' | ||
ELSE 'pending' | ||
END | ||
""", | ||
) | ||
|
||
|
||
def _update_purchase_order_dest_address_id(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE purchase_order | ||
ADD COLUMN IF NOT EXISTS dest_address_id integer | ||
""", | ||
) | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE purchase_order AS po | ||
SET dest_address_id = FALSE | ||
FROM stock_picking_type AS spt | ||
JOIN stock_location AS sl | ||
ON spt.default_location_dest_id = sl.id | ||
WHERE po.picking_type_id = spt.id AND sl.usage != 'customer' | ||
""", | ||
) | ||
|
||
|
||
def migrate(env, version): | ||
openupgrade.delete_records_safely_by_xml_id( | ||
env, | ||
[ | ||
"purchase_stock.route_warehouse0_buy", | ||
], | ||
) | ||
_update_purchase_order_receipt_status(env) | ||
_update_purchase_order_dest_address_id(env) |
24 changes: 24 additions & 0 deletions
24
openupgrade_scripts/scripts/purchase_stock/16.0.1.2/upgrade_analysis_work.txt
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,24 @@ | ||
'---Models in module 'purchase_stock'--- | ||
---Fields in module 'purchase_stock'--- | ||
purchase_stock / purchase.order / dest_address_id (False) : NEW mode: modify, hasdefault: compute | ||
# DONE: pre-migration: create column and fill values | ||
|
||
purchase_stock / purchase.order / incoterm_location (char) : NEW | ||
# NOTHING TO DO | ||
|
||
purchase_stock / purchase.order / receipt_status (selection) : NEW selection_keys: ['full', 'partial', 'pending'], isfunction: function, stored | ||
# DONE: pre-migration: create column and fill values | ||
purchase_stock / stock.warehouse.orderpoint / purchase_visibility_days (float): NEW hasdefault: default | ||
# NOTHING TO DO | ||
|
||
---XML records in module 'purchase_stock'--- | ||
NEW ir.ui.view: purchase_stock.purchase_order_view_tree_inherit | ||
DEL ir.ui.view: purchase_stock.product_category_view_form | ||
# NOTHING TO DO: noupdate="0" records | ||
|
||
DEL stock.location.route: purchase_stock.route_warehouse0_buy (noupdate) | ||
# DONE: pre-migration: delete record noupdate="1" | ||
|
||
NEW stock.route: purchase_stock.route_warehouse0_buy (noupdate) | ||
# NOTHING TO DO | ||
|