Skip to content

Commit

Permalink
Merge PR #4756 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 21, 2025
2 parents 4970fb5 + 36d3d83 commit 3c18643
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo)
# Copyright 2025 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openupgradelib import openupgrade


def _fill_incoterm_location(env):
# Fill incoterm_location according
# https://github.com/odoo/odoo/blob/e73db7e5aa2603e3b7eff20cd630b13f8c215424/
# addons/purchase_stock/models/account_invoice.py#L161-L169
openupgrade.logged_query(
env.cr,
"""
WITH sub AS (
SELECT
MAX(COALESCE(po.incoterm_location, '')) as incoterm_location,
am.id as move_id
FROM purchase_order po
JOIN purchase_order_line pol ON pol.order_id = po.id
JOIN account_move_line aml ON aml.purchase_line_id = pol.id
JOIN account_move am ON aml.move_id = am.id
GROUP BY am.id
)
UPDATE account_move am
SET incoterm_location = sub.incoterm_location
FROM sub
WHERE sub.move_id = am.id
""",
)


def _purchase_stock_convert_created_purchase_line_id_m2o_to_m2m(env):
"""
Convert m2o to m2m in 'purchase.stock'
Expand All @@ -19,4 +45,5 @@ def _purchase_stock_convert_created_purchase_line_id_m2o_to_m2m(env):

@openupgrade.migrate()
def migrate(env, version):
_fill_incoterm_location(env)
_purchase_stock_convert_created_purchase_line_id_m2o_to_m2m(env)

0 comments on commit 3c18643

Please sign in to comment.