模块'odoo.tools.pycompat'没有属性'integer_types'odoo 13

问题描述

当我尝试在odoo 13中升级代码时,我在odoo 12中具有与pycompat库相关的代码 它给了我以下错误

if isinstance(res_ids,pycompat.integer_types):
AttributeError: module 'odoo.tools.pycompat' has no attribute 'integer_types'

我的python代码如下:

def generate_email(self,res_ids,fields=None):
    self.ensure_one()
    multi_mode = True
    if isinstance(res_ids,pycompat.integer_types):
        res_ids = [res_ids]
        multi_mode = False
    if fields is None:
        fields = ['subject','body_html','email_from','email_to','partner_to','email_cc','email_bcc','reply_to','scheduled_date']

    res_ids_to_templates = self.get_email_template(res_ids)

那么,我需要在此代码中进行哪些更改?

预先感谢

解决方法

integer_types是用于与Python 2代码保持兼容性的填充程序。此填充物(及其他填充物)在Odoo 13中为removed

您应该直接与int进行比较

if isinstance(res_ids,int):
    ...