2017-04-19 7 views
1

Hy男、 私は何か質問したい。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)}), 
} 

が、私は名前の私自身、カスタマーモデルと私のウィザードでcharにcomplete_nameフィールドタイプを変更したい:「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テンプレートで使用されている場合は、xmlを編集する必要はありません。 – Cherif

+0

fields.charにfields.functionを変更するだけで機能が有効にならないと言われました。だから、この場合、私はXMLファイルrigthtを編集すべきではありませんか?フィールドのタイプを基底から変更するだけです。 –