Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
26540 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ

if 'x_field' in x_obj:

....

Câu trả lời hay nhất

You can check it like

if 'FIELD_NAME' in self.env['product.product']._fields:
...
...
Ảnh đại diện
Huỷ bỏ