Search code examples
odooodoo-12

Odoo 12: KeyError: 'ir.values'


I m trying to create a new contact in odoo application but it shows me this error :

KeyError: 'ir.values'

The issue is related with this funtion.

 class ResPartner(models.Model):
_inherit = 'res.partner'

def _default_credit_limit(self):
    return self.env['ir.values'].get_default('account.config.settings', 'credit_limit')

I don't understand the problem

Can you please help me


Solution

  • KeyError: 'ir.values'

    If you run self.env['ir.values'] on Odoo 12, you will get the above error because the ir.values Model does not exist in Odoo 12.

    The ir.values Model was removed and replaced with ir.default. For example:

    self.env['ir.default'].get('sale.order', 'sale_order_template_id')
    

    You can see the relevant file in the Odoo core code or the commit where most of that Model was added.