Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


How to hide the Print button for a group?

on 3/5/15, 2:36 PM 903 views

Hello, I need to find out how to hide the Print button for a group on a given model.  For example, can I hide the Print button for Sales Users on Sales Orders?

Anton Chepurov
On 3/7/16, 4:27 AM

Say you have this Print button:

    <record id="quant_label_values" model="ir.values">
        <field name="name">Label</field>
        <field name="key2">client_print_multi</field>
        <field name="model">stock.quant</field>
        <field name="value" eval="'ir.actions.report.xml,' + str(ref('quant_label'))"/>


Then this code will hide it from all non-Warehouse Users:


from openerp import api, models

class ir_values(models.Model):

     _inherit = 'ir.values'

    def _drop_quant_print_if_not_stock_user(self, action_slot, model, res):
        if model == 'stock.quant' and action_slot == 'client_print_multi':
            quant_label_values = self.env.ref('my_module.quant_label_values')
            is_stock_user = self.user_has_groups('stock.group_stock_user')
            res = [r for r in res if r[0] != quant_label_values.id or is_stock_user]
        return res

    def get_actions(self, action_slot, model, res_id=False):
        res = super(ir_values, self).get_actions(action_slot, model, res_id=res_id)
        res = self._drop_quant_print_if_not_stock_user(action_slot, model, res)
        return res


Simply adjust this code to your needs.



| 5 4 7
Lodz, Poland

On 3/5/15, 4:36 PM
  • Example (active for base.group_no_one):

<button name="invoice_cancel" states="draft,proforma2,open" string="Cancel Invoice" groups="base.group_no_one"/>

  • Example (active for base.group_sale_manager):

<button name="print_quotation" string="Print" type="object" states="sent,progress,manual" class="oe_highlight" groups="base.group_sale_manager"/>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 3/5/15, 2:36 PM
Seen: 903 times
Last updated: 3/7/16, 4:27 AM