Denis Ledoux c03e4cb229 [FIX] models: validate standard views set to noupdate in database
On the registry, the set `loaded_xmlids` maintains the list
of the xml ids loaded during a module upgrade.
(The <record/> nodes in XML data file)

According to the `noupdate` attribute on the node in the XML file,
an XML ID is added to the listn either:
 - If noupdate is set on the <data/> node, through `_load_xmlid`:
   - https://github.com/odoo/odoo/blob/eb02e9b3e00243bcf8a41b0f42273e59875ab968/odoo/tools/convert.py#L505-L510
   - https://github.com/odoo/odoo/blob/eb02e9b3e00243bcf8a41b0f42273e59875ab968/odoo/addons/base/models/ir_model.py#L1802
 - If noupdate is not set on the <data/> node, through `_load_records` and `_update_xmlids`:
   - https://github.com/odoo/odoo/blob/eb02e9b3e00243bcf8a41b0f42273e59875ab968/odoo/tools/convert.py#L578
   - https://github.com/odoo/odoo/blob/eb02e9b3e00243bcf8a41b0f42273e59875ab968/odoo/models.py#L4048-L4050
   - https://github.com/odoo/odoo/blob/eb02e9b3e00243bcf8a41b0f42273e59875ab968/odoo/addons/base/models/ir_model.py#L1793
   For this second case, `_update_xmlids` was called only when the condition
   `to_create or to_update` was met.

For records not set as `noupdate="1" in the XML data file,
but set to noupdate in the database
(e.g. manually set by a user),
the code goes trough the second path explained above (noupdate not set on the <data/> node)
and the condition `to_create or to_update` was not met
(See https://github.com/odoo/odoo/blob/eb02e9b3e00243bcf8a41b0f42273e59875ab968/odoo/models.py#L4005-L4012)
and they were therefore not added in the set `loaded_xmlids`

Besides, the method in charge to validate standard views `_validate_module_views`,
only validates views that are in this list `loaded_xmlids`:
https://github.com/odoo/odoo/blob/eb02e9b3e00243bcf8a41b0f42273e59875ab968/odoo/addons/base/models/ir_ui_view.py#L1194-L1210

And the method in charge to validate custom views `_validate_custom_views`
only validates views with no XML ID or the module of the XML ID is not within the list of modules.

Therefore, standard views set to noupdate in database were not validated at all
(or indirectly, if they had a view inheriting on them that was not set to noupdate)

This is not a recent regression, this is the case even in Odoo 8.0.
Standard views set to `noupdate` in database but not in the XML files
were not validated (or indirectly, through one of their inherited views if they had any)

This revision just skips the test `to_create or to_update` so it goes through
`_update_xmlids` anyway and add the xml id to the `loaded_xmlids` set,
so standard views set to noupdate in database finally gets validated.
Besides, `_update_xmlids` won't do anything more than add the xml id to the set,
the SQL query executed in this method has a `WHERE` condition filtering out xml ids set to noupdate
https://github.com/odoo/odoo/blob/eb02e9b3e00243bcf8a41b0f42273e59875ab968/odoo/addons/base/models/ir_model.py#L1784

closes odoo/odoo#40207

Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2019-11-13 13:58:19 +00:00
2019-11-21 18:59:58 +00:00
2015-09-08 15:45:09 +02:00
2019-10-03 12:48:09 +00:00
…
2015-09-08 17:58:38 +02:00
2019-11-08 11:24:04 +00:00
2019-10-03 12:48:09 +00:00

Build Status Tech Doc Help Nightly Builds

Odoo

Odoo is a suite of web based open source business apps.

The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...

Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.

Getting started with Odoo

For a standard installation please follow the Setup instructions from the documentation.

To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials

S
Description
No description provided
Readme LGPL-3.0
3.4 GiB
Languages
Python 49.6%
JavaScript 47.8%
SCSS 2%
CSS 0.3%
HTML 0.2%