~pedro.baeza/project-service/7.0-project_service_profiling-fix

« back to all changes in this revision

Viewing changes to project_issue_baseuser/project_issue.py

  • Committer: Joel Grand-Guillaume
  • Author(s): Daniel Reis
  • Date: 2014-01-17 14:41:38 UTC
  • mfrom: (27.1.3 7.0-baseuser-dr)
  • Revision ID: joel.grandguillaume@camptocamp.com-20140117144138-scsgfu03ccq58m3v
[MRG] Added new features: Extend Project user roles to support more complex use cases. Regular 'Employees' can create Tasks or Issues, but have read-only access when they are initiated. Projects can be private to a particular Manager and Team (Project Manager no longer sees everything from everyone)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    Copyright (C) 2013 Daniel Reis
 
5
#
 
6
#    This program is free software: you can redistribute it and/or modify
 
7
#    it under the terms of the GNU Affero General Public License as
 
8
#    published by the Free Software Foundation, either version 3 of the
 
9
#    License, or (at your option) any later version.
 
10
#
 
11
#    This program is distributed in the hope that it will be useful,
 
12
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
#    GNU Affero General Public License for more details.
 
15
#
 
16
#    You should have received a copy of the GNU Affero General Public License
 
17
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
#
 
19
##############################################################################
 
20
 
 
21
from openerp.osv import orm
 
22
 
 
23
 
 
24
# Backport from trunk(v8) fix required. See Bug#1243628.
 
25
class ProjectIssue(orm.Model):
 
26
    _inherit = 'project.issue'
 
27
 
 
28
    def _get_default_partner(self, cr, uid, context=None):
 
29
        """
 
30
        If no other deafult is found, the current user is automatically
 
31
        added as the Contact for the issue.
 
32
        """
 
33
        res = super(ProjectIssue, self
 
34
                    )._get_default_partner(cr, uid, context=context)
 
35
        if not res:
 
36
            user = self.pool.get('res.users'
 
37
                                 ).browse(cr, uid, uid, context=context)
 
38
            res = user.partner_id and user.partner_id.id
 
39
        return res
 
40
 
 
41
    _defaults = {
 
42
        'partner_id': lambda s, cr, uid, c: s._get_default_partner(cr, uid, c),
 
43
    }