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

I have a model res_partner_attributes. Before updating specific field say x_myNumber, how to check if the field exists? If the field does not exist then create the field and update its value.

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

if 'x_field' in x_obj:

....

أفضل إجابة

You can check it like

if 'FIELD_NAME' in self.env['product.product']._fields:
...
...
الصورة الرمزية
إهمال