2017-01-19 4 views
0

私はカスタムモジュールこのような新しいstock.locationに定義した:コール特定の株式の場所 - Odoo V9コミュニティ

<record id="location_stock" model="stock.location"> 
    <field name="name">ReparacionUnidades</field> 
    <field name="location_id" ref="stock.stock_location_locations_virtual"/> 
    <field name="usage">production</field> 
    <field name="company_id"></field> 
</record> 

、私は、二つのフィールドにデフォルトとしてこの場所を設定したいですこのような新しいAPI、:default属性で

x_location_src_id = fields.Many2one('stock.location', string=u'Ubicacion Origen de Productos', required=True, 
            readonly=False, default='ReparacionUnidades', 
            help="Location where the system will look for components.") 
x_location_dest_id = fields.Many2one('stock.location', string=u'Ubicacion Destino de Productos', required=True, 
            readonly=False, default='ReparacionUnidades', 
            help="Location where the system will look for components.") 

は、今、この瞬間に、これはフォームの空表示されます。この場合には

ref="stock.stock_location_locations_virtual" 

もちろん、私は、そう、私が呼ぶ、またはより良いことができますどのように、何が同等になり、正しい方法で場所を呼び出していませんよ?

私はstock_location DBテーブルを検索しましたが、本当に私はヒントを持っていません。

アイデア?

EDIT

私はまた、このように試してみた:、default属性にこの_static_locationオブジェクトを呼び出し、その後

def _static_location(self): 
    return ReparacionUnidades 

を、しかしReparacionUnidadesは明らかに定義されていません。

答えて

1

試してみてください。

default=_static_location 

し、あなたの方法を定義するように:メソッドは、フィールドの前に宣言する必要があります

def _static_location(self): 
    return self.env.ref('your_module_name.location_stock') 

+1

LoL、おい、どうして気づかなかったか、ありがとう。 – NeoVe

関連する問題