2
# -*- encoding: utf-8 -*-
3
###########################################################################
4
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
7
# Credits######################################################
8
# Coded by: Humberto Arocha <hbto@vauxoo.com>
9
# Planified by: Rafael Silva <rsilvam@vauxoo.com>
10
# Audited by: Nhomar Hernandez <nhomar@vauxoo.com>
11
#############################################################################
12
# This program is free software: you can redistribute it and/or modify
13
# it under the terms of the GNU Affero General Public License as published
14
# by the Free Software Foundation, either version 3 of the License, or
15
# (at your option) any later version.
17
# This program is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU Affero General Public License for more details.
22
# You should have received a copy of the GNU Affero General Public License
23
# along with this program. If not, see <http://www.gnu.org/licenses/>.
24
##########################################################################
27
from openerp.osv import osv, fields
28
from openerp.tools.translate import _
31
class project_task(osv.Model):
32
_inherit = 'project.task'
34
def _get_issue(self, cr, uid, ids, fieldname, arg, context=None):
38
pi_obj = self.pool.get('project.issue')
41
pi_ids = pi_obj.search(cr, uid, [('task_id', '=', id)]) or []
42
res[id] = pi_ids and pi_ids[0] or None
46
def _get_task_in_issue(self, cr, uid, ids, context=None):
49
pi_obj = self.pool.get('project.issue')
50
return [pi_brw.task_id.id for pi_brw in pi_obj.browse(cr, uid, ids,
55
'issue_id': fields.function(
59
relation='project.issue',
60
string='Project issue',
62
'project.issue': (_get_task_in_issue, ['task_id'], 15),
63
'project.task': (lambda self, cr, uid, ids, c={}: ids, [], 45),
68
class project_task_work(osv.Model):
69
_inherit = 'project.task.work'
71
def _get_project(self, cr, uid, ids, fieldname, arg, context=None):
75
for ptw_brw in self.browse(cr, uid, ids, context=context):
79
(ptw_brw.task_id.issue_id and
80
ptw_brw.task_id.issue_id.project_id and
81
ptw_brw.task_id.issue_id.project_id.id
82
or ptw_brw.task_id.project_id and
83
ptw_brw.task_id.project_id.id)\
88
def _get_issue(self, cr, uid, ids, fieldname, arg, context=None):
92
pi_obj = self.pool.get('project.issue')
93
ptw_brws = self.browse(cr, uid, ids, context=context)
94
for ptw_brw in ptw_brws:
95
pi_ids = ptw_brw.task_id and pi_obj.search(cr, uid, [
97
ptw_brw.task_id.id)])\
100
res[ptw_brw.id] = pi_ids and pi_ids[0] or None
103
def _get_partner(self, cr, uid, ids, fieldname, arg, context=None):
107
for ptw_brw in self.browse(cr, uid, ids, context=context):
110
ptw_brw.task_id and \
111
(ptw_brw.task_id.issue_id and
112
ptw_brw.task_id.issue_id.partner_id and
113
ptw_brw.task_id.issue_id.partner_id.id
114
or ptw_brw.task_id.project_id and
115
ptw_brw.task_id.project_id.partner_id and
116
ptw_brw.task_id.project_id.partner_id.id
117
or ptw_brw.task_id.partner_id and
118
ptw_brw.task_id.partner_id.id
124
def _get_work_in_task(self, cr, uid, ids, context=None):
128
pt_obj = self.pool.get('project.task')
129
for pt_brw in pt_obj.browse(cr, uid, ids, context=context):
130
res += [work_brw.id for work_brw in pt_brw.work_ids]
131
return list(set(res))
133
def _get_work_in_issue(self, cr, uid, ids, context=None):
137
pi_obj = self.pool.get('project.issue')
138
pt_ids = [pi_brw.task_id.id for pi_brw in pi_obj.browse(
139
cr, uid, ids, context=context) if pi_brw.task_id]
140
return self.pool.get('project.task.work')._get_work_in_task(cr, uid,
145
'project_id': fields.function(
149
relation='project.project',
152
'project.issue': (_get_work_in_issue, ['task_id',
154
'project.task.work': (lambda self, cr, uid, ids, c={}: ids,
158
'state': fields.selection([('done', 'Collected'),
159
('draft', 'Uncollected'),
160
('cancel', 'Cancel'), ],
164
'issue_id': fields.function(
168
relation='project.issue',
169
string='Project Issue',
171
'project.issue': (_get_work_in_issue, [], 15),
172
'project.task': (_get_work_in_task, [], 30),
173
'project.task.work': (lambda self, cr, uid, ids, c={}: ids,
177
'partner_id': fields.function(
181
relation='res.partner',
184
'project.issue': (_get_work_in_issue, [], 15),
185
'project.task': (_get_work_in_task, [], 30),
186
'project.task.work': (lambda self, cr, uid, ids, c={}: ids,
190
'name': fields.text('Work summary'),