[IMP] project_issue: Conver to task button now with type=object

[REM] project_issue: Remove wizard folder and its files
[REM] project_issu: Remove menu file for feature request

bzr revid: mra@tinyerp.com-20100408051022-vv1vx6fq1xodcj44
This commit is contained in:
mra (Open ERP) 2010-04-08 10:40:22 +05:30
parent c691539f33
commit 95b5abcf20
8 changed files with 66 additions and 157 deletions

View File

@ -20,7 +20,6 @@
#
##############################################################################
import project_issue
import report
import wizard

View File

@ -39,10 +39,8 @@
'project_issue_data.xml'
],
'update_xml': [
'project_issue_wizard.xml',
'project_issue_view.xml',
'project_issue_menu.xml',
'project_feature_menu.xml',
'project_issue_menu.xml',
'report/project_issue_report_view.xml',
'security/project_issue_security.xml',
'security/ir.model.access.csv',

View File

@ -1,7 +0,0 @@
<?xml version="1.0"?>
<openerp>
<data noupdate="1">
</data>
</openerp>

View File

@ -23,11 +23,11 @@ import base64
import os
import re
import time
import time
import tools
from crm import crm
import mx.DateTime
from datetime import datetime, timedelta
import tools
from crm import crm
from osv import fields,osv,orm
from osv.orm import except_orm
from tools.translate import _
@ -58,9 +58,9 @@ class project_issue(osv.osv):
@param ids: List of Opendays IDs
@return: difference between current date and log date
@param context: A standard dictionary for contextual values
"""
cal_obj = self.pool.get('resource.calendar')
res_obj = self.pool.get('resource.resource')
"""
cal_obj = self.pool.get('resource.calendar')
res_obj = self.pool.get('resource.resource')
res = {}
for issue in self.browse(cr, uid, ids , context):
@ -88,7 +88,7 @@ class project_issue(osv.osv):
duration = float(ans.days)
if issue.section_id.resource_calendar_id:
duration = float(ans.days) * 24
duration = float(ans.days) * 24
new_dates = cal_obj.interval_get(cr,
uid,
issue.section_id.resource_calendar_id and issue.section_id.resource_calendar_id.id or False,
@ -100,9 +100,9 @@ class project_issue(osv.osv):
date_until = mx.DateTime.strptime(date_until, '%Y-%m-%d %H:%M:%S')
for in_time, out_time in new_dates:
if in_time.date not in no_days:
no_days.append(in_time.date)
no_days.append(in_time.date)
if out_time > date_until:
break
break
duration = len(no_days)
res[issue.id][field] = abs(int(duration))
return res
@ -140,6 +140,60 @@ class project_issue(osv.osv):
return user.context_project_id
return False
def convert_issue_task(self, cr, uid, ids, context=None):
case_obj = self.pool.get('project.issue')
data_obj = self.pool.get('ir.model.data')
task_obj = self.pool.get('project.task')
if context is None:
context = {}
for case in case_obj.browse(cr, uid, ids, context=context):
if case.state != 'open':
raise osv.except_osv(_('Warning !'),
_('Issues or Feature Requests should be in \'Open\' state before converting into Task.'))
result = data_obj._get_id(cr, uid, 'project', 'view_task_search_form')
res = data_obj.read(cr, uid, result, ['res_id'])
id2 = data_obj._get_id(cr, uid, 'project', 'view_task_form2')
id3 = data_obj._get_id(cr, uid, 'project', 'view_task_tree2')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
if id3:
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
for bug in case_obj.browse(cr, uid, ids, context=context):
new_task_id = task_obj.create(cr, uid, {
'name': bug.name,
'partner_id': bug.partner_id.id,
'description':bug.description,
'date': bug.date,
'project_id':bug.project_id.id,
'priority':bug.priority,
'user_id':bug.user_id.id,
'planned_hours': 0.0,
})
new_task = task_obj.browse(cr, uid, new_task_id)
vals = {
'task_id': new_task_id,
}
case_obj.write(cr, uid, [bug.id], vals)
return {
'name': _('Tasks'),
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'project.task',
'res_id': int(new_task_id),
'view_id': False,
'views': [(id2,'form'),(id3,'tree'),(False,'calendar'),(False,'graph')],
'type': 'ir.actions.act_window',
'search_view_id': res['res_id'],
'nodestroy': True
}
def _convert(self, cr, uid, ids, xml_id, context=None):
data_obj = self.pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'project_issue', xml_id)

View File

@ -54,8 +54,8 @@
<field name="priority" colspan="3"/>
<field name="task_id" />
<button string="Convert To Task"
name="%(wizard_project_issue_task_set)d"
icon="gtk-index" type="action"
name="convert_issue_task"
icon="gtk-index" type="object"
attrs="{'invisible':[('task_id','!=',False)]}" />
</group>
<separator string= "Description" colspan="4"/>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard
id="wizard_project_issue_task_set"
keyword="client_action_multi"
model="project.issue"
name="project.issue.task_set"
multi="True"
string="Convert To Task"/>
</data>
</openerp>

View File

@ -1,25 +0,0 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import project_issue_wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,98 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from mx.DateTime import now
import wizard
import netsvc
import ir
import pooler
from tools.translate import _
class issue2task(wizard.interface):
def _check_state(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
case_obj = pool.get('project.issue')
for case in case_obj.browse(cr, uid, data['ids']):
if case.state != 'open':
raise wizard.except_wizard(_('Warning !'),
_('Issues or Feature Requests should be in \'Open\' state before converting into Task.'))
return {}
def _makeTask(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
data_obj = pool.get('ir.model.data')
result = data_obj._get_id(cr, uid, 'project', 'view_task_search_form')
res = data_obj.read(cr, uid, result, ['res_id'])
id2 = data_obj._get_id(cr, uid, 'project', 'view_task_form2')
id3 = data_obj._get_id(cr, uid, 'project', 'view_task_tree2')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
if id3:
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
bug_case_obj = pool.get('project.issue')
task_obj = pool.get('project.task')
for bug in bug_case_obj.browse(cr, uid, data['ids']):
new_task_id = task_obj.create(cr, uid, {
'name': bug.name,
'partner_id': bug.partner_id.id,
'description':bug.description,
'date': bug.date,
'project_id':bug.project_id.id,
'priority':bug.priority,
'user_id':bug.user_id.id,
'planned_hours': 0.0,
})
new_task = task_obj.browse(cr, uid, new_task_id)
vals = {
'task_id': new_task_id,
}
bug_case_obj.write(cr, uid, [bug.id], vals)
value = {
'name': _('Tasks'),
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'project.task',
'res_id': int(new_task_id),
'view_id': False,
'views': [(id2,'form'),(id3,'tree'),(False,'calendar'),(False,'graph')],
'type': 'ir.actions.act_window',
'search_view_id': res['res_id']
}
return value
states = {
'init': {
'actions': [_check_state],
'result': {'type': 'action', 'action': _makeTask, 'state':'end' }
}
}
issue2task('project.issue.task_set')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: