Skip to content

Commit

Permalink
[OU-ADD] sale_stock
Browse files Browse the repository at this point in the history
  • Loading branch information
huguesdk committed Jul 7, 2023
1 parent 975bcfa commit 9ed1d0c
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docsource/modules150-160.rst
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ Module coverage 15.0 -> 16.0
+-------------------------------------------------+----------------------+-------------------------------------------------+
| sale_sms | | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| sale_stock | | |
| sale_stock | Done | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| sale_stock_margin | | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
57 changes: 57 additions & 0 deletions openupgrade_scripts/scripts/sale_stock/16.0.1.0/pre-migration.py
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)
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

0 comments on commit 9ed1d0c

Please sign in to comment.