79
88
ids = ",".join(map(str, ids_project))
82
cr.execute('select count(t.id), p.id, p.name , sum(t.remaining_hours) as hours from project_project as p left join project_task as t on p.id=t.project_id \
91
cr.execute('select count(t.id), p.id, p.name , sum(t.remaining_hours) as hours \
92
from project_project as p left join project_task as t on p.id=t.project_id \
83
93
where p.id in ('+ids+') and t.state=%s group by p.id, p.name', ('open',))
84
94
for proj in cr.dictfetchall():
85
result[proj['id']]['tasks'] = str(proj['count']) + ' opens, ' + str(proj['hours']) + ' remaining'
95
result[proj['id']]['tasks'] = str(proj['count']) + ' opens, ' + str(proj['hours']) + ' hours remaining'
87
97
#======================================Bug, Features ,support request====================================================
88
cr.execute('select p.id, count(c.id), p.name from project_project as p, crm_case as c where p.id=c.project_id and p.section_bug_id=c.section_id \
89
and p.id in ('+ids+') group by p.id,p.name')
90
for bug in cr.dictfetchall():
91
result[bug['id']]['bugs'] = str(bug['count']) + ' Total '
92
cr.execute('select p.id, count(c.id),c.state,p.name from project_project as p, crm_case as c where p.id=c.project_id and p.section_bug_id=c.section_id \
93
and p.id in ('+ids+') and c.state=%s group by p.id,p.name,c.state', ('open',))
98
cr.execute('select p.id, count(c.id),c.state,p.name from project_project as p, \
99
crm_case as c, project_task as t where t.case_id=c.id and p.id=t.project_id \
100
and p.section_bug_id=c.section_id and p.id in ('+ids+') and c.state=%s \
101
group by p.id,p.name,c.state', ('open',))
94
102
res_bug = cr.dictfetchall()
95
103
for bug in res_bug:
96
result[bug['id']]['bugs'] = result[bug['id']]['bugs'] + str(bug['count']) + ' open'
104
result[bug['id']]['bugs'] = result[bug['id']]['bugs'] + str(bug['count']) + ' Open '
105
cr.execute('select p.id, count(c.id), p.name from project_project as p, \
106
crm_case as c, project_task as t where t.case_id=c.id \
107
and p.id=t.project_id and p.section_bug_id=c.section_id \
108
and p.id in ('+ids+') group by p.id,p.name')
109
for bug in cr.dictfetchall():
110
result[bug['id']]['bugs'] = result[bug['id']]['bugs'] + str(bug['count']) + ' Total'
98
cr.execute('select p.id, count(c.id), p.name from project_project as p, crm_case as c where p.id=c.project_id and p.section_feature_id=c.section_id \
99
and p.id in ('+ids+') group by p.id,p.name')
100
for feature in cr.dictfetchall():
101
result[feature['id']]['features'] = str(feature['count']) + ' Total '
102
cr.execute('select p.id, count(c.id),c.state,p.name from project_project as p, crm_case as c where p.id=c.project_id and p.section_feature_id=c.section_id \
112
cr.execute('select p.id, count(c.id),c.state,p.name from project_project as p, \
113
crm_case as c, project_task as t where t.case_id=c.id \
114
and p.id=t.project_id and p.section_feature_id=c.section_id \
103
115
and p.id in ('+ids+') and c.state=%s group by p.id,p.name,c.state', ('open',))
104
116
res_fet = cr.dictfetchall()
105
117
for feature in res_fet:
106
result[feature['id']]['features'] = result[feature['id']]['features'] + str(feature['count']) + ' open'
118
result[feature['id']]['features'] = result[feature['id']]['features'] + str(feature['count']) + ' Open '
119
cr.execute('select p.id, count(c.id), p.name from project_project as p, \
120
crm_case as c, project_task as t where t.case_id=c.id \
121
and p.id=t.project_id and p.section_feature_id=c.section_id \
122
and p.id in ('+ids+') group by p.id,p.name')
123
for feature in cr.dictfetchall():
124
result[feature['id']]['features'] = result[feature['id']]['features'] + str(feature['count']) + ' Total'
108
cr.execute('select p.id, count(c.id), p.name from project_project as p, crm_case as c where p.id=c.project_id and p.section_support_id=c.section_id \
109
and p.id in ('+ids+') group by p.id,p.name')
110
for support in cr.dictfetchall():
111
result[support['id']]['support_req'] = str(support['count']) + ' Total '
112
cr.execute('select p.id, count(c.id),c.state,p.name from project_project as p, crm_case as c where p.id=c.project_id and p.section_support_id=c.section_id \
126
cr.execute('select p.id, count(c.id),c.state,p.name from project_project as p, \
127
crm_case as c, project_task as t where t.case_id=c.id \
128
and p.id=t.project_id and p.section_support_id=c.section_id \
113
129
and p.id in ('+ids+') and c.state=%s group by p.id,p.name,c.state', ('open',))
114
130
res_sup = cr.dictfetchall()
115
131
for support in res_sup:
116
result[support['id']]['support_req'] = result[support['id']]['support_req'] + str(support['count']) + ' open'
132
result[support['id']]['support_req'] = result[support['id']]['support_req'] + str(support['count']) + ' Open '
133
cr.execute('select p.id, count(c.id), p.name from project_project as p, \
134
crm_case as c, project_task as t where t.case_id=c.id \
135
and p.id=t.project_id and p.section_support_id=c.section_id \
136
and p.id in ('+ids+') group by p.id,p.name')
137
for support in cr.dictfetchall():
138
result[support['id']]['support_req'] = result[support['id']]['support_req'] + str(support['count']) + ' Total'
117
140
#==========================================================================================
119
142
# Number of doument attach in project and its tasks
217
244
'project_id': fields.many2one('project.project', 'Project')
247
def write(self, cr, uid, ids, vals, context={}):
248
wiki = self.browse(cr, uid, ids[0])
249
res = super(Wiki, self).write(cr, uid, ids, vals, context={})
251
task_data = self.browse(cr, uid, ids[0], context)
252
desc = '''Hello,\n\n The wiki information is updated for the project: %s\n\nModified Datas are:\n''' %(str(wiki.project_id.name),)
254
if val.endswith('id') or val.endswith('ids'):
256
desc += '========\n' +val + ':' + str(vals[val]) + "\n"
257
desc += '\nThanks,\n' + 'Project Manager\n' + (task_data.project_id.manager and task_data.project_id.manager.name) or ''
258
self.pool.get('project.project')._log_event(cr, uid, wiki.project_id.id, {
260
'name' : wiki.name or '',
261
'description' : desc,
221
269
class crm_case(osv.osv):
222
270
_inherit = 'crm.case'
224
def _get_latest_cases(self, cr, uid, ids_cases, context={}, *arg):
272
def _get_latest_cases(self, cr, uid, ids_cases, name, args, context={}):
225
273
if not ids_cases:
233
281
'announce_ids': '',
284
date_back = datetime.date.today() + datetime.timedelta(days=-31)
285
date_back = date_back.strftime('%Y-%m-%d')
287
if context.has_key('project_id') and context['project_id']:
288
project_id = context['project_id']
290
project_ids = self.pool.get('project.project').search(cr, uid, [('manager', '=', uid)])
291
project_id = project_ids and project_ids[0]
236
293
for case in self.browse(cr, uid, ids_cases, context):
237
294
cr.execute("""select c.id from crm_case c \
238
left join project_project p on p.id = c.project_id \
239
where c.section_id = p.section_bug_id and c.date >= %s """, (time.strftime('%Y-%m-01'),))
295
left join project_task t on c.id=t.case_id left join project_project p on p.id = t.project_id \
296
where c.section_id = p.section_bug_id and c.date >= %s and p.id=%s """, (date_back,project_id,))
240
297
list_case = map(lambda x: x[0], cr.fetchall())
241
298
result[case.id]['bug_ids'] = list_case
243
300
cr.execute("""select c.id from crm_case c \
244
left join project_project p on p.id = c.project_id \
245
where c.section_id = p.section_feature_id and c.date >= %s """, (time.strftime('%Y-%m-01'),))
301
left join project_task t on c.id=t.case_id left join project_project p on p.id = t.project_id \
302
where c.section_id = p.section_feature_id and c.date >= %s and p.id=%s """, (date_back, project_id,))
246
303
list_case = map(lambda x: x[0], cr.fetchall())
247
304
result[case.id]['feature_ids'] = list_case
249
306
cr.execute("""select c.id from crm_case c \
250
left join project_project p on p.id = c.project_id \
251
where c.section_id = p.section_support_id and c.date >= %s """, (time.strftime('%Y-%m-01'),))
307
left join project_task t on c.id=t.case_id left join project_project p on p.id = t.project_id \
308
where c.section_id = p.section_support_id and c.date >= %s and p.id=%s """, (date_back, project_id,))
252
309
list_case = map(lambda x: x[0], cr.fetchall())
253
310
result[case.id]['support_ids'] = list_case
255
312
cr.execute("""select c.id from crm_case c \
256
left join project_project p on p.id = c.project_id \
257
where c.section_id = p.section_annouce_id and c.date >= %s """, (time.strftime('%Y-%m-01'),))
313
left join project_task t on c.id=t.case_id left join project_project p on p.id = t.project_id \
314
where c.section_id = p.section_annouce_id and c.date >= %s and p.id=%s """, (date_back, project_id,))
258
315
list_case = map(lambda x: x[0], cr.fetchall())
259
316
result[case.id]['announce_ids'] = list_case
263
'project_id' : fields.many2one('project.project', 'Project'),
264
320
'bug_ids' : fields.function(_get_latest_cases,type='one2many', relation='crm.case', method=True , string= 'Latest Bugs', multi='case'),
265
321
'feature_ids' : fields.function(_get_latest_cases,type='one2many', relation='crm.case', method=True , string='Latest Features', multi='case'),
266
322
'support_ids' : fields.function(_get_latest_cases,type='one2many', relation='crm.case', method=True , string='Latest Supports', multi='case'),
270
326
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
271
327
if context is None:
329
if context.has_key('project_id') and context['project_id']:
330
project_id = context['project_id']
332
project_ids = self.pool.get('project.project').search(cr, uid, [('manager', '=', uid)])
333
project_id = project_ids and project_ids[0]
273
335
if context.has_key('section') and context['section']=='Bug Tracking' or context.has_key('case_search') and context['case_search']=='bug':
274
cr.execute('select c.id from crm_case c left join project_project p on p.id=c.project_id where c.section_id=p.section_bug_id')
336
cr.execute('select c.id from crm_case c left join project_task t on c.id=t.case_id left join project_project p on p.id=t.project_id where c.section_id=p.section_bug_id and p.id=%s',(project_id,))
275
337
return map(lambda x: x[0], cr.fetchall())
276
338
elif context.has_key('section') and context['section']=='Feature' or context.has_key('case_search') and context['case_search']=='feature':
277
cr.execute('select c.id from crm_case c left join project_project p on p.id=c.project_id where c.section_id=p.section_feature_id')
339
cr.execute('select c.id from crm_case c left join project_task t on c.id=t.case_id left join project_project p on p.id=t.project_id where c.section_id=p.section_feature_id and p.id=%s',(project_id,))
278
340
return map(lambda x: x[0], cr.fetchall())
279
341
elif context.has_key('section') and context['section']=='Support' or context.has_key('case_search') and context['case_search']=='support':
280
cr.execute('select c.id from crm_case c left join project_project p on p.id=c.project_id where c.section_id=p.section_support_id')
342
cr.execute('select c.id from crm_case c left join project_task t on c.id=t.case_id left join project_project p on p.id=t.project_id where c.section_id=p.section_support_id and p.id=%s',(project_id,))
281
343
return map(lambda x: x[0], cr.fetchall())
282
344
elif context.has_key('section') and context['section']=='Announce' or context.has_key('case_search') and context['case_search']=='announce':
283
cr.execute('select c.id from crm_case c left join project_project p on p.id=c.project_id where c.section_id=p.section_annouce_id')
345
cr.execute('select c.id from crm_case c left join project_task t on c.id=t.case_id left join project_project p on p.id=t.project_id where c.section_id=p.section_annouce_id and p.id=%s',(project_id,))
284
346
return map(lambda x: x[0], cr.fetchall())
285
347
return super(crm_case, self).search(cr, uid, args, offset, limit, order, context, count)
287
def create(self, cr, uid, values, *args, **kwargs):
349
def create(self, cr, uid, values, *args, **kwargs): # to be check
288
350
case_id = super(crm_case, self).create(cr, uid, values, *args, **kwargs)
290
case = self.browse(cr, uid, case_id)
292
self.pool.get('project.project')._log_event(cr, uid, case.project_id.id, {
295
'description' : case.description,
352
# case = self.browse(cr, uid, case_id)
353
# if case.project_id:
354
# self.pool.get('project.project')._log_event(cr, uid, case.project_id.id, {
355
# 'res_id' : case.id,
356
# 'name' : case.name,
357
# 'description' : case.description,
359
# 'action' : 'create',
301
def write(self, cr, uid, ids, vals, context={}):
363
def write(self, cr, uid, ids, vals, context={}): # to be check
302
364
res = super(crm_case, self).write(cr, uid, ids, vals, context={})
304
cases = self.browse(cr, uid, ids)
307
self.pool.get('project.project')._log_event(cr, uid, case.project_id.id, {
310
'description' : case.description,
366
# cases = self.browse(cr, uid, ids)
368
# if case.project_id:
369
# self.pool.get('project.project')._log_event(cr, uid, case.project_id.id, {
370
# 'res_id' : case.id,
371
# 'name' : case.name,
372
# 'description' : case.description,
374
# 'action' : 'write',
375
437
'section_id' : fields.many2one('crm.case.section', 'Section', required=False)
440
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
443
if context.has_key('bugs_user') and context['bugs_user']=='bug_form' and context.has_key('project_id') and context['project_id']:
444
cr.execute('select id from report_crm_case_bugs where project_id=%s',(context['project_id']))
445
return map(lambda x: x[0], cr.fetchall())
446
return super(report_crm_case_bugs, self).search(cr, uid, args, offset, limit, order, context, count)
378
448
def init(self, cr):
380
450
create or replace view report_crm_case_bugs as (
384
c.project_id as project_id,
454
t.project_id as project_id,
385
455
c.section_id as section_id,
389
crm_case c left join project_project p on p.id = c.project_id
459
crm_case c left join project_task t on t.case_id = c.id
460
left join project_project p on p.id = t.project_id
390
461
where c.section_id = p.section_bug_id
391
group by c.user_id, c.project_id, c.section_id, c.state
462
group by c.user_id, t.project_id, c.section_id, c.state
394
466
report_crm_case_bugs()
396
468
class report_crm_case_features_user(osv.osv):
402
474
'nbr': fields.integer('# of Cases', readonly=True),
403
475
'user_id': fields.many2one('res.users', 'User', size=16, readonly=True),
476
'project_id': fields.many2one('project.project', 'Project')
479
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
482
if context.has_key('project_id') and context['project_id']:
483
cr.execute('select id from report_crm_case_features_user where project_id=%s',(context['project_id']))
484
return map(lambda x: x[0], cr.fetchall())
485
return super(report_crm_case_features_user, self).search(cr, uid, args, offset, limit, order, context, count)
405
488
def init(self, cr):
407
490
create or replace view report_crm_case_features_user as (
413
crm_case c left join project_project p on p.id = c.project_id
497
crm_case c left join project_task t on t.case_id=c.id
498
left join project_project p on p.id = t.project_id
414
499
where c.section_id = p.section_feature_id
415
group by c.user_id, c.name
500
group by c.user_id, c.name, p.id
418
504
report_crm_case_features_user()
420
506
class report_crm_case_support_user(osv.osv):
426
512
'nbr': fields.integer('# of Cases', readonly=True),
427
513
'user_id': fields.many2one('res.users', 'User', size=16, readonly=True),
514
'project_id': fields.many2one('project.project', 'Project')
517
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
520
if context.has_key('project_id') and context['project_id']:
521
cr.execute('select id from report_crm_case_support_user where project_id=%s',(context['project_id']))
522
return map(lambda x: x[0], cr.fetchall())
523
return super(report_crm_case_support_user, self).search(cr, uid, args, offset, limit, order, context, count)
429
525
def init(self, cr):
431
527
create or replace view report_crm_case_support_user as (
437
crm_case c left join project_project p on p.id = c.project_id
534
crm_case c left join project_task t on c.id=t.case_id
535
left join project_project p on p.id = t.project_id
438
536
where c.section_id = p.section_support_id
439
group by c.user_id, c.name
537
group by c.user_id, c.name, p.id
442
541
report_crm_case_support_user()
444
543
class report_crm_case_announce_user(osv.osv):
450
549
'name': fields.char('Description',size=64,required=True),
451
550
'nbr': fields.integer('# of Cases', readonly=True),
452
551
'user_id': fields.many2one('res.users', 'User', size=16, readonly=True),
552
'project_id': fields.many2one('project.project', 'Project')
555
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
558
if context.has_key('project_id') and context['project_id']:
559
cr.execute('select id from report_crm_case_announce_user where project_id=%s',(context['project_id']))
560
return map(lambda x: x[0], cr.fetchall())
561
return super(report_crm_case_announce_user, self).search(cr, uid, args, offset, limit, order, context, count)
454
563
def init(self, cr):
456
565
create or replace view report_crm_case_announce_user as (