Skip to Content
Menu
This question has been flagged
4 Replies
1630 Views

For timesheets i am trying to only show projects that the user is a member of in the team of the project. Using odoo 11.


For setting team of a project i use project_team, which stores members like this:

members = fields.Many2many('res.users', 'project_user_rel', 'project_id',                           
                            'uid', 'Project Members', help="""Project's


Now in my own addon i try to set domain so that user is in the members:
_inherit = 'account.analytic.line'
project_id = fields.Many2one('project.project', 'Project', domain=[('allow_timesheets', '=', True), ('user_id', 'in', 'members')], delegate=True)

But now it shows no projects at all, even if the user is in the members.

I also tried it another way using

api.constrains('project_id')... but this method is not called at all.

Anyone has an idea what is going on? Thanks

Avatar
Discard
Best Answer

Hello @chester,


<field name="project_id" required="1" domain="['|', ('user_id', '=', uid), ('members', 'in', uid)]"/>


Please use this field and inherit the form/tree view of account.analytic.line

You are trying domain in py file which is not possible as we can get current user in py and in domain.

Can you please mark this as a resolved if you are satisfied with my answer.

Regards,




Email: odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

   

Avatar
Discard
Author

Hello, sorry not working, shows no project at all, even if i put members on right side.

If I could use constraints i could just filter the members but

@api.constrains('project_id') is just not called.

Author

Actually it did work now like this, not sure why it did not before. Thanks for your help!