Odoo Help

Welcome!

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.

0

How to switch view in my python function? [Closed]

By
wizardz
on 7/25/16, 2:14 AM 277 views

The Question has been closed for reason: duplicate question

by
wizardz
on 07/26/2016 08:50:31

I have write a simply function with an if else, now I want in my else, that the Odoo view switch to the project tree view. How can I make that?

0

deep

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

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

deep
On 7/26/16, 2:40 AM

Refer the Standard Module, in which they have already done what you are looking for,..

Below is a sample snippet from stock / purchase.

@api.multi

def action_view_picking(self):

'''

This function returns an action that display existing picking orders of given purchase order ids.

When only one found, show the picking immediately.

'''

action = self.env.ref('stock.action_picking_tree')

result = action.read()[0]

#override the context to get rid of the default filtering on picking type

result['context'] = {}

pick_ids = sum([order.picking_ids.ids for order in self], [])

#choose the view_mode accordingly

if len(pick_ids) > 1:

result['domain'] = "[('id','in',[" + ','.join(map(str, pick_ids)) + "])]"

elif len(pick_ids) == 1:

res = self.env.ref('stock.view_picking_form', False)

result['views'] = [(res and res.id or False, 'form')]

result['res_id'] = pick_ids and pick_ids[0] or False

return result



Tips: Use "Ctrl + H" to perform the global search in the entire addons, if you are using IDEs like Eclispse, Aptana Studio,  PyCharm etc.

0
shameem@axon
On 7/25/16, 6:14 AM
 return   { 'name': _(' Name '),
'view_type': 'tree',
'res_model': 'project.project',
'type': ' ir.actions.act_window'
}
     

About This Community

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

Question tools

1 follower(s)

Stats

Asked: 7/25/16, 2:14 AM
Seen: 277 times
Last updated: 7/26/16, 8:50 AM