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

Hi,

I need to set one of my one2many field as static,That  is, I have a one2many field and one of its field values should be set before its loading.

How can I do that??

Please help

Thanks in advance

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

Hello

you can see the example in "working time".

Activate the debug mode, Go to Settings -> Technical -> Resource -> working time. click on Create button, after that you will get the Working hours by default.

=> using default_get of your main object you can achieve this.

@api.model
def default_get(self, fields_list):
       res = super(classname, self).default_get(fields_list)
       vals = [(0, 0, {'field_1': value_1, 'field_2': value_2}),
               (0, 0, {'field_1': value_1, 'field_2': value_2})]
       res.update({'your_o2m_field': vals})
       return res

I  hope this will helps you.

       


الصورة الرمزية
إهمال

It worked for me, thanks !

Thank You @ Mitul Shingala

Appreciate for your answer

+1 from me

المنشورات ذات الصلة الردود أدوات العرض النشاط
3
يوليو 19
5416
4
نوفمبر 20
7900
1
أغسطس 20
3958
0
نوفمبر 18
2509
2
مارس 25
8727