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

Hello All,

I am using default_get method for one2many fields and i can see fields in list but when i want to pass these fields in dictionary by super method in show blank dictionary. So, how to get this?

My python code is here:


@api.model
def default_get(self, fields):
print("FIELDS", fields)
rec = super(CrmContactLine, self).default_get(fields)
print("REC", rec)
context = dict(self._context or {})
partner = self.env['res.partner'].browse(context['partner_id'])
fields['partner_m2m'] = partner.child_ids
return rec

GOT RESULT ON TERMINAL 'FIELDS' SHOW LIST VALUES BUT 'REC' DICTIONARY NULL

FIELDS ['name', 'email', 'designation', 'linkedln_profile', 'indentifier', 'approached_status', 'approach_date', 'email_status', 'follow_up_date', 'partner_m2m']

REC {}


Thanks in advance.

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

Hello,

update the value like below code

@api.model
def default_get(self, fields):
print("FIELDS", fields)
rec = super(CrmContactLine, self).default_get(fields)
print("REC", rec)
context = dict(self._context or {})
partner = self.env['res.partner'].browse(context['partner_id'])
rec['partner_m2m'] = [(6, 0, partner.child_ids.ids)] # if your field type is many2many
rec['partner_m2m'] = [(0, 0, {'fieldname': value})] # if your field type is one2many
return rec
الصورة الرمزية
إهمال
الكاتب

Thanks Mitul..

المنشورات ذات الصلة الردود أدوات العرض النشاط
2
نوفمبر 21
33014
0
أغسطس 22
2296
1
يوليو 22
19998
0
أبريل 22
2969
3
سبتمبر 21
3154