Odoo
Demo Data
In this blog we will explain how to add value for many2one field in the xml demo data file in odoo , so let us start
First let us say we have python object by the name 'report.create' which is contain the model_id field which is many2one field from 'ir.model' as bellow
class ReportCreater(models.Model):
_name = 'report.creater'
model_id = fields.Many2one(
'ir.model', string='Model', required=True, ondelete="cascade",
help="The type of document this template can be used with")
and we want to create demo data for this object and the records from the demo data must contain the model_id field , so we can do it as bellow
<odoo>
<data noupdate="0">
<record id="simple_contract_template" model="desined.report.template">
<field model="ir.model" name="model_id" search="[('model', '=', 'res.partner')]"/>
</record>
</data>
</odoo>
*NOTES
- 'ir.model' this object contain all models in the data base
- search="[('model', '=', 'res.partner')] in this step we made search in the 'ir.model' object to return record from it , and in that record the value of model field must be 'res.partner'
- 'ir.model' contain the model field which is char field
No comments:
Post a Comment