Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odgovori
293 Prikazi

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! 

Avatar
Opusti
Best Answer

Hi,

When merging custom modules in Odoo, the behavior of merge_module and remove_module is very specific, and it does not automatically handle everything you might expect.

Since Module A is being fully merged into Module B:


You can usually just call:

from odoo.upgrade import util

def migrate(cr, version):

    util.merge_module(cr, "module_a", "module_b")

    util.remove_module(cr, "module_a")

The field example_field on sale. order and the wizard model will now belong to Module B, and the stored data is safe.

The views and actions will also now belong to Module B.


Hope it helps.

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
1
sep. 25
2147
1
jul. 24
2435
1
jun. 24
4264
1
jan. 23
3037
1
nov. 24
2013