I want to show "Create Invoice" button in Sales Order only for one group.Is is Possible? I've created a new group in Sales,it is Sales/Branch Head.Is is possible to hide the " Create Invoice " button for all users and show it only for "Sales/ Branch Head" group.Thanks in advance
2 Answers
3
votes
You can use groups attribute. Example from account module:
<record id="view_invoice_line_tree" model="ir.ui.view">
<field name="name">account.invoice.line.tree</field>
<field name="model">account.invoice.line</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Invoice Line">
<field name="name"/>
<field name="account_id" groups="account.group_account_user"/>
<field name="quantity"/>
<field name="uos_id"/>
<field name="price_unit"/>
<field name="discount" groups="base.group_extended"/>
<field name="price_subtotal"/>
</tree>
</field>
</record>
0
votes
You can create a view for all your other users without the button you want to show. And then create a other view that inherits your first view and add the button you want to show to your desired group. Here is an example I am using and is working for me.
<?xml version="1.0"?>
<openerp>
<data>
<!-- ##################################################### SHOW BUTTON ONLY TO MEMBERS OF SOME_GROUP ############################################################ -->
<record model="ir.ui.view" id="unique_id_of_your_new_view">
<field name="name">view.unique.id.of.your.new.view</field>
<field name="model">your.model</field>
<field name="inherit_id" ref="id_of_view_youre_inheriting"/>
<field name="groups_id" eval="[(6, 0, [ref('name_of_your_group') ])]"/>
<field name="arch" type="xml">
<field name="some_field_in_your_main_view" position="after">
<!-- whatever you will place here will be shown only to members of 'name_of_your_group' -->
<button name="your_button" class="oe_highlight" string="This button is not shown to everybody" />
</field>
</field>
</record>
</data>
</openerp>