← Back to team overview

c2c-oerpscenario team mailing list archive

Re: [Bug 669920] [NEW] [6.0RC1][WISH] Allow to select a view depend of record selected

 

On Tuesday 02 November 2010, you wrote:
> Public bug reported:
> 
> 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.
> 

Please, no. This patch breaks the core ORM (or MVC, in other terms) logic of 
OpenERP. 

It is not the first time we think of something like that. Yes, we do want to 
modify views depending on the context of the data. But there is a rule:

*The xml arch of the view MUST BE independent of the record being
displayed.*

To give you an example: You are at res.partners, you select partner #44 which 
is a customer, and then you would like to have a "customer-oriented" form, 
right? And then, you simply press PgDn and go to record #45, a supplier. See?

Still, even by that rule, we are allowed one workaround. You can have those 
"attributes" in the views, that will make components appear or disappear 
according to the record being viewed. That one will work, and even be more 
generic than having views attached to specific ids. We use it in v6, indeed.

-- 
[6.0RC1][WISH] Allow to select a view depend of record selected
https://bugs.launchpad.net/bugs/669920
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.

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