获取表单视图 odoo 10 中的所有字段和值

Fetch all fields and values in a form view odoo 10

我需要将表单视图中的所有字段及其值提取到字典中。 例如,在 customer form view 中,需要在按钮函数中将所有值放入字典中。 我尝试使用 fields_get()fields_view_getname_get。但没有运气。 有没有预定义的功能或解决方案?

self.env.cr.execute("""select * from res_partner where id=%s""",(self.id,))
line_list = [i for i in self.env.cr.dictfetchall()]
for i in line_list:
    print i['fieldname']

或使用orm方法

请试试这个:

for rec in your_list_of_dictionary:
    print rec #this rec variable contains dictionary

终于找到解决办法了。self.read()帮了我。