简体   繁体   English

显示TypeError:'builtin_function_or_method'对象在Odoo中不可迭代

[英]showing TypeError: 'builtin_function_or_method' object is not iterable in Odoo

I am getting this error when I am trying to change the license_id in odoo 当我尝试在odoo中更改license_id时出现此错误

    @api.multi
    @api.onchange('license_id')
    def del_potential(self):
        _logger.info('Status Approved or not' + str(self.license_id.approval_state))
        _logger.info('Potential FGL' + str(self.partner_potential_fgl_address))
        if self.license_id.approval_state == 'approved':
            so = self.env['sale.order'].browse(id)
            # _logger.info('del_potential id:'+str(so))
            so.partner_potential_fgl_address = False

Can anyone please guide why I am getting this error? 谁能指导我为什么收到此错误?

Sorry it is my bad it should be 对不起,我应该不好

so = self.env['sale.order'].browse([self.id])

instead of 代替

so = self.env['sale.order'].browse(id)

It should be like this, 应该是这样

@api.multi
@api.onchange('license_id')
def del_potential(self):
    for rec in self:
        _logger.info('Status Approved or not' + str(rec.license_id.approval_state))
        _logger.info('Potential FGL' + str(rec.partner_potential_fgl_address))
        if rec.license_id.approval_state == 'approved':
            rec.partner_potential_fgl_address = False

This is not required as self contains list of browsable recordset, so you don't need explicitly browse any ids.. 这不是必需的,因为self包含可浏览记录集的列表,因此您不需要显式浏览任何id。

Don't use 不要使用

so = self.env['sale.order'].browse([self.id])

Use instead 改用

self.id or self.field_name

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 发生异常:TypeError 'builtin_function_or_method' object is not iterable - Exception has occurred: TypeError 'builtin_function_or_method' object is not iterable python “类型错误:‘builtin_function_or_method’ object 不可迭代” - python "TypeError: 'builtin_function_or_method' object is not iterable" TypeError:“ builtin_function_or_method”不可迭代 - TypeError: 'builtin_function_or_method' is not iterable 'builtin_function_or_method' object 不可迭代 - 'builtin_function_or_method' object is not iterable TypeError:“ builtin_function_or_method”对象无法下标 - TypeError: 'builtin_function_or_method' object is unsubscriptable 类型错误:'builtin_function_or_method' 对象不可下标 - TypeError: 'builtin_function_or_method' object is not subscriptable TypeError:“ builtin_function_or_method”对象不可下标 - TypeError: 'builtin_function_or_method' object is not subscriptable python:TypeError:类型'builtin_function_or_method'的参数不可迭代 - python : TypeError: argument of type 'builtin_function_or_method' is not iterable Python:TypeError:类型为'builtin_function_or_method'的参数不可迭代 - Python: TypeError: argument of type 'builtin_function_or_method' is not iterable 修复这个错误? TypeError:“builtin_function_or_method”类型的参数不可迭代 - Fix this error? TypeError: argument of type 'builtin_function_or_method' is not iterable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM