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 filter view according to company?

By
Andrew
on 7/15/15, 9:29 AM 806 views

Hello. I have an ERP instance with several companies.


I wan't to set a default view filter for my custom module which will show only records from current users company.

For example a user should view only records where company_id is equal to his company. It is possible to do this?

I have tried to use something like this, but it isn't working.


filter string="My Company" name="my company" domain="[('company_id','==',[user.company_id.id])]" />

Try this one. [('company_id','child_of',[user.company_id.id])]

Solanki Shamji
on 7/15/15, 9:41 AM

also try this ['|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False)]

Solanki Shamji
on 7/15/15, 9:42 AM

have you define comapny_id (many2one) field in your custom object?

Solanki Shamji
on 7/16/15, 5:28 AM
0
Andrew
On 7/15/15, 10:09 AM

Unfortunattly "Solanki Shamji" solution is not working. It says " Uncaught TypeError: Cannot read property 'length' of undefined" :( 

have you define comapny_id (many2one) field in your custom object?

Solanki Shamji
on 7/16/15, 5:28 AM
0

Drees Far

--Drees Far--
1130
| 5 2 6
Tunis, Tunisia
--Drees Far--
Drees Far
On 7/15/15, 9:55 AM

Here is the answer:

In the group of your user in settings for example : Human Ressources/Manager or Human Ressources/Emplyees in settings, if you click on it, you will find some thing named "Rules". There, you add:

General:

name:

object: object of your custom module

active: True

Rule definition:

['|', ('employee_id.user_id', '=', user.id), ('employee_id.department_id.manager_id.user_id', '=', user.id)]

and then you add the group of users: Human Ressources/Manager or Human Ressources/Emplyees

i have worked with this to display for each employee only his own payslips.

It works fine


Try it and if it works for you just vote

Drees Far
on 7/15/15, 10:02 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

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/15/15, 9:29 AM
Seen: 806 times
Last updated: 7/16/15, 5:28 AM