在 Odoo 的自定义模块中迭代来自其他模型记录的数据

Iterate data from other model records inside custom module in Odoo

我想在我的自定义模块中迭代 account.invoice。我正在使用以下行进行迭代,但它无法正常工作。

for filex in self.env['account.invoice'].search_read([],['partner_id','status','date_due']):

search_read returns 一个字典(check this),因此你需要像这样迭代:

for (key, value) in self.env['account.invoice'].search_read([],['partner_id','status','date_due']).iteritems():