模块“odoo.tools.pycompat”没有属性“integer\u types”odoo 13

2024-10-03 21:36:48 发布

您现在位置:Python中文网/ 问答频道 /正文

当我尝试升级ODOO13中的代码时,我在ODOO12中有一个与Pycomat库相关的代码 它给了我以下错误:

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)

那么,我需要在这段代码中做什么样的更改呢

提前谢谢


Tags: to代码selfnoneidsfieldsifmode
1条回答
网友
1楼 · 发布于 2024-10-03 21:36:48

integer_types是一个垫片,用于保持与Python 2代码的兼容性。这个垫片(和其他垫片)已经在Odoo13中安装

您应该直接与int进行比较

if isinstance(res_ids, int):
    ...

相关问题 更多 >