Skip to content

Commit

Permalink
Merge pull request #4383 from Tecnativa/16.0-ou_imp-delivery-carrier_…
Browse files Browse the repository at this point in the history
…name

[16.0][OU-IMP] delivery: Quick carrier_name population
  • Loading branch information
pedrobaeza authored Apr 6, 2024
2 parents 468b676 + 669534d commit 716e754
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions openupgrade_scripts/scripts/delivery/16.0.1.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: 2024 Tecnativa - Pedro M. Baeza
# SPDX-License-Identifier: AGPL-3.0-or-later
from openupgradelib import openupgrade


def _precreate_stock_move_line_carrier_name(env):
"""It seems Odoo doesn't handle with a SQL related fields with more than one path
(several dots), so let's do it here for optimizing times.
"""
openupgrade.logged_query(
env.cr, "ALTER TABLE stock_move_line ADD carrier_name VARCHAR"
)
openupgrade.logged_query(
env.cr,
"""
UPDATE stock_move_line sml
SET carrier_name = dc.name
FROM stock_picking sp
JOIN delivery_carrier dc ON dc.id = sp.carrier_id
WHERE sml.picking_id = sp.id
""",
)


@openupgrade.migrate()
def migrate(env, version):
_precreate_stock_move_line_carrier_name(env)
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ delivery / product.template / country_of_origin (many2one) : NEW re
# NOTHING TO DO: New field for Intrastat. May should be filled from OCA Intrastat modules

delivery / stock.move.line / carrier_name (char) : NEW isrelated: related, stored
# NOTHING TO DO: Related stored already handled in a fast way by ORM.
# DONE: pre-migration: Pre-create it and fast fill it, as ORM seems to not handle related fields with more than 1 path.

---XML records in module 'delivery'---
NEW ir.actions.act_window: delivery.action_delivery_zip_prefix_list
Expand Down

0 comments on commit 716e754

Please sign in to comment.