Community mailing list archives

community@mail.odoo.com

Re: Accessing user from qweb template in view

by
Torvald Baade Bringsvor, Torvald B. Bringsvor
- 03/23/2015 19:20:38
Hi Naresh and Markus

Both solutions would probably work, but I found Markus' to be the best one so I implemented that and it works beautifully. Thanks for the help.

-Torvald


Torvald Baade Bringsvor
Bringsvor Consulting AS - Odoo (formerly OpenERP) implementation partner

2015-03-23 16:18 GMT+01:00 Markus Schneider <markus.schneider@initos.com>:
Hi Torvald, Hi Naresh,

you don't need to code. You just can use two views:

1) view with field readonly="1" without a group

2) inherit first view, replace readonly attribute for the field with 0
and bind this view to the group.

This should work

Kind Regards

Markus

On 20.03.2015 14:37, Naresh Soni wrote:
> Hi Torvald,
> 
> You can do it like this:
> 
> add one field in your model
> check_group_xxxx = fields.Boolean(compute='check_check_group_xxxx',
> string='Group available')
> 
> in the function:
>  def check_check_group_xxxx(self):
>       self.check_group_xxxx = self.env['res.users'].has_group('group id')
> 
> 
> then in the view use like this:
> 
>  
> 
> 
> I think this should help you !
> 
> 
> Thanks,
> 
> On 20 March 2015 at 17:18, Torvald Baade Bringsvor
>  wrote:
> 
>     Hi
> 
>     I'm trying to solve the following:
> 
>     A field should be editable for members of one group only, it should
>     be read only for everyone else.
> 
>     Using the group attribute in the field tag in the view doesn't work
>     since we need to display the field for the users who are not members.
>     So I tried adding a little qweb template to the view to be able to
>     do a t-if on the group membership if the users, but I can't find
>     anywhere in the docs what kind of data you have available when you
>     are in a regular view (not a website view).
> 
>     Can anyone shed some light on this? Or is there some way to resolve
>     this in plain XML view lingo?
> 
>     -Torvald
> 
> 
>     Torvald Baade Bringsvor
>     Bringsvor Consulting AS - Odoo (formerly OpenERP) implementation partner
> 
>     _______________________________________________
>     Mailing-List: https://www.odoo.com/groups/community-59
>     Post to: mailto:community@mail.odoo.com <mailto:community@mail.odoo.com>
>     Unsubscribe: https://www.odoo.com/groups?unsubscribe
> 
> 
> 
> 
> -- 
> Regards,
> Naresh Soni
> ODOO(Formerly OpenERP) Support & OPW(Team Leader),
> TinyERP Pvt. Ltd. 
> 16 & 17 IT Tower - I
> Infocity Gandhinagar, 
> Gujarat, 382009, India
> 
> Cell:8866370537,
> Web:https://nareshsoni.odoo.com/ ,
> skype:naresh_openerp
> Blog: http://soninaresh.wordpress.com/
> Linkedin : http://www.linkedin.com/profile/view?id=27722844&trk=tab_pro
> 
> 
> 
> 
> _______________________________________________
> Mailing-List: https://www.odoo.com/groups/community-59
> Post to: mailto:community@mail.odoo.com
> Unsubscribe: https://www.odoo.com/groups?unsubscribe
> 

-- 
Dipl.-Comp.-Math. Markus Schneider
Softwareentwickler

initOS GmbH & Co. KG
An der Eisenbahn 1
21224 Rosengarten

Mobil:   +49 (0)172 2303699
Phone:   +49 (0)4105 5615613
Fax:     +49 (0)4105 5615610

Email:   markus.schneider@initos.com
Web:     http://www.initos.com

Geschäftsführung:
Dipl. Wirt.-Inf. Frederik Kramer & Dipl.-Ing. (FH) Torsten Francke
Haftende Gesellschafterin: initOS Verwaltungs GmbH

Sitz der Gesellschaft: Rosengarten – Klecken
Amtsgericht Tostedt, HRA 201840
USt-IdNr: DE 275698169
Steuer-Nr: 15/205/21402

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe