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.
I'm writing a parser for an Aeroo report for expenses.
In the py code I need to make some reference to specific product categories, created within the same module via XML serialization, eg.:
<record id="park" model="product.category"> <field name="parent_id" ref="hr_expense.cat_expense"/> <field name="name">Parking tickets</field> </record>
How can I reference in the py code the category having the id "park"?
All the xml records are stored in "ir.model.data" object. There is a method called "get_object_reference" which gives you the database ID from xml ID.
In this method you have to pass module name where xml record is created and xml ID of the record.
self.pool.get('ir.model.data').get_object_reference(cr, uid, 'module_name', 'xml_id_of_record')
record_id = self.env.ref('module_name.xml_id_of_record').id
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 9/3/15, 6:02 AM|
|Seen: 3827 times|
|Last updated: 3/13/17, 11:59 AM|