openerp-connector-community team mailing list archive
-
openerp-connector-community team
-
Mailing list archive
-
Message #00214
override field selection, best pratice
Hello devs,
I have a question towards OpenERP experts
We cant' inherit directly method defined for field selection.
Two Solutions
1.a/ Either you do this on main class model
def _get_type_selection(self, cr, uid, context=None):
""" To inherit to add type """
return []
_columns = {
'type': fields.selection(
_get_type_selection,
'Type',),
1.b/ and defined again field on each inherit class
def _get_type_selection(self, cr, uid, context=None):
res = super(MyClass, self)._get_type_selection(cr, uid, context=context)
res.append(('myvalue', My Value'),)
return res
_columns = {
'type': fields.selection(
_get_type_selection,
'Type',),
2.a/ Either you do that in the main model
def _get_type_selection(self, cr, uid, context=None):
""" To inherit to add type """
return []
def __get_type_selection(self, cr, uid, context=None):
return self._get_type_selection(cr, uid, context=context)
_columns = {
'type': fields.selection(
__get_type_selection,
'Type',),
2.b/ only this on each inherit class:
def _get_type_selection(self, cr, uid, context=None):
res = super(MyClass, self)._get_type_selection(cr, uid, context=context)
res.append(('myvalue', My Value'),)
return res
First solution is used for example here
in http://bazaar.launchpad.net/~stock-logistic-core-editors/carriers-deliveries/7.0/files/9/delivery_carrier_label_postlogistics.
Mainly at Akretion we think second solution is better,
Thanks for your feed back
David BEAL
Akretion
OpenERP Development - Integration
+33 (0)6 67 22 86 89
+33 (0)4 82 53 84 60
Follow ups