https://github.com/wearp/odatoo
Odoo XML data file generation using Python
https://github.com/wearp/odatoo
odoo xml-data
Last synced: 30 days ago
JSON representation
Odoo XML data file generation using Python
- Host: GitHub
- URL: https://github.com/wearp/odatoo
- Owner: wearp
- Created: 2016-02-07T16:20:48.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-18T08:40:12.000Z (almost 10 years ago)
- Last Synced: 2025-09-28T20:01:57.930Z (5 months ago)
- Topics: odoo, xml-data
- Language: Python
- Homepage:
- Size: 14.6 KB
- Stars: 7
- Watchers: 0
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# odatoo
[](https://travis-ci.org/wearp/odatoo) [](https://coveralls.io/github/wearp/odatoo?branch=master)
_Generate Odoo XML data files, effortlessly, in python._
For times when you need to create _a lot_ of data (i.e. for demonstration or test purposes), and you can't be bothered.
## Install
```
pip install odatoo
```
## Create a document
```python
>>> from odatoo.document import Document
>>> doc = Document()
>>> ...
```
## Create a record and fields
```python
>>> record = doc.record(model="openacademy.course", id="course0")
>>> # add a fields to the record
>>> record.field(name="name", value="Course 0")
>>> record.field(name="description", value="Course 0's description")
>>> # add another record
>>> another_record = doc.record(model="openacademy.course", id="course1")
>>> ...
```
## Set/edit field and record properties
```python
>>> # 'name' is a required field property
>>> field = another_record.field(name="name")
>>> # set 'value''
>>> field.value = "Course 1"
>>> field.description = "Course 1's description"
>>> another_field = another_record.field(name="teacher_id")
>>> another_field.ref = "teacher_1"
>>> ...
```
## Write document to a file
```python
>>> doc.write("demo.xml")
```
## Output XML data file
```xml
Course 0
Course 0's description
Course 1
Course 1's description
```