mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-20 21:31:59 +02:00
19.0 vanilla
This commit is contained in:
parent
0a7ae8db93
commit
991d2234ca
416 changed files with 646602 additions and 300844 deletions
|
|
@ -1,14 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import typing
|
||||
from contextlib import suppress
|
||||
|
||||
import odoo
|
||||
import logging
|
||||
from odoo.tools.misc import file_open
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from collections.abc import Iterable, Iterator
|
||||
|
||||
from odoo.sql_db import Cursor
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
def get_installed_modules(cursor):
|
||||
|
||||
def get_installed_modules(cursor: Cursor) -> list[str]:
|
||||
cursor.execute('''
|
||||
SELECT name
|
||||
FROM ir_module_module
|
||||
|
|
@ -16,15 +23,17 @@ def get_installed_modules(cursor):
|
|||
''')
|
||||
return [result[0] for result in cursor.fetchall()]
|
||||
|
||||
def get_neutralization_queries(modules):
|
||||
|
||||
def get_neutralization_queries(modules: Iterable[str]) -> Iterator[str]:
|
||||
# neutralization for each module
|
||||
for module in modules:
|
||||
filename = f'{module}/data/neutralize.sql'
|
||||
with suppress(FileNotFoundError):
|
||||
with odoo.tools.misc.file_open(filename) as file:
|
||||
with file_open(filename) as file:
|
||||
yield file.read().strip()
|
||||
|
||||
def neutralize_database(cursor):
|
||||
|
||||
def neutralize_database(cursor: Cursor) -> None:
|
||||
installed_modules = get_installed_modules(cursor)
|
||||
queries = get_neutralization_queries(installed_modules)
|
||||
for query in queries:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue