2017-04-19 66 views
1

Hy guys, 我想問一些問題。改變odoo中的字段類型

那麼有在基地現場是這樣的:

_name = "stock.location" 

_columns = 
{ 
    'complete_name': fields.function(_complete_name, type='char',string="Full Location Name", store={'stock.location': (_get_sublocations, ['name', 'location_id', 'active'], 10)}), 
} 

,我想改變complete_name字段中鍵入我的嚮導CHAR名爲我自己custome模式:「compute.location.wizard」 , 我怎麼做?

回答

1

,如果你使用的是舊的API:

_inherit = "stock.location" 

_columns = 
{ 
    # change the all data 
    # change anything you want 
    'complete_name': fields.function(_new_method_, type='new_type',string="Full Location Name", store={'stock.location': (_get_sublocations, ['name', 'location_id', 'active'], 10)}), 
} 

,但如果你可以使用新的API

from openerp import models, fields 

... 

_inherit = "stock.location" 

complete_name = fields.Integer(compute="_your_new_method_"); 
# you can change one attribute but in your case i think you need to 
# change the compute method too 
+0

我應該編輯XML文件中呢? –

+0

僅當您想更改字段的名稱,因爲xml不關心類型。但如果這個領域是在qweb模板中使用的一些contatination中,我認爲你不必編輯xmls – Cherif

+0

他們告訴我只是將fields.function更改爲fields.char,所以函數不會被激活。那麼,在這種情況下,我不應該編輯xml文件rigtht?只是爲了從基地改變字段的類型。 –