Odoo Help

0

How to get view type in Odoo 8

By
priyait233@gmail.com
on 9/14/18, 3:08 AM 101 views

I need to get view type in Odoo 8. Whether it is form view or not. If it is form view, then i need to do some function. How to get view type in Odoo 8

view_obj = self.env['ir.ui.view'].search([('name','=','your_view_name')])

if view_obj.type == 'form':

#do this

else:

#do this

Sehrish
on 9/14/18, 6:12 AM
0
Muniswaran
On 9/17/18, 2:19 AM

HI Priya,

I think you have to overwrite the fields_view_get function

Here I given example:

Try this below code its may helps to you.

    def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
        res = super(class_name, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
          if view_type == 'form':
            doc = etree.XML(res['arch'])
            for node in doc.xpath("//field[@name='user_id']"):
              node.set('readonly', "1")
              setup_modifiers(node, res['fields']['user_id'])
            res['arch'] = etree.tostring(doc)

        return res
0
Sushma
On 9/14/18, 10:27 AM

Hi Priya,

Try something like example for stock form view, self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'view_stock_return_picking_form')
"get_object_reference() returns (model, res_id) corresponding to a given module and xml_id (cached) or raise ValueError if not found"


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.

Register

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)

Stats

Asked: 9/14/18, 3:08 AM
Seen: 101 times
Last updated: 9/17/18, 2:19 AM