Skip to content

Commit

Permalink
[OU-ADD] sale: migration
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangtiendung070797 committed Jul 7, 2023
1 parent 360c08c commit 37e9a76
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docsource/modules150-160.rst
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ Module coverage 15.0 -> 16.0
+-------------------------------------------------+----------------------+-------------------------------------------------+
| resource | Nothing to do | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| sale | | |
| sale | Done | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| |del| sale_coupon | | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
16 changes: 16 additions & 0 deletions openupgrade_scripts/scripts/sale/16.0.1.2/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from openupgradelib import openupgrade


def try_delete_noupdate_records(env):
openupgrade.delete_records_safely_by_xml_id(
env,
[
"sale.mail_notification_paynow_online",
],
)


@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(env.cr, "sale", "16.0.1.2/noupdate_changes.xml")
try_delete_noupdate_records(env)
56 changes: 56 additions & 0 deletions openupgrade_scripts/scripts/sale/16.0.1.2/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from openupgradelib import openupgrade

_models_renames = [
(
"sale.payment.acquirer.onboarding.wizard",
"sale.payment.provider.onboarding.wizard",
),
]

_renames_xmlids = [
(
"sale.sale_payment_provider_onboarding_wizard_rule",
"sale.sale_payment_acquirer_onboarding_wizard_rule",
),
(
"sale_management.menu_product_attribute_action",
"sale.menu_product_attribute_action",
),
]

_moved_fields = [
"product_type",
]


def _noupdate_switch(env):
openupgrade.set_xml_ids_noupdate_value(
env, "sale", ["model_sale_order_action_share"], False
)


def _remove_table_constraints(env):
openupgrade.delete_sql_constraint_safely(
env, "sale", "sale_order", "date_order_conditional_required"
)


@openupgrade.migrate()
def migrate(env, version):
openupgrade.add_xmlid(
env.cr,
"sale",
"default_invoice_email_template",
"ir.config_parameter",
env["ir.config_parameter"].search(
[("key", "=", "sale.default_invoice_email_template")],
limit=1).id,
noupdate=True,
)
openupgrade.update_module_moved_fields(
env.cr, "sale.order.line", _moved_fields, "sale_stock", "sale"
)
openupgrade.rename_models(env.cr, _models_renames)
openupgrade.rename_xmlids(env.cr, _renames_xmlids)
_noupdate_switch(env)
_remove_table_constraints(env)
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---Models in module 'sale'---
obsolete model report.all.channels.sales [sql_view]
obsolete model report.sale.report_saleproforma [abstract]
# NOTHING TO DO: obsolete model, does not exist in the database

obsolete model sale.payment.acquirer.onboarding.wizard [transient]
new model sale.payment.provider.onboarding.wizard [transient]
# DONE: pre-migration: renamed model sale.payment.acquirer.onboarding.wizard to sale.payment.provider.onboarding.wizard

---Fields in module 'sale'---
sale / account.analytic.applicability / business_domain (False) : NEW selection_keys: ['bill', 'expense', 'general', 'invoice', 'purchase_order', 'sale_order'], mode: modify
# NOTHING TO DO

sale / account.bank.statement.line / partner_shipping_id (many2one): module is now 'account' ('sale')
sale / account.move / partner_shipping_id (many2one): module is now 'account' ('sale')
sale / account.move.line / is_downpayment (boolean) : NEW
sale / account.payment / partner_shipping_id (many2one): module is now 'account' ('sale')
# NOTHING TO DO

sale / payment.acquirer / so_reference_type (selection) : DEL selection_keys: ['partner', 'so_name']
sale / payment.provider / so_reference_type (selection) : NEW selection_keys: ['partner', 'so_name'], hasdefault: default
# NOTHING TO DO

sale / sale.order / show_update_fpos (boolean) : NEW
sale / sale.order / show_update_pricelist (boolean): not stored anymore
# NOTHING TO DO: handle by ORM

sale / sale.order.line / analytic_distribution_stored_char (char): NEW isfunction: function, stored
# NOTHINGH TO DO: handle by ORM

sale / sale.order.line / analytic_tag_ids (many2many) : DEL relation: account.analytic.tag
# NOTHINGH TO DO: not used any more

sale / sale.order.line / product_type (selection) : previously in module sale_stock
# DONE: pre-migration: moved from sale_stock to sale

sale / sale.order.line / qty_delivered (float) : not a function anymore
# NOTHING TO DO: No database change

sale / sale.order.line / qty_delivered_manual (float) : DEL
# NOTHING TO DO: not used any more, this field is useless since the new compute method from 13.0

---XML records in moduldatabasee 'sale'---
NEW ir.actions.act_window: sale.action_open_sale_payment_provider_onboarding_wizard
DEL ir.actions.act_window: sale.action_open_sale_onboarding_payment_acquirer_wizard
DEL ir.actions.act_window: sale.action_sale_order_form_view
# NOTHING TO DO: noupdate="0" records

ir.actions.server: sale.model_sale_order_action_share (noupdate switched)
# DONE: pre-migration: noupdate switched to 1

NEW ir.config_parameter: sale.default_invoice_email_template (noupdate)
# DONE: pre-migration: add xmlid

NEW ir.model.access: sale.access_product_product_attribute_custom_value_sale_user
NEW ir.model.access: sale.access_product_tag_sale_manager
NEW ir.model.access: sale.access_sale_payment_provider_onboarding_wizard
DEL ir.model.access: sale.access_account_account_sale_manager
DEL ir.model.access: sale.access_account_account_type_sale_salesman
DEL ir.model.access: sale.access_account_analytic_tag_sale_salesman
DEL ir.model.access: sale.access_account_move_manager
DEL ir.model.access: sale.access_account_tax_sale_manager
DEL ir.model.access: sale.access_product_product_attribute_custom_value_sale_manager
DEL ir.model.access: sale.access_report_all_channels_sales
DEL ir.model.access: sale.access_sale_payment_acquirer_onboarding_wizard
DEL ir.model.access: sale.access_sale_report_manager
# NOTHING TO DO

ir.model.constraint: sale.constraint_sale_order_date_order_conditional_required (changed definition: is now 'check((state in('sale','done') and date_order is not null) or state not in('sale','done'))' ('check((state in('sale','done') and date_order is not null) or state not in('sale','done') )'))
# DONE: pre-migration: dropped constraint and let ORM add it again with the new definition

NEW ir.rule: sale.sale_payment_provider_onboarding_wizard_rule (noupdate)
DEL ir.rule: sale.sale_payment_acquirer_onboarding_wizard_rule (noupdate)
NEW ir.ui.menu: sale.menu_product_attribute_action [renamed from sale_management module]
# DONE: pre-migration: renamed xmlids

DEL ir.ui.menu: sale.menu_product
NEW ir.ui.view: sale.payment_provider_form
DEL ir.ui.view: sale.acquirer_form_inherit_sale
# NOTHING TO DO

DEL ir.ui.view: sale.mail_notification_paynow_online (noupdate)
# DONE: post-migration: delete record noupdate="1"

DEL ir.ui.view: sale.product_template_form_view_invoice_policy
DEL ir.ui.view: sale.product_template_sale_form_view
DEL ir.ui.view: sale.report_invoice_document_inherit_sale
DEL ir.ui.view: sale.sale_onboarding_order_confirmation_form
NEW mail.template: sale.mail_template_sale_cancellation (noupdate)
# NOTHING TO DO

DEL res.groups: sale.group_delivery_invoice_address [renamed to account module]
# NOTHING TO DO: handle in migration script of 'account' module

0 comments on commit 37e9a76

Please sign in to comment.