module 'odoo.tools.pycompat' has no attribute 'integer_types' odoo 13

527 views Asked by At

i have an code related to pycompat library in odoo 12 when i tried to upgrade this code in odoo 13 it gives me below error:

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

my python code is below:

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)

So, what kind of changes i need to do in this code?

Thanks in advance

1

There are 1 answers

2
snakecharmerb On

integer_types was a shim used to maintain compatibility with Python 2 code. This shim (and others) have been removed in Odoo 13.

You should compare against int directly instead

if isinstance(res_ids, int):
    ...