Store¶
store
¶
SQLite persistence layer for the Odoo KB.
Two databases, same schema: - kb_global.db : Odoo community + enterprise, generated once per version. - kb_project.db : global + third-party + apik, scoped to a project.
Schema (v3)¶
meta (key, value) sources (origin, path) modules (name, origin, depends) -- depends is a JSON array string symbols (model, name, kind, origin, module, source_file, source_line, field_type, section) field_refs (model, field_name, module, kwarg, target_method) model_origins (model, module, origin, role, model_type, inherit_json, inherits_json, source_file, source_line) role: 'create' | 'extend' | 'prototype' model_type: 'model' | 'transient' | 'abstract'
Indexes¶
idx_symbols_lookup on symbols(model, name, kind) idx_symbols_module on symbols(module) idx_modules_origin on modules(origin) idx_field_refs_target on field_refs(model, target_method) idx_model_origins_model on model_origins(model) idx_model_origins_role on model_origins(model, role)
Classes:
| Name | Description |
|---|---|
KBReader |
Read-only interface to a KB SQLite database. |
Functions:
| Name | Description |
|---|---|
write_global_kb |
Write (or overwrite) a global KB database. |
write_project_kb |
Write (or overwrite) a project KB database. |
KBReader
¶
KBReader(db_path: Path)
Read-only interface to a KB SQLite database.
Use as a context manager or call close() explicitly when done::
with KBReader(Path(".oops-cache/kb_project.db")) as kb:
entries = kb.get_symbol("sale.order", "action_confirm", "method")
modules = kb.get_modules()
-
Reference
IO
Refactor
refactoranalyse_file
Methods:
| Name | Description |
|---|---|
__enter__ |
Return self for use as a context manager. |
__exit__ |
Close the connection on context-manager exit. |
close |
Close the underlying SQLite connection. |
get_field_refs_for_field |
Return kwargs and target methods referenced by a field. |
get_field_refs_for_method |
Return field references that target a specific method. |
get_meta |
Return all meta key/value pairs. |
get_model_creators |
Return all modules recorded as creators of |
get_model_origin |
Return the role of |
get_model_symbols |
Return all symbols defined on a model across all upstream modules. |
get_modules |
Return all modules indexed by name. |
get_sources |
Return all indexed source roots. |
get_symbol |
Return all KB entries for a symbol (may span multiple modules). |
is_model_creator |
Return True if |
model_exists |
Return True if any upstream module defines or extends this model. |
module_exists |
Return True if the named module is present in the KB. |
symbol_exists |
Return True if the symbol exists in any upstream module. |
Source code in src/oops/kb/store.py
__exit__
¶
close
¶
get_field_refs_for_field
¶
get_field_refs_for_field(model: str, field_name: str, module: Optional[str] = None) -> List[Dict[str, Any]]
Return kwargs and target methods referenced by a field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Dotted model name. |
required |
|
str
|
Field name to look up. |
required |
|
Optional[str]
|
Optional module filter; when given, only entries from that module are returned. |
None
|
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List of |
Source code in src/oops/kb/store.py
get_field_refs_for_method
¶
get_field_refs_for_method(model: str, target_method: str) -> List[Dict[str, Any]]
Return field references that target a specific method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Dotted model name. |
required |
|
str
|
Method name to look up. |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List of |
List[Dict[str, Any]]
|
sorted by module, kwarg, and field name. |
Source code in src/oops/kb/store.py
get_meta
¶
get_model_creators
¶
Return all modules recorded as creators of model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Dotted model name. |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List of |
Source code in src/oops/kb/store.py
get_model_origin
¶
Return the role of module for model, or None if absent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Dotted model name. |
required |
|
str
|
Module name. |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
|
Source code in src/oops/kb/store.py
get_model_symbols
¶
Return all symbols defined on a model across all upstream modules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
dotted model name. |
required |
|
Optional[str]
|
optional filter — 'field' or 'method'. |
None
|
Source code in src/oops/kb/store.py
get_modules
¶
Return all modules indexed by name.
Returns:
| Type | Description |
|---|---|
Dict[str, Dict[str, Any]]
|
Mapping of module name to |
Source code in src/oops/kb/store.py
get_sources
¶
get_symbol
¶
Return all KB entries for a symbol (may span multiple modules).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
dotted model name, e.g. 'sale.order'. |
required |
|
str
|
field or method name. |
required |
|
str
|
'field' or 'method'. |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List of dicts with keys: origin, module, source_file, source_line, |
List[Dict[str, Any]]
|
field_type, section. Empty list if symbol is not found. |
Source code in src/oops/kb/store.py
is_model_creator
¶
Return True if module is a creator (or prototype source) of model.
Falls back to True when neither module nor any other module has a
model_origins creator entry for the model — safe assumption for modules
that were not included in the KB scan.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Dotted model name. |
required |
|
str
|
The module being analysed. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True when this module created the model, False when it only extends it. |
Source code in src/oops/kb/store.py
model_exists
¶
Return True if any upstream module defines or extends this model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Dotted model name, e.g. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if at least one symbol for the model exists, False otherwise. |
Source code in src/oops/kb/store.py
module_exists
¶
Return True if the named module is present in the KB.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Module name to look up. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the module exists, False otherwise. |
Source code in src/oops/kb/store.py
symbol_exists
¶
Return True if the symbol exists in any upstream module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Dotted model name, e.g. |
required |
|
str
|
Symbol name. |
required |
|
str
|
|
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if at least one upstream entry matches, False otherwise. |
Source code in src/oops/kb/store.py
write_global_kb
¶
write_global_kb(db_path: Path, odoo_version: str, sources: Dict[str, str], scan_results: List[Dict[str, Any]]) -> None
Write (or overwrite) a global KB database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Path
|
destination .db file (created if absent). |
required |
|
str
|
e.g. '17.0'. |
required |
|
Dict[str, str]
|
{ origin: absolute_path_string }. |
required |
|
List[Dict[str, Any]]
|
list of ScanResult dicts from scanner.scan_tier(). |
required |
Source code in src/oops/kb/store.py
write_project_kb
¶
write_project_kb(db_path: Path, odoo_version: str, project: str, scope: List[str], sources: Dict[str, str], scan_results: List[Dict[str, Any]]) -> None
Write (or overwrite) a project KB database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Path
|
destination .db file. |
required |
|
str
|
e.g. '17.0'. |
required |
|
str
|
project slug string. |
required |
|
List[str]
|
sorted list of module names in scope. |
required |
|
Dict[str, str]
|
{ origin: absolute_path_string }. |
required |
|
List[Dict[str, Any]]
|
list of ScanResult dicts (global already merged in by caller). |
required |