YAML models of Odoo
Current project stage is Proof of Concept:
- no tests,
- no stability,
- everything may change next minute
Install with pip:
pip install -e git+https://github.com/crnd-inc/yamodool.git#egg=yamodool
or add line to requirements.txt
:
-e git+https://github.com/crnd-inc/yamodool.git#egg=yamodool
-
Add following lines into
__init__.py
file of your addonfrom yamodool import load_yamodool load_yamodool()
-
Create subdirectory
yamodools
in your addon. -
Create model definition in file
yamodools/my_super_model.yml
name: my.super.model order: sequence ASC description: My super model fields: sequence: type: Integer default: 5 active: type: Boolean default: true index: true name: type: Char required: true index: true translate: true help: Record name contact_id: type: Many2one required: true comodel_name: res.partner contact_type: type: Selection selection: - Address - Contact - Company constraints: unique_name: type: unique fields: - name message: Name must be unique ascii_name: type: check check: 'name ~ ''^[a-zA-Z0-9\-_]*$''' message: Name must be ascii only
-
Add
dependencies
section to addon's manifest file'external_dependencies': { 'python': [ 'yamodool', ], },
There is examples firectory in project root, that contains example models. Look there for more features.
The main goal of this project is to separate model definition from python code in a way that will not conflict with Odoo.