Hi Experts,
Purpose: Intend to hide the "sale price" when a product is not marked as "can be sold" under the product "general information" tab.
Version: 10 CE
Found this original field from product_views.xml:
<field name="list_price" widget='monetary' options="{'currency_field': 'currency_id'}"/>
I wrote this:
<record id= "product_template_form_view_inherited" model= "ir.ui.view">
<field name="inherit_id" ref="product.product_template_form_view" />
<field name="model">product.template</field >
<field name="arch" type= "xml">
<group name="group_standard_price">
<field name="list_price" position="attributes">
<attrs name='invisible'>{[('sale_ok','=',False)]}</attrs>
<attrs name='widget'>{'monetary'}</attrs>
<attrs name='options'>{'currency_field': 'currency_id'}</attrs>
</field>
</group>
</field>
</record>
It did not work, any idea?
p/s: I always have this doubt, if I extend a field with the purpose to override one intended attribute only, I still need to include all other original attributes so they are all retained, right?
Thank you!
Tom
use xpath to find the field you want to modify, then your code will work. you don't need to rewrite all attributes in your extension. only the ones you need to modify. otherwise you will mess with other things.
<xpath expr="//field[@name='list_price']" position="attributes">
<attribute name=" ... "> ... value here ... </attribute>
</xpath>