تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
4091 أدوات العرض

I have a model which contains a variable, 'country' and 'country' is a related field with 'res.country' model by Many2One relationship. For demo data I want a specific Country, Like 'Bangladesh' or 'Pakistan' but I got an parsing error when I write Bangladesh in field of demo data. here I provide the code below.


class NewAddress(models.Model):
    _name = 'new.address'
    
    name = fields.Char()
    country = fields.Many2one('res.country')

The demo data part.




Error Part:
odoo.tools.convert.ParseError: while parsing /odoo/custom/pip/bd_address/data/bd_division_demo.xml:4, somewhere inside

Dhaka
Bangladesh







Thanks in Advanced

الصورة الرمزية
إهمال
أفضل إجابة

Hi,

In order to create a new record using the demo data feature, you need to provide the data in an XML format, as shown below:

<odoo>


    <record id="demo_record_1" model="new.address">


        <field name="name">Dhaka</field>


        <field name="country" ref="res.country_34"/>


    </record>


</odoo>

In the example above, we are creating a new record in the new.address model with the name "Dhaka" and setting the country field to the country with the id res.country_34, which is Bangladesh

Note that the ref attribute of the field element is used to specify the id of the record in the res.country model that you want to link to. In order to use this attribute, you will need to know the id of the record in the res.country model that you want to link to. You can find this id by checking the records in the res.country model or by using the search method of the res.country model to find the id of the record you are interested in.

Regards

الصورة الرمزية
إهمال
الكاتب

This Not Worked. Even though documentation also say same.

المنشورات ذات الصلة الردود أدوات العرض النشاط
2
سبتمبر 22
2840
1
ديسمبر 21
5283
1
أغسطس 24
2129
1
يونيو 23
1316
2
فبراير 22
2860