An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# odatoo

[![Build Status](https://travis-ci.org/wearp/odatoo.svg?branch=master)](https://travis-ci.org/wearp/odatoo) [![Coverage Status](https://coveralls.io/repos/github/wearp/odatoo/badge.svg?branch=master)](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


```