Odoo Help


Show projects if the user is in team

on 6/7/16, 6:24 AM 322 views

I want to show projects if the user is in project's teamI have done this at the moment, but I don't know how continue: 


class project_permission(osv.Model):    
    _inherit = 'project.project'    
    def _get_visibility_selection(self, cr, uid, context=None):        
        selection = super(project_permission, self)._get_visibility_selection(cr, uid, context=context)        
        selection.append(('team', _('Private project: team Only')))    # sólo personas del equipo                return selection

And I'm trying to give permissions: 


<?xml version="1.0" encoding="utf-8"?>
    <data noupdate="1">        
        <record model="ir.rule" id="permission.project_public_members_rule">            
            <field name="name">Project: employees: public, team, employees or following</field>            
            <field name="domain_force">                
                    ('privacy_visibility', 'in', ['public', 'employees', 'team']),                    
                                ('privacy_visibility', '=', 'followers'),                            
                                ('message_follower_ids', 'in', [user.partner_id.id]),                        
                                ('privacy_visibility', '=', 'team'),                            
                                ('members', 'in', [user.partner_id.id]),                
            <field name="groups" eval="[(4, ref('base.group_user'))]"/>        
        <record id="permission_project_rule" model="ir.rule">            
            <field name="name">Project: team users: public, team or following</field>            
            <field name="model_id" ref="project.model_project_project"/>            
            <field name="domain_force">                
                        ('privacy_visibility', '=', 'public'),                        
                            ('privacy_visibility', '=', 'team'),                            
                            ('message_follower_ids', 'child_of', [user.partner_id.commercial_partner_id.id]),                    
                            ('privacy_visibility', '=', 'followers'),                        
                            ('message_follower_ids', 'in', [user.partner_id.id])            
            <field name="groups" eval="[(4, ref('base.group_permission'))]"/>        
        <record model="ir.rule" id="project_permission_public_rule">            
            <field name="name">Project: public users: public only</field>            
            <field name="model_id" ref="project.model_project_project"/>                            <field name="domain_force">                [('privacy_visibility', '=', 'public')]            </field>                        <field name="groups" eval="[(4, ref('base.group_public'))]"/>                </record>                        <record model="ir.rule" id="permission.task_visibility_rule">                        <field name="name">Project/Task: employees: public, team, employee or (followers and following)</field>                        <field name="model_id" ref="project.model_project_task"/>                        <field name="domain_force">                                    ['|',                                            ('project_id.privacy_visibility', 'in', ['public', 'team', 'employees']),                                            '|',                                                    '&amp;',                                                            ('project_id.privacy_visibility', '=', 'followers'),                                                            ('project_id.message_follower_ids', 'in', [user.partner_id.id]),                                                    '|',                                
                            ('message_follower_ids', 'in', [user.partner_id.id]),                                
                            ('user_id', '=', user.id),                                            '|',                                                    '&amp;',                                                            ('privacy_visibility', '=', 'team'),                                                            ('members', 'in', [user.partner_id.id]),                                                    '|',                                                            ('members', 'in', [user.partner_id.id]),                                                            ('user_id', '=', user.id),                            ]                        </field>                </record>        
        <record id="permission_task_rule" model="ir.rule">            
            <field name="name">Project/Task: team users: public or (team and colleagues following)</field>                        <field name="model_id" ref="project.model_project_task"/>                        <field name="domain_force">                                ['|',                                            '|',                                                    '|',                                                            ('project_id.privacy_visibility', '=', 'public'),                                                            '&amp;',                                    
                                ('project_id.privacy_visibility', '=', 'team'),                                    
                                ('project_id.members', 'child_of', [user.partner_id.commercial_partner_id.id]),                            
                       '&amp;',                                                            ('project_id.privacy_visibility', '=', 'followers'),                                                            ('project_id.message_follower_ids', 'in', [user.partner_id.id]),                                            '&amp;',                                                    # on employee project can receive messages but not access the object                                                    ('project_id.privacy_visibility', '!=', 'employees'),                                                    ('message_follower_ids', 'in', [user.partner_id.id]),                                ]                        </field>                        <field name="groups" eval="[(4, ref('base.group_team'))]"/>                </record>        
        <record model="ir.rule" id="permission_task_public_rule">            
            <field name="name">Project/Task: public users: public only</field>            
            <field name="model_id" ref="project.model_project_task"/>            
            <field name="domain_force">[('project_id.privacy_visibility', '=', 'public')]</field>            
            <field name="groups" eval="[(4, ref('base.group_public'))]"/>        

And this is my .csv: 


Am I doing well? Or maybe have I got to do another thing (like a domain...)?

The field where the user are part of the team of the project is a many2many

on 6/7/16, 6:26 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 platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 6/7/16, 6:24 AM
Seen: 322 times
Last updated: 6/7/16, 7:15 AM