Skip to content
Open
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
4 changes: 2 additions & 2 deletions docsource/modules180-190.rst
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ Module coverage 18.0 -> 19.0
+---------------------------------------------------+----------------------+-------------------------------------------------+
| project_todo | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| purchase | | |
| purchase |Done | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| purchase_edi_ubl_bis3 | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
Expand All @@ -972,7 +972,7 @@ Module coverage 18.0 -> 19.0
+---------------------------------------------------+----------------------+-------------------------------------------------+
| purchase_requisition_stock | |No DB layout changes. |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| purchase_stock | | |
| purchase_stock |Done | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| rating | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
49 changes: 49 additions & 0 deletions openupgrade_scripts/scripts/purchase/19.0.1.2/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2026 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade


def purchase_order_fields(env):
"""
Set state = purchase for orders with state == 'done'
Set locked = true for orders in state purchase if their company is configured
accordingly
Set acknowledged=True for orders in state purchase to avoid unexpected reminder
mails
"""
env.cr.execute("UPDATE purchase_order SET state='purchase' WHERE state='done'")
env.cr.execute("UPDATE purchase_order SET acknowledged=True WHERE state='purchase'")
env.cr.execute(
"""
UPDATE purchase_order SET locked=TRUE
FROM res_company
WHERE
purchase_order.company_id=res_company.id
AND res_company.po_lock='lock'
"""
)


def purchase_order_line_technical_price_unit(env):
"""
Initialized technical_price_unit with price_unit
"""
env.cr.execute("UPDATE purchase_order_line SET technical_price_unit=price_unit")


@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(env, "purchase", "19.0.1.2/noupdate_changes.xml")
openupgrade.delete_record_translations(
env.cr,
"purchase",
[
"email_template_edi_purchase",
"email_template_edi_purchase_done",
"email_template_edi_purchase_reminder",
],
["body_html"],
)
purchase_order_fields(env)
purchase_order_line_technical_price_unit(env)
28 changes: 28 additions & 0 deletions openupgrade_scripts/scripts/purchase/19.0.1.2/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2026 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade

renamed_fields = [
("purchase.order", "purchase_order", "note", "notes"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
("purchase.order", "purchase_order", "note", "notes"),
("purchase.order", "purchase_order", "notes", "note"),

("purchase.order.line", "purchase_order_line", "product_uom", "product_uom_id"),
("purchase.order.line", "purchase_order_line", "taxes_id", "tax_ids"),
]

added_fields = [
("locked", "purchase.order", "purchase_order", "boolean", None, "purchase", False),
(
"technical_price_unit",
"purchase.order.line",
"purchase_order_line",
"float",
None,
"purchase",
),
]


@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_fields(env, renamed_fields)
openupgrade.add_fields(env, added_fields)
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---Models in module 'purchase'---
---Fields in module 'purchase'---
purchase / product.packaging / purchase (boolean) : DEL
purchase / product.template / purchase_line_warn (selection): DEL required, selection_keys: ['block', 'no-message', 'warning']

# NOTHING TO DO

purchase / purchase.order / acknowledged (boolean) : NEW

# DONE: set to True for state == purchase

purchase / purchase.order / is_late (boolean) : NEW stored: False

# NOTHING TO DO

purchase / purchase.order / locked (boolean) : NEW hasdefault: default

# DONE: precreated in pre-migration, set in post-migration

purchase / purchase.order / mail_reception_confirmed (boolean): DEL
purchase / purchase.order / mail_reception_declined (boolean): DEL
purchase / purchase.order / mail_reminder_confirmed (boolean): DEL

# NOTHING TO DO

purchase / purchase.order / note (html) : NEW
purchase / purchase.order / notes (html) : DEL

# DONE: renamed in pre-migration

purchase / purchase.order / receipt_reminder_email (boolean): is now stored
purchase / purchase.order / receipt_reminder_email (boolean): not a function anymore
purchase / purchase.order / reminder_date_before_receipt (integer): is now stored
purchase / purchase.order / reminder_date_before_receipt (integer): not a function anymore

# NOTHING TO DO: will be recomputed by the ORM

purchase / purchase.order / state (selection) : selection_keys removed: [done]

# DONE: mapped done to purchase

purchase / purchase.order.line / currency_id (many2one) : not stored anymore
purchase / purchase.order.line / display_type (selection) : selection_keys added: [line_subsection] (most likely nothing to do)
purchase / purchase.order.line / product_packaging_id (many2one): DEL relation: product.packaging
purchase / purchase.order.line / product_packaging_qty (float) : DEL

# NOTHING TO DO

purchase / purchase.order.line / product_uom (many2one) : DEL relation: uom.uom
purchase / purchase.order.line / product_uom_id (many2one) : NEW relation: uom.uom

# DONE: renamed in pre-migration

purchase / purchase.order.line / state (selection) : not stored anymore

# NOTHING TO DO

purchase / purchase.order.line / tax_ids (many2many) : NEW relation: account.tax
purchase / purchase.order.line / taxes_id (many2many) : DEL relation: account.tax

# DONE: renamed in pre-migration

purchase / purchase.order.line / technical_price_unit (float) : NEW

# DONE: precreated and set to price_unit

purchase / res.company / po_lead (float) : DEL required
purchase / res.partner / purchase_warn (selection) : DEL selection_keys: ['block', 'no-message', 'warning']

# NOTHING TO DO

---XML records in module 'purchase'---
NEW ir.actions.act_window: purchase.mail_followers_edit_action_from_purchase
DEL ir.actions.server: purchase.action_purchase_batch_bills
DEL ir.model.access: purchase.access_product_category_purchase_manager
DEL ir.model.access: purchase.access_product_packaging_purchase_manager
DEL ir.model.access: purchase.access_product_product_purchase_manager
DEL ir.model.access: purchase.access_product_tag_purchase_manager
DEL ir.model.access: purchase.access_product_template_purchase_manager
DEL ir.model.access: purchase.access_uom_category_purchase_manager
DEL ir.model.access: purchase.access_uom_uom_purchase_manager
ir.model.constraint: purchase.constraint_purchase_order_line_accountable_required_fields (changed definition: is now 'CHECK(display_type IS NOT NULL OR is_downpayment OR (product_id IS NOT NULL AND product_uom_id IS NOT NULL AND date_planned IS NOT NULL))' ('check(display_type is not null or is_downpayment or(product_id is not null and product_uom is not null and date_planned is not null))'))
ir.model.constraint: purchase.constraint_purchase_order_line_non_accountable_null_fields (changed definition: is now 'CHECK(display_type IS NULL OR (product_id IS NULL AND price_unit = 0 AND product_uom_qty = 0 AND product_uom_id IS NULL AND date_planned is NULL))' ('check(display_type is null or(product_id is null and price_unit = 0 and product_uom_qty = 0 and product_uom is null and date_planned is null))'))
DEL ir.ui.menu: purchase.menu_purchase_uom_categ_form_action
DEL ir.ui.menu: purchase.menu_unit_of_measure_in_config_purchase
DEL ir.ui.view: purchase.product_packaging_form_view_purchase
DEL ir.ui.view: purchase.product_packaging_tree_view_purchase
DEL ir.ui.view: purchase.purchase_partner_kanban_view
DEL ir.ui.view: purchase.res_partner_view_purchase_account_buttons

# NOTHING TO DO

DEL mail.message.subtype: purchase.mt_rfq_done (noupdate)

# NOTHING TO DO: don't delete subtypes because then messages end up without one

NEW res.groups.privilege: purchase.res_groups_privilege_purchase

# NOTHING TO DO
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2026 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(env, "purchase_stock", "19.0.1.2/noupdate_changes.xml")
openupgrade.m2o_to_x2m(
Comment on lines +9 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you change the order of calling these methods?

env.cr,
env["purchase.order"],
"purchase_order",
"reference_ids",
"group_id",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---Models in module 'purchase_stock'---
---Fields in module 'purchase_stock'---
purchase_stock / procurement.group / purchase_line_ids (one2many) : DEL relation: purchase.order.line
purchase_stock / product.category / property_account_creditor_price_difference_categ (many2one): DEL relation: account.account
purchase_stock / product.template / property_account_creditor_price_difference (many2one): DEL relation: account.account
purchase_stock / product.template / route_ids (False) : DEL mode: modify

# NOTHING TO DO

purchase_stock / purchase.order / group_id (many2one) : DEL relation: procurement.group
purchase_stock / purchase.order / reference_ids (many2many) : NEW relation: stock.reference

# DONE: filled from group_id

purchase_stock / purchase.order.line / group_id (many2one) : DEL relation: procurement.group
purchase_stock / res.partner / group_on (selection) : NEW required, selection_keys: ['1', '2', '3', '4', '5', '6', '7', 'default'], hasdefault: default
purchase_stock / res.partner / group_rfq (selection) : NEW required, selection_keys: ['all', 'day', 'default', 'week'], hasdefault: default
purchase_stock / res.partner / suggest_based_on (char) : NEW hasdefault: default
purchase_stock / res.partner / suggest_days (integer) : NEW hasdefault: default
purchase_stock / res.partner / suggest_percent (integer) : NEW hasdefault: default
purchase_stock / stock.reference / purchase_ids (many2many) : NEW relation: purchase.order
purchase_stock / stock.warehouse / buy_to_resupply (boolean) : not stored anymore
purchase_stock / stock.warehouse / buy_to_resupply (boolean) : now a function
purchase_stock / stock.warehouse.orderpoint / available_vendor (many2one) : NEW relation: res.partner, stored: False
purchase_stock / stock.warehouse.orderpoint / product_supplier_id (many2one): DEL relation: res.partner
purchase_stock / stock.warehouse.orderpoint / purchase_visibility_days (float): DEL
purchase_stock / stock.warehouse.orderpoint / vendor_id (many2one) : DEL relation: res.partner
---XML records in module 'purchase_stock'---
NEW ir.ui.view: purchase_stock.product_view_search_catalog
NEW ir.ui.view: purchase_stock.stock_reference_purchase_view_form
DEL ir.ui.view: purchase_stock.product_template_form_view
DEL ir.ui.view: purchase_stock.stock_reorder_report_search_inherited_purchase_stock
DEL ir.ui.view: purchase_stock.view_category_property_form

# NOTHING TO DO
Loading