This question has been flagged
1 Reply
3022 Views

Hi there,

I'm developing a module that hides the cost price `purchase_price` in sale order for users without `group_show_cost_and_margin`. I've created a view that modifies `sale.order.line.tree.margin.view.form` from sale_margin (https://github.com/odoo/odoo/blob/10.0/addons/sale_margin/views/sale_margin_view.xml).

My view:

    <record id="sale_order_line_purchase_price_form" model="ir.ui.view">
    <field name="name">ale.order.line.tree.purchase.form</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale_margin.sale_margin_sale_order_line"/>
    <field name="arch" type="xml">
        <field name="purchase_price" position="replace">
            <field name="purchase_price"   groups="hide_cost_margin.group_show_cost_and_margin"/>
        </field>
    </field>
    </record>

However, the cost column is still shown for users without `group_show_cost_and_margin` permission.

What am I doing wrong?

Thanks you in advance.

Avatar
Discard
Best Answer

Hello Try this


<record model="ir.ui.view" id="sale_margin_sale_order_line1">
<field name="name">sale.order.line.margin.view.form1</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale_margin.sale_margin_sale_order_line"/>
<field name="arch" type="xml">
    <xpath expr="//field[@name='order_line']/form//field[@name='purchase_price']" position="replace">
<field name="purchase_price"   groups="hide_cost_margin.group_show_cost_and_margin"/>
    </xpath>
</field>
</record>

<record model="ir.ui.view" id="sale_margin_sale_order_line_form1">
<field name="name">sale.order.line.tree.margin.view.form1</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale_margin.sale_margin_sale_order_line_form"/>
<field name="arch" type="xml">
   <xpath expr="//field[@name='order_line']/tree//field[@name='purchase_price']" position="replace">
<field name="purchase_price"   groups="hide_cost_margin.group_show_cost_and_margin"/>
    </xpath>
</field>
</record>
Avatar
Discard
Author

Thanks you!