Skip to content

Commit

Permalink
[FIX] purchase: finish migration
Browse files Browse the repository at this point in the history
  • Loading branch information
MiquelRForgeFlow committed Jan 11, 2023
1 parent be4f90e commit c1414a7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
14 changes: 14 additions & 0 deletions openupgrade_scripts/scripts/purchase/15.0.1.2/end-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
all_purchase_order_lines = env["purchase.order.line"].search(
[
("product_packaging_id", "!=", False),
("state", "in", ["draft", "sent", "to approve"]),
]
)
for line in all_purchase_order_lines:
line._onchange_suggest_packaging()
line._onchange_update_product_packaging_qty()
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

@openupgrade.migrate()
def migrate(env, version):
openupgrade.convert_field_to_html(
env.cr,
"purchase_order",
openupgrade.get_legacy_name("notes"),
"notes",
verbose=False,
)
openupgrade.load_data(env.cr, "purchase", "15.0.1.2/noupdate_changes.xml")
openupgrade.delete_record_translations(
env.cr,
Expand All @@ -13,4 +20,3 @@ def migrate(env, version):
"email_template_edi_purchase_reminder",
],
)
openupgrade.convert_field_to_html(env.cr, "purchase_order", "notes", "notes")
21 changes: 21 additions & 0 deletions openupgrade_scripts/scripts/purchase/15.0.1.2/pre-migration.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
from openupgradelib import openupgrade

_columns_copy = {
"purchase_order": [
("notes", None, None),
],
}


@openupgrade.migrate()
def migrate(env, version):
openupgrade.copy_columns(env.cr, _columns_copy)
openupgrade.set_xml_ids_noupdate_value(
env,
"purchase",
Expand All @@ -12,3 +19,17 @@ def migrate(env, version):
],
True,
)
openupgrade.add_fields(
env,
[
(
"purchase",
"product.packaging",
"product_packaging",
"boolean",
"bool",
"purchase",
True,
)
],
)
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---Models in module 'purchase'---
---Fields in module 'purchase'---
purchase / product.packaging / purchase (boolean) : NEW hasdefault
# NOTHING TO DO: new feature
# DONE: pre-migration: fast filled with True value

purchase / purchase.order / notes (text) : type is now 'html' ('text')
# DONE: pre-migration: convert plaintext to html
# DONE: post-migration: convert plaintext to html

purchase / purchase.order.line / product_packaging_id (many2one): NEW relation: product.packaging
purchase / purchase.order.line / product_packaging_qty (float) : NEW
# NOTHING TO DO: new feature
# DONE: end-migration: filled product_packaging_id

---XML records in module 'purchase'---
NEW ir.actions.act_window: purchase.action_accrued_expense_entry
Expand Down

0 comments on commit c1414a7

Please sign in to comment.