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

how to set default value for many2one field

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

find the id of that default value and give it to the many2one field using _defaults = ...

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

I have to write a function for default

Suppose I have a many2many relationship from a module "x" with partners. then, the relationship of this many2many fields, becomes a many2one (between the items selected for partners and invoice). I have limited the domain for this relationship in the invoice using domain="[('partner_ids', '=', partner_id)] in the view. It works but now I want to get the first of these items (in the invoice) as the default one. So, actually I don't know the id of the item because it varies for each partner. I just want selected as default the first one in the list. How could I do this?

المنشورات ذات الصلة الردود أدوات العرض النشاط
3
أكتوبر 18
40844
0
سبتمبر 22
60
2
أغسطس 22
3345
0
ديسمبر 21
2783
1
يناير 17
6602