← Back to team overview

openerp-community team mailing list archive

Re: Problem with views

 

Le lundi 21 mars 2011 à 14:37 +0100, Olivier Dony a écrit :
> Le 21/03/11 14:12, Thibaut DIRLIK a écrit :
> > Thanks for your answer. So, how could I do to do what I want? I have to
> > copy/paste the entire sale order view and create a new one ? This
> > doesn't seem to be a good way to obtain what I want.
> 
> Copy/pasting the whole view is probably the worst solution indeed.
> 
> Perhaps you could work with groups, adding your commission-related
> fields in the view in all cases, but with a groups="..."  attributes
> that shows them only to users would belong to the group with that XML
> ID? This is commonly done with the "Usability/Extended view" group.
> 

I thought about this solution. The problem is that in my case (a
commission module), a Sale Agent must be able to do 'normal' sale
orders, and not only commission-related orders.

> Another option could be to use context values in your view, in the
> visibility or attrs values. For example you could perhaps use:
>        invisible="context.get('commission_enabled')"
> and then put a specific context in the action that launches your
> specific view.
> I'm not 100% sure it will work for all your needs, but a combination of
> this and groups-based visibility may allow you to come close to what you
> want.

I also tried this one. It works fine, but only at the 'first level': it
works for fields which belongs to the sale.order object, but not to
fields which belongs to sale.order.line ! And because sale.order.line
views are defined inside the sale.order form view, it doesn't work.

I made a bug request few weeks ago to ask the separation of the
sale.order view and sale.order.line views, but they considered it wasn't
a bug. Anyway, it would allow more flexibility if they was separated.

> 
> On a side note, view copy-by-value works as you expect when using a
> different "model",  e.g. for use with "_inherits", or "_inherit" with
> a different "_name". But that won't help you here, presumably.
> 

Anyway, thanks for your help, I think I will just let the field visible,
and tell the user to not use them if he is not a sale agent.

Thanks for spending time on my problem,

--
Thibaut D.




References