c2c-oerpscenario team mailing list archive
-
c2c-oerpscenario team
-
Mailing list archive
-
Message #06346
[Bug 669920] Re: [6.0RC1][WISH] Allow to select a view depend of record selected
In account/invoice.py, you do exactly what we want to do :
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
journal_obj = self.pool.get('account.journal')
if context is None:
context = {}
if context.get('active_model', '') in ['res.partner'] and context.get('active_ids', False) and context['active_ids']:
partner = self.pool.get(context['active_model']).read(cr, uid, context['active_ids'], ['supplier','customer'])[0]
if not view_type:
view_id = self.pool.get('ir.ui.view').search(cr, uid, [('name', '=', 'account.invoice.tree')])[0]
view_type = 'tree'
if view_type == 'form':
if partner['supplier'] and not partner['customer']:
view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name', '=', 'account.invoice.supplier.form')])[0]
else:
view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name', '=', 'account.invoice.form')])[0]
But you have to add the active_model and the active_ids in the context
by yourself. If it could be done automatically...
--
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/669920
Title:
[6.0RC1][WISH] Allow to select a view depend of record selected
Status in OpenObject Web Client:
Triaged
Bug description:
Hi
I need to show different view based on the category of partner, i can do it with my menu link, but if i go in sale order and click on the partner link, view selected by priority.
The active_id not pass in context to function fields_view_get, so ... if i want select view i need the active_id record.
my pacth to do it
client-web/addons/openerp/widgets/screen.py
def add_view_id(self, view_id, view_type):
self.view_id = view_id
if view_type in self.views_preloaded:
view = self.views_preloaded[view_type]
else:
ctx = rpc.session.context.copy()
ctx.update(self.context)
+ ctx['active_id'] = self.id and self.id or False
+ ctx['active_ids'] = self.ids and self.ids or False
if ctx.get('view_id'):
view_id = ctx['view_id']
view = cache.fields_view_get(self.model, view_id, view_type, ctx, self.hastoolbar, self.hassubmenu)
self.add_view(view, view_type)
So now in my addons module in server, i can override the function fields_view_get in res.partner to select view based on the category of the partner.
I hope you can add this in next version.
References