Make database fields from fields that live in serialized fields
unserialize_field · OCA/server-tools
-
Security25/25No findings
-
Activity0/25Last human commit 141 months ago
-
Required by5/250 modules depend on it
-
Maturity5/25In 1 Odoo series since 6.1
Heuristic over the facts below, not an audit · How it's computed
Migration considerations
- Migrating to 19.0: only `__manifest__.py` is recognized: a module with `__openerp__.py` is not detected at all. migration-openerp-manifest · source
ir_model_fields— Class 'ir_model_fields' still inherits from the old-style `orm.Model` API: rewrite it against `models.Model`/`models.TransientModel`/`models.AbstractModel` - the old `osv`/`orm` API was removed entirely in modern Odoo. migration-old-api-base · sourceview_model_fields_form— Migrating to 17.0: `attrs=`/`states=` are rejected in views: convert them to Python expressions in `invisible`/`readonly`/`required`, keeping the original AND/OR logic. (2 occurrences in this file) migration-view-attrs-states · source- Migrating to 10.0: the `openerp` namespace was renamed to `odoo`; only a deprecated `openerp.addons` alias remained. (`openerp.osv`) (2 occurrences in this file) migration-openerp-import · source
- Raw `cr.execute()` INSERT/UPDATE/DELETE bypasses the ORM (no compute/constrains/tracking/mail): `UPDATE ir_model_fields SET serialization_field_id = NULL WHERE name = %s and model = %s` - re-check the table/column names still match after upgrading. migration-raw-sql-write · source
Migration review checklist, not a compatibility verdict. "Migrating to X.0" applies once you upgrade to that version; "Since X.0" means this version already ignores or rejects that code. Methodology
Description
Sparse, or serialized fields do not live as a column in the database table. Instead, their values are stored in JSON arrays in a separate field. As a result, these fields cannot be searched or sorted by.
If such a sparse field is created as 'manual', this module can unserialize the field. Its field definition and values will then be migrated to a proper database column. A real life use case where you encounter many of such fields is the Magento-OpenERP connector.
For technical reasons, many2many and one2many fields are not supported.
Dependencies
- Odoo dependencies
-
odoo/odoo:- base
- Python dependencies
- None
- System dependencies
- None
- Required by
- None
Code analysis
Extracted from the source by best-effort static analysis (no code is executed); details may be incomplete.
Views touched 2
| XML ID | Name | Model | Type | Status |
|---|---|---|---|---|
view_model_fields_form |
ir.model.fields | form | Inherits base.view_model_fields_form | |
view_model_form |
ir.model | form | Inherits base.view_model_form |
HTTP endpoints 0
No HTTP endpoints found for this module.
Models touched 1
No new fields.
Public methods (3)-
action_unserialize_field(self, cr, uid, ids, context=None) -
create_database_column(self, cr, uid, pool_obj, field_name, context=None) -
unserialize_field(self, cr, uid, pool_obj, read_record, serialization_field_name, field_name, context=None)