Reputation: 1600
Environment :- Odoo 9, Python 2.7
Module A
from openerp import models, fields, api, _, exceptions
class Games(models.Model):
_name = 'moduleA.games'
game = fields.Selection([
('cricket', 'Cricket'),
('hockey', 'Hockey'),
('golf', 'Golf')],
string='Game', default='cricket', required=True
)
Module B
from openerp import models, fields, api, _, exceptions
class ExtraGames(models.Model):
_inherit = 'moduleA.games'
def __init__(self, pool, cr):
res = super(ExtraGames,self)._columns # res = {}
super(ExtraGames,self)._columns['game'].selection.append(
('chess', 'Chess')
)
Now using that code, I want to add one more game Chess inside already defined games list but its not working. Actually I am getting empty dictionary ( {} ) as result of super(ExtraGames,self)._columns and because of that its giving KeyError 'game'.
How can we do it ?
Upvotes: 1
Views: 267
Reputation: 2633
You can use selection_add
:
from openerp import fields, models
class ExtraGames(models.Model):
_inherit = 'moduleA.games'
game = fields.Selection(
selection_add=[('chess', 'Chess')],
)
Upvotes: 3