2015-02-11 123 views
8

如何添加上odoo
相關的字段我想補充的stock.move文本字段相關stock.picking起源場
我嘗試這樣做:odoo相關領域?

_columns={  
    'sourcebl': fields.related('picking_id', 'origin', type='char', relation='stock.picking', string='Class Description', store=True, readonly=True), 
      } 

你有什麼想法

回答

2

我用舊的API它精細現在的工作:

_columns={ 
'sourcebon': fields.related('picking_id', 'origin', string="Origin", type="char",store=True, readonly=True), 
} 
+5

好的,太棒了!但是如果你使用Odoo,你必須使用新的API來獲得更好的兼容性和更好的性能。 – 2015-09-08 13:49:48

15

您可以在這裏找到更多的信息:Link

在新的API中,不再有field.related。你應該定義你的相關領域是這樣的:

sourcebl = fields.Char(string='Class Description', related='picking_id.origin') 
+0

這段Python代碼是放到哪裏實現呢? – Omar 2015-03-26 15:44:50

+0

其新的API字段聲明,所以它將與其他字段。 – 2015-09-18 12:51:23

+0

非常有幫助。它包含在文檔中,但很難注意。 – 2015-10-29 09:52:28