-
-
Notifications
You must be signed in to change notification settings - Fork 698
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
Showing
3 changed files
with
74 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
57 changes: 57 additions & 0 deletions
57
openupgrade_scripts/scripts/sale_stock/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,57 @@ | ||
# Copyright 2023 Coop IT Easy SC | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
|
||
def compute_sale_order_delivery_status(env): | ||
openupgrade.add_fields( | ||
env, | ||
[ | ||
( | ||
"delivery_status", | ||
"sale.order", | ||
False, | ||
"selection", | ||
False, | ||
"sale_stock", | ||
) | ||
], | ||
) | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
with so_delivery_status as ( | ||
select | ||
sale_id as id, | ||
case | ||
when | ||
count(state) filter ( | ||
where state = 'cancel' | ||
) = count(state) | ||
then null | ||
when | ||
count(state) filter ( | ||
where state not in ('done', 'cancel') | ||
) = 0 | ||
then 'full' | ||
when | ||
count(state) filter (where state = 'done') > 0 | ||
then 'partial' | ||
else 'pending' | ||
end as delivery_status | ||
from stock_picking | ||
group by 1 | ||
order by 1 | ||
) | ||
update sale_order as so | ||
set delivery_status = so_delivery_status.delivery_status | ||
from so_delivery_status | ||
where so_delivery_status.id = so.id; | ||
""", | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
compute_sale_order_delivery_status(env) |
16 changes: 16 additions & 0 deletions
16
openupgrade_scripts/scripts/sale_stock/16.0.1.0/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,16 @@ | ||
---Models in module 'sale_stock'--- | ||
---Fields in module 'sale_stock'--- | ||
sale_stock / sale.order / delivery_status (selection) : NEW selection_keys: ['full', 'partial', 'pending'], isfunction: function, stored | ||
# DONE: pre-migration: fast computed delivery_status | ||
sale_stock / sale.order / incoterm_location (char) : NEW | ||
sale_stock / sale.order.line / product_type (selection) : module is now 'sale' ('sale_stock') | ||
sale_stock / sale.order.line / route_id (many2one) : relation is now 'stock.route' ('stock.location.route') [nothing to do] | ||
sale_stock / stock.location.route / sale_selectable (boolean) : DEL | ||
sale_stock / stock.route / sale_selectable (boolean) : NEW | ||
# NOTHING TO DO | ||
---XML records in module 'sale_stock'--- | ||
DEL ir.ui.menu: sale_stock.menu_aftersale | ||
DEL ir.ui.menu: sale_stock.menu_invoiced | ||
DEL ir.ui.view: sale_stock.product_template_view_form_inherit_sale | ||
DEL ir.ui.view: sale_stock.product_template_view_form_inherit_stock | ||
# NOTHING TO DO |