Skip to content

Commit

Permalink
Merge PR OCA#4749 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by MiquelRForgeFlow
  • Loading branch information
OCA-git-bot committed Feb 20, 2025
2 parents b9f9bf8 + 7acdc31 commit 9d90a5c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docsource/modules160-170.rst
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ Module coverage 16.0 -> 17.0
+---------------------------------------------------+----------------------+-------------------------------------------------+
| sale_sms | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| sale_stock | Nothing to do | |
| sale_stock | Done | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| sale_stock_margin | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
33 changes: 33 additions & 0 deletions openupgrade_scripts/scripts/sale_stock/17.0.1.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2025 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
# Fill delivery_date and incoterm_location according
# https://github.com/odoo/odoo/blob/00818b7bfaf22635b0c40b3b9c7e37e0c9789da1/
# addons/sale_stock/models/account_move.py#L116-L134
openupgrade.logged_query(
env.cr,
"""
WITH sub AS (
SELECT
MAX(so.effective_date) as effective_date,
MAX(COALESCE(so.incoterm_location, '')) as incoterm_location,
am.id as move_id
FROM sale_order so
JOIN sale_order_line sol ON sol.order_id = so.id
JOIN sale_order_line_invoice_rel rel ON rel.order_line_id = sol.id
JOIN account_move_line aml ON rel.invoice_line_id = aml.id
JOIN account_move am ON aml.move_id = am.id
GROUP BY am.id
)
UPDATE account_move am
SET delivery_date = sub.effective_date,
incoterm_location = sub.incoterm_location
FROM sub
WHERE sub.move_id = am.id
""",
)

0 comments on commit 9d90a5c

Please sign in to comment.