2016-08-17 13 views
2

パートナーの販売価格表(フィールドproperty_product_pricelist、タブ販売&購入、モデルres.partner)のデフォルト値を変更しようとしています。 (そのフィールドのタイプがプロパティあるので)ir.propertyモデルにレコードを追加して、XMLを経由して、このデフォルト値が導入されたようです:Odoo 8のプロパティフィールドのデフォルト値を変更する方法は?

<record id="list0" model="product.pricelist"> 
    <field name="name">Public Pricelist</field> 
    <field name="type">sale</field> 
</record> 
<record id="ver0" model="product.pricelist.version"> 
    <field name="pricelist_id" ref="list0"/> 
    <field name="name">Default Public Pricelist Version</field> 
</record> 
<record id="item0" model="product.pricelist.item"> 
    <field name="price_version_id" ref="ver0"/> 
    <field name="base" ref="list_price"/> 
    <field name="sequence">1000</field> 
    <field name="name">Default Public Pricelist Line</field> 
</record> 

<!-- 
Property 
--> 
<record forcecreate="True" id="property_product_pricelist" model="ir.property"> 
    <field name="name">property_product_pricelist</field> 
    <field name="fields_id" search="[('model','=','res.partner'),('name','=','property_product_pricelist')]"/> 
    <field eval="'product.pricelist,'+str(ref('list0'))" name="value"/> 
</record> 

だから私は(私はそれを試していない)と思いますもしあなたのことをこのXMLレコードを変更するには、例えば、デフォルト値を変更します:

<record forcecreate="True" id="product.property_product_pricelist" model="ir.property"> 
    <field name="name">property_product_pricelist</field> 
    <field name="fields_id" search="[('model','=','res.partner'),('name','=','property_product_pricelist')]"/> 
    <field eval="'product.pricelist,'+str(ref('my_default_pricelist'))" name="value"/> 
</record> 

問題は、私は他のフィールド(user_id)に応じて、異なるデフォルト値を導入したいということです。つまりuser_idres.users(ID )の場合は、公開価格表をデフォルトの価格表に設定します。そうでない場合は、私が作成した価格表をデフォルトの値として設定します(my_default_pricelist)。

誰でも助けてくれますか?

答えて

0

条件付きのデフォルト値を使用するには、Pythonに移動する必要があります。

モデルを拡張してフィールドを再定義してください。今回は、fnct=compute_method引数を使用してください。 compute_methodは、フィールドのデフォルト値を設定するたびに実行されるメソッドです。

フィールドproperty_product_pricelistが使用しているpropertyクラスは、functionクラスの拡張です。 openerp/osv/fields.pyに行き、functionクラスの定義を見つけて、パラメータを見てください。

関連する問題