Edi Santoso
Odoo and Python Developer
drink a tea to enjoying the life

odoo 9 custom module AttributeError: 'int' object has no attribute 'id'

odoo 9 error

  File "/home/me/odoo-dev/odoo/openerp/fields.py", line 1705, in convert_to_write
    return value.id
AttributeError: 'int' object has no attribute 'id'


kenapa error ??
karena ketika fields.Many2one dia itu membutuhkan object bukan int
seperti ini yg benar

        return self.env.user.account_diskon_purchase and self.env.user.account_diskon_purchase or False

bukan sepeti ini
        return self.env.user.account_diskon_purchase and self.env.user.account_diskon_purchase.id or False 


reference : http://stackoverflow.com/questions/40531116/attributeerror-int-object-has-no-attribute-id-odoo-v9-community