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

1) We add Custom Field to model manually from "Settings ->  Technical" menu in Odoo, but i want to add multiple fields to particular model (Like Contacts) using some API or Script call

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

What is the meaning of 'state':'base' & 'state':'manual' in of field ?

أفضل إجابة

Hi Ganshyam,

You can call 'ir.model.fields' create mandatory values: {'name':'fieldname','field_description':'feild label','ttype':'boolean','model_id':model_id, 'state':'base'}

Other properties like readonly, required etc. you add in this dictionary.

Make sure you should pass state = 'base', by default it is manual that could be consider as custom field and can easily delete from odoo admin, but for base you can't delete from odoo admin, for custom fields you need to add prefix 'x_' to every field name.

If you're trying though python script you can refer https://www.odoo.com/documentation/10.0/reference/orm.html


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

Your answer is work for me and custom fields added in ir.model.filed, but i as well as i want to add in particular model too like res.partner(Contats).

Indeed you need to find out res.partner model.id pass in create dictionary. Thanks !

الكاتب

It's solved now i want to add those created custom field to view like (res.partner.form)

so we can see those custom field in a form , have u any idea about that please know me.

write some script to update existing ones, first reset there state = base, and remove prefix "x_" update with new field, but I'm not sure about how to deal with data already exist for such fields

المنشورات ذات الصلة الردود أدوات العرض النشاط
2
ديسمبر 24
2287
1
أكتوبر 23
1600
1
فبراير 22
4038
1
فبراير 22
6970
0
نوفمبر 21
4478