Maintainers
This module is part of the shopinvader/pattern-import-export project on GitHub.
You are welcome to contribute.
This module extends the import/export capabilities of Odoo.
Patterns are simply a type of ir.exports model, so you can define them with the native Odoo widget to define export lists.
This module only create a common data structure. Other modules will be used to add specific file type support like excel and csv.
Table of contents
First you have to define a pattern:
You can refer to the examples in demo data.
You have two options:
Or:
One of the strength of pattern_import_export module is the ability to reference records by natural keys (business keys) instead of technical keys (xmlid or database id).
One or more columns can be the natural key of the record to find and update or to create a new record. Each column in the natural key has to be suffixed by “#key”.
One or more columns can be used as foreign keys can be accessed with “|” syntax. (for instance on partner: country_id|code )
Here is an example of a simple update on product.product: Existing record:
The generated export will look like:
id | name | default_code |
---|---|---|
10 | Product 1 | PRD1 |
Updated file
id | name | default_code |
---|---|---|
10 | Product 1-bis | PRD1B |
After import, our record will have been updated:
Now, let’s update some relational fields. Here is some more of our starting data:
- id (of the seller_id which is a res.partner): 22
- name (seller): Partner 1
- price: 10
The generated export should be like
id | name | default_code | seller_ids|1|id | seller_ids|1|price |
---|---|---|---|---|
10 | Product 1 | PRD1 | 22 | 10 |
Let’s say “ref” is a unique-constrained Char field. For the seller, instead of using its id, let’s use its ref.
id | name | default_code | seller_ids|1|ref#key | seller_ids|1|price |
---|---|---|---|---|
10 | Product 1 | PRD1 | partner1-ref | 10 |
So this #key means that Odoo should search for a res.partner where the ref matches the cell value.
Lets take another example, instead of using the id, we want to use the product’s default_code as key.
id | name | default_code#key | seller_ids|1|ref#key | seller_ids|1|price |
---|---|---|---|---|
Product 1 | PRD1 | partner1-ref | 10 |
Odoo will search the product with the matching default_code and update it.
Please take care of iterators (yield) to avoid loading full file into the system memory.
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed feedback.
Do not contact contributors directly about support or help with technical issues.
This module is part of the shopinvader/pattern-import-export project on GitHub.
You are welcome to contribute.