The odoo.sh platform doesn’t provide migrations to Odoo studio custom views. It also deactivate such views in the migration process. However a developer could benefit from the migrations directory during such process to update the views and reactivate it.
The migrations directory informs Odoo run the migration scripts which located the matched version with the manifest. as you can see in the following addon directory
my_module/
├── __init__.py
├── __manifest__.py
├── README.rst
├── models/
│ ├── __init__.py
│ ├── sale_order.py
│ └── res_partner.py
├── security/
│ └── ir.model.access.csv
├── views/
│ ├── sale_order_views.xml
│ └── res_partner_views.xml
├── data/
│ └── data.xml
├── report/
├── wizard/
├── tests/
├── static/
│ └── description/
│ ├── icon.png
│ └── index.html
└── migrations/
├── 17.0.1.0.0/
│ ├── pre-migration.py
│ ├── post-migration.py
│ └── end-migration.py
├── 18.0.1.0.0/
│ ├── pre-migration.py
│ └── post-migration.py
└── 19.0.1.0.0/
├── pre-migration.py
└── post-migration.py
So you could add a migration script such as following to read and update and reactivate the views. please note that you may need the references or the ids of such views
from odoo import api, SUPERUSER_ID
from odoo.tools.misc import file_open
def migrate(cr, version):
env = api.Environment(cr, SUPERUSER_ID, {})
views_to_update = {
'module_name/odoo_studio_views/views_01.xml': 'studio_customization.odoo_studio_account__97c288dc-4e52-49ab-be3a-8625abb5f28e',
'module_name/odoo_studio_views/views_02.xml': 'studio_customization.odoo_studio_account__97c399dc-4e52-49ab-be3a-8625abb5f28e',
}
for file_path, xml_id in _store.items():
if view := env.ref(xml_id, raise_if_not_found=False):
view.write(
{
'active': True,
'arch_db': file_open(file_path, 'r').read(),
}
)
Top comments (0)