Odoo Help


hide field in fields_view_get function

Thazin Khaing
on 12/5/13, 6:22 AM 3,336 views
 def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
        #override of fields_view_get in order to change the label of the process button and the separator accordingly to the shipping type
        if context is None:
        res = super(stock_partial_picking, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
        type = context.get('default_type', False)
        if type:
            doc = etree.XML(res['arch'])
            for node in doc.xpath("//button[@name='do_partial']"):
                if type == 'in':
                    node.set('string', _('_Receive'))
                elif type == 'out':
                    node.set('string', _('_Deliver'))

        i want to hide qty,expire_date field

        for node in doc.xpath("//separator[@name='product_separator']"):
            if type == 'in':
                node.set('string', _('Receive Products'))
            elif type == 'out':
                node.set('string', _('Deliver Products'))
        res['arch'] = etree.tostring(doc)
    return res

Techno-Functional Associate with 7+ years of experience in Odoo (formerly known as OpenERP).

On 10/9/14, 9:11 AM

set "invisible" attribute in node... exactly like how 'string' is overridden...

@deep: Can i use fields_view_get function to check which user is logged-in and make fields invisible on basis of that?

on 10/15/14, 7:30 AM

Sure you can, than user, it will be wise to set the attribute depending on Groups [user groups], in that way, you will not have to worry in future if you add a new user...

on 10/15/14, 8:41 AM

In case of groups, if two employees belongs to the same group and they can see each other's information, I want to show a field when he/she opens his profile but hide when opens other employee's profile...so which approach should i go with?

on 10/16/14, 12:34 AM

@deep: I have posted question on forum as well....for more details please check here : https://www.odoo.com/forum/help-1/question/hide-tab-from-other-user-65238

on 10/16/14, 12:50 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

0 follower(s)


Asked: 12/5/13, 6:22 AM
Seen: 3336 times
Last updated: 3/16/15, 8:10 AM