Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][OU-ADD] sale_stock #4015

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
)
],
)
huguesdk marked this conversation as resolved.
Show resolved Hide resolved
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
pedrobaeza marked this conversation as resolved.
Show resolved Hide resolved
# 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