Intro
This module is a databinding framework for Odoo and XML data: it allows to go from XML to Odoo objects back and forth. While having no hard dependency with it, it has been designed to be used along with xsdata. So a good starting point is to read the xsdata documentation here.
But what if instead of only generating Python structures from XML files you could actually generate full blown Odoo objects or serialize Odoo objects back to XML? This is what this module is for!
First you should generate xsdata Python binding libraries you would generate for your specific XSD grammar, the Brazilian Electronic Invoicing for instance, or UBL or any XSD files...
Second you should generate Odoo abstract mixins for all these pure Python bindings. This can be achieved using xsdata-odoo. An example is OCA/l10n-brazil/l10n_br_nfe_spec for the Brazilian Electronic Invoicing.
SpecModel
Now that you have generated these Odoo abstract bindings you should tell Odoo how to use them. For instance you may want that your abstract model for the recipient of the electronic invoice matches the Odoo res.partner object. This is fairly easy, you mostly need to define an override like:
Notice you should inherit from spec_models.SpecModel and not the usual models.Model.
Field mapping: You can then define two ways mapping between fields by overriding fields from Odoo or from the binding using _compute= , _inverse= or simply related=.
Relational fields: simple fields are easily mapped this way. However what about relational fields? In your XSD schema, your electronic invoice is related to the partner.binding.mixin not to an Odoo res.partner. Don't worry, when SpecModel classes are instanciated for all relational fields, we look if their comodel have been injected into some existing Odoo model and if so we remap them to the proper Odoo model.
Field prefixes: to avoid field collision between the Odoo fields and the XSD fields, the XSD fields are prefixed with the name of the schema and a few digits representing the schema version (typically 2 digits). So if your schema get a minor version upgrade, the same fields and classes are used. For a major upgrade however new fields and classes may be used so data of several major versions could co-exist inside your Odoo database.
StackedModel
Sadly real life XML is a bit more complex than that. Often XML structures are deeply nested just because it makes it easier for XSD schemas to validate them! for instance an electronic invoice line can be a nested structure with lots of tax details and product details. In a relational model like Odoo however you often want flatter data structures instead. This is where StackedModel comes to the rescue! It inherits from SpecModel and when you inherit from StackedModel you can inherit from all the generated mixins corresponding to the nested XML tags below some tag (here invoice.line.binding.mixin). All the fields corresponding to these XML tag attributes will be collected in your model and the XML parsing and serialization will happen as expected. Here is an example inspired from the Brazilian Electronic Invoice where the schema is called nfe and where we use the 2 digits 40 for its short version:
All many2one fields that are required in the XSD (xsd_required=True) will get their model stacked automatically and recursively. You can also force non required many2one fields to be stacked using the stacking_force_paths attribute. On the contrary, you can avoid some required many2one fields to be stacked using the stacking_skip_paths attribute.
Initialization hook
Because XSD schemas can define lot's of different models, spec_driven_model comes with a handy _register_hook override (in spec.mixin) that will automatically make all XSD mixins turn into concrete Odoo model (eg with a table) if you didn't inject them into existing Odoo models already.
auto_awesome What this module does
AI-generated from the code · Odoo 18.0Lets Odoo models be generated from XML schemas and exchange data with XML files in both directions, turning parsed XML into Odoo records and Odoo records back into XML.
This is a technical foundation module for developers who work with XML standards (for example electronic invoicing schemas). It does not add menus or screens for end users; it provides building blocks that other modules use.
What it enables: - Import: a parsed XML document can be turned into Odoo records automatically. The module walks through the XML structure, creates or matches related records (for example partners or countries) instead of duplicating them, and can run in a dry-run mode that builds records without saving them. - Export: existing Odoo records can be converted back into XML structures, including dates, numbers formatted to the schema's decimal places, and nested sub-records. - Automatic model creation: schema-based models that were not attached to an existing Odoo model are made concrete at load time, with their database tables and default read/write access rules created automatically.
Business rules and behaviours it adds: - When several schema fields share the same label, the labels are automatically made unique by appending the schema and tag name, avoiding Odoo's duplicate-label warnings. - Related values found in the XML are copied to the right fields, and choice fields are filled in automatically. - Records are searched before being created, so repeated imports reuse existing data.
It touches ir.model.fields and provides the abstract models spec.mixin, spec.mixin_import, spec.mixin_export and spec.mixin_view.
Required by other modules
Models and fields (4)
- spec.mixin · new model
- spec.mixin_view · new model
- spec.mixin_export · new model
- spec.mixin_import · new model
Text generated by AI (DeepSeek) from reading the Odoo 18.0 code on GitHub; it may contain mistakes, so check the code before deciding. The module is very large and only part of the code was read. View the code on GitHub
Availability by version
Reviewed: 2026-11-03Confirmation status: 7 confirmed, 2 with no information of 9 versions.
Sources · Odoo 13.0
Confirmed on 2026-11-03 in branch 13.0 of OCA/l10n-brazil.
terminal Installation and usage
OCA documentation · Odoo 18.0Usage
Source · Odoo 18.0See my detailed OCA Days explanations here:
You are also encouraged to look at the tests directory which features a full blown example from the famous PurchaseOrder.xsd from Microsoft tutorials.
No verified information in OCA: Installation, Configuration.
Installation instructions, the distribution package, dependencies and configuration steps are not shown because they have not yet been verified in the module documentation for any version.
Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.