[FIX] website: make generated templates noupdate
Since [1] when the generation of missing configurator templates and new
page templates was introduced, `_load_xmlid` was called for every
generated record so that `_process_end` does not delete them after a
module update.
Unfortunately, this trick does not work when using the "Upgrade" command
on the Website app in the Apps view. (or calling
```py
env['ir.module.module'].search([
('name', '=', 'website')
]).button_immediate_upgrade()`
```
from the shell): in that case, the `self.pool` onto which the xmlids
were registered was a different instance from the one accessed by
`_process_end`.
This commit avoids this problem by making the generated templates
`noupdate: True`, thus preventing `_process_end` from deleting them.
Steps to reproduce:
- Install website with -i
- Go to Apps, search Website, upgrade Website
=> In the logs you can see that some templates are deleted at the end of
the upgrade
- Website configurator: a business website, furniture store, get leads,
choose a palette, about us + services + pricing + privacy policy,
choose the center template (loftspace)
=> You see some crash in the logs
[1]: https://github.com/odoo/odoo/commit/a2f8e18b76e52e1a349b77691d0af18edc09a1be
closes odoo/odoo#140986
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
@@ -568,11 +568,17 @@ class IrModuleModule(models.Model):
|
||||
|
||||
:param views: views for which model data must be created
|
||||
"""
|
||||
# The generated templates are set as noupdate in order to avoid that
|
||||
# _process_end deletes them.
|
||||
# In case some of them require an XML definition in the future,
|
||||
# an upgrade script will be needed to temporarily make those
|
||||
# records updatable.
|
||||
self.env['ir.model.data'].create([{
|
||||
'name': view.key.split('.')[1],
|
||||
'module': view.key.split('.')[0],
|
||||
'model': 'ir.ui.view',
|
||||
'res_id': view.id,
|
||||
'noupdate': True,
|
||||
} for view in views])
|
||||
|
||||
def _generate_primary_snippet_templates(self):
|
||||
@@ -605,11 +611,6 @@ class IrModuleModule(models.Model):
|
||||
missing_create_values = [values for values in create_values if values['key'] not in existing_primary_template_keys]
|
||||
missing_records = self.env['ir.ui.view'].with_context(no_cow=True).create(missing_create_values)
|
||||
self._create_model_data(missing_records)
|
||||
|
||||
# Prevent deletion by _process_end
|
||||
for values in create_values:
|
||||
self.env['ir.model.data']._load_xmlid(values["key"])
|
||||
|
||||
return len(missing_records)
|
||||
|
||||
def get_create_vals(name, snippet_key, parent_wrap, new_wrap):
|
||||
@@ -779,8 +780,5 @@ class IrModuleModule(models.Model):
|
||||
missing_records = View.create(missing_create_values)
|
||||
self._create_model_data(missing_records)
|
||||
_logger.info('Generated %s primary page templates for %r', len(missing_create_values), self.name)
|
||||
# Prevent deletion by _process_end
|
||||
for values in create_values:
|
||||
self.env['ir.model.data']._load_xmlid(values['key'])
|
||||
if update_count:
|
||||
_logger.info('Updated %s primary page templates for %r', update_count, self.name)
|
||||
|
||||
Reference in New Issue
Block a user