Odoo Help


How to hide the Print button for a group?

on 3/5/15, 2:36 PM 2,180 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?



| 6 5 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"/>

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.

I loved your answer in this way i can even add new field to ir.values like goups_ids, view_ids and view_id because this actions shows in every view in the model some time i don't want that and some time i don't want to use buttons to fix this problem really greate work and good idea thank you

on 12/3/16, 8:33 AM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


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