I am merging two of my custom modules together, and I want to be sure I’m using the right upgrade_util functions.
Context:
- "Module A" is being merged into "Module B".
- Module A extends the sale.order model with one custom field (example_field) and an inherited view (sale_order_form_extend).
- Module A also includes a wizard + its view. (Transient model with multiple fields)
My Question:
Do I need to explicitly use multiple utils (move_field_to_module, remove_view, move_model, etc.) to handle all the difference move/remove processes (fields, views, wizard) before merging?
Or is it enough to just call "merge_module" and "remove_module"? (Will Odoo move my fields and their stored data as well as remove the views that were defined in Module A as part of these utils?)
Example of what I am think I need to do:
from odoo.upgrade import util
def migrate(cr, version):
# move fields
util.move_field_to_module(cr, "sale.order", "example_field", "module_a", "module_b")
# remove old views
util.remove_view(cr, xml_id="module_a.sale_order_form_extend")
# move wizard fields
util.move_field_to_module(cr, "example.wizard", "fields...")
# Remove wizard view
util.remove_view(cr, xml_id="module_a.wizard_form_view")
# move wizard (model)
util.move_model(cr, "example.wizard", "module_a", "module_b")
# merge modules
util.merge_module(cr, "module_a", "module_b")
# remove old module
util.remove_module(cr, "module_a")
OR is it as simple as doing the following:
from odoo.upgrade import util
def migrate(cr, version):
# merge modules
util.merge_module(cr, "module_a", "module_b")
# remove old module
util.remove_module(cr, "module_a")
I have already checked the Odoo documentation and I cannot determine which way I need to go. Any clarification is appreciated, thanks in advance!