Before this commit the neutralize system introduced in v16 was using ORM
methods in order to change appropriate records. Although flexible, this approach
could lead to call some methods with side effects while neutralizing
(eg: overloads of write).
This patch converts the neutralize system to a safer "inert" SQL based approach
by migrating the generic method _neutralize to SQL files exposed in the
data folder.
Task id: 2961687
closes odoo/odoo#102792
X-original-commit: e5dbded9bb363351feff7ca8a56c7f8a6860f492
Related: odoo/enterprise#32580
Signed-off-by: Fabien Meghazi <fme@odoo.com>
22 lines
668 B
Python
22 lines
668 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
import odoo
|
|
|
|
|
|
def get_installed_modules(cursor):
|
|
cursor.execute('''
|
|
SELECT name
|
|
FROM ir_module_module
|
|
WHERE state IN ('installed', 'to upgrade', 'to remove');
|
|
''')
|
|
return [result[0] for result in cursor.fetchall()]
|
|
|
|
def get_neutralization_queries(modules):
|
|
# neutralization for each module
|
|
for module in modules:
|
|
filename = odoo.modules.get_module_resource(module, 'data/neutralize.sql')
|
|
if filename:
|
|
with odoo.tools.misc.file_open(filename) as file:
|
|
yield file.read().strip()
|