Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Is there a way to load data into a models binary field on module install?
I want to have a howtos model where there would be a tree view of binary fields where the howtos would be stored. This fields would be filled with data on module install.
I know how to fill data into models with xml files.
<record model="hr.code.tags" id="tag_my_tag"> <field name="name">MyTag</field> <field name="usage">To be used for my values.</field> <field name="locked">True</field> </record>
Yes, there is a way:
Assuming that your module names "demo", your model has the identifier "demo.howto" and the binary field is "file":
1. Put in the folder demo/static/src/binary your pdf files (howto.pdf).
2. Create a file with data records to register in the folder demo/data (howto_data.xml):
<record id="howto_1" model="demo.howto">
<field file="demo/static/src/binary/howto.pdf" name="file" type="base64" />
3. Register the data file in the data section of the __manifest__.py
# always loaded
4. Install module and the data will be loaded.
About This Community
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 12/6/18, 9:46 AM|
|Seen: 82 times|
|Last updated: 12/7/18, 4:54 AM|