改变odoo中的字段类型

时间:2017-04-19 03:40:18

标签: python openerp

嗨伙计们, 我想问一些事情。

基地里有一个像这样的字段:

_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,并使用我自己的名为“compute.location.wizard”的客户模型,我该怎么做?

1 个答案:

答案 0 :(得分: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