I'm very disappointed with myself having to ask this question, but after almost two wasted days....
I am creating my first module I have
from osv import osv, fields
class sale_pack_type(osv.Model):
_inherit = 'sale.order'
_columns = {
'sale_pack_type': fields.selection((('a', 'A'), ('b', 'B'), ('c', 'C')), 'Sale Packaging Type'),
}
_defaults = {
'sale_pack_type': 'a',
}
Which works just dandy!
But when I try to retrieve the value using
class ware_pack_type(osv.Model):
_inherit = 'stock.picking.out'
_columns = {
'ware_pack_type': fields.related('sale_id', 'sale_pack_type', type='char', relation='sale.order', readonly=True, store=True, string='Packaging Type'),
}
I get constant failure :( -
The best I can achieve is displaying 'Packaging Type' in the view and 'ware_pack_type' in the 'stock.picking.out' db, all values = NULL.
I've tried everything ...
type='selection', selection=(('a','A'),.....
with and without relation=...
type='one2many'
gone through hundreds of web pages
and many many more
Nothing works, pleeeeasssse help.
It seems to be wrong related field implementation, I am not sure but please check related field documentation. related filed can be use with self related field. please see documentation or batter example from blogs other than openerp docs.
Cheers Zahin - did you mean to say "related field CAN be used"? or did you mean "Cannot"?
The only example / commentary relating to field.related is about a bug but thats four years old, and suppose to be resolved https://bugs.launchpad.net/openobject-server/+bug/385117 - I'm off for a beer!
@Cameron: What I mean is exact given in answer 1, sale_id should require.