تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
5 الردود
11982 أدوات العرض

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])]

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

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

الكاتب أفضل إجابة

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?

أفضل إجابة

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

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
أغسطس 25
66
0
يوليو 25
891
1
مايو 25
1637
ADD PROPERTIES تم الحل
1
مايو 25
2777
2
مارس 25
1515