omas
omas

Reputation: 79

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

Upvotes: 1

Views: 2393

Answers (2)

Travis Waelbroeck
Travis Waelbroeck

Reputation: 2135

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.

Upvotes: 4

CZoellner
CZoellner

Reputation: 14801

Are you sure that this setting even exists anymore? I don't know for sure, but couldn't find it, i'm aware in Odoo 8 it existed. Beside the fact, that i don't think it exists anymore: account.config.settings don't exist for 100% sure, because the settings model was refactored into res.config.settings.

Actually the partner field credit_limit is gone, too. So if you want to use it and have a default outside the code, use ir.default for your desired behaviour.

Upvotes: 0

Related Questions