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

Show projects if the user is in team

By
Celia
on 6/7/16, 6:24 AM 235 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: 

project_permission.py

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: 

permission_security.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp> 
    <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']),                    
                        '|',                        
                            '&amp;',                            
                                ('privacy_visibility', '=', 'followers'),                            
                                ('message_follower_ids', 'in', [user.partner_id.id]),                        
                            '&amp;',                            
                                ('privacy_visibility', '=', 'team'),                            
                                ('members', 'in', [user.partner_id.id]),                
                ]            
            </field>            
            <field name="groups" eval="[(4, ref('base.group_user'))]"/>        
        </record>        
        <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'),                        
                        '&amp;',                            
                            ('privacy_visibility', '=', 'team'),                            
                            ('message_follower_ids', 'child_of', [user.partner_id.commercial_partner_id.id]),                    
                        '&amp;',                        
                            ('privacy_visibility', '=', 'followers'),                        
                            ('message_follower_ids', 'in', [user.partner_id.id])            
            </field>            
            <field name="groups" eval="[(4, ref('base.group_permission'))]"/>        
        </record>        
        <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'))]"/>        
        </record>    
    </data>
</openerp>

And this is my .csv: 

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_permission_project_public,permission.project,project.model_project_project,base.group_public,1,0,0,0
access_permission_task_public,permission.task,project.model_project_task,base.group_public,1,0,0,0

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

Celia
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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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