2017-04-19 56 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?只是为了从基地改变字段的类型。 –