I am trying to modify the default value of the Sale Pricelist of a partner (field property_product_pricelist
, tab Sales & Purchases, model res.partner
). It seems that this default value was introduced via XML (since that field is of type property), adding a record to the ir.property
model:
<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>
So I guess (I did not try it) that if you modify this XML record, you will change the default value, for example:
<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>
The problem is that I want to introduce different default values depending on other field (user_id
). I mean, if user_id
is the res.users
with ID 1, I want the Public Pricelist as the default pricelist, otherwise, I want the pricelist created by me (my_default_pricelist
) as the default one.
Can anyone help me, please?