summaryrefslogtreecommitdiff
path: root/addons/project_issue/wizard/project_issue_wizard.py
diff options
context:
space:
mode:
authorHarry (Open ERP) <hmo@tinyerp.com>2010-03-05 18:55:30 +0530
committerHarry (Open ERP) <hmo@tinyerp.com>2010-03-05 18:55:30 +0530
commit6e0f534bf7ec100ae9c24ea42dbcfdd1d1fbe940 (patch)
tree389192922c20a21d2769814117bd40005e76b2d0 /addons/project_issue/wizard/project_issue_wizard.py
parent5ef680e14b219a8ff356fdc97a0b75627b4af89d (diff)
[RENAME] Renamed crm_project module with project_issue
bzr revid: hmo@tinyerp.com-20100305132530-1wrppksepbbkzads
Diffstat (limited to 'addons/project_issue/wizard/project_issue_wizard.py')
-rw-r--r--addons/project_issue/wizard/project_issue_wizard.py98
1 files changed, 98 insertions, 0 deletions
diff --git a/addons/project_issue/wizard/project_issue_wizard.py b/addons/project_issue/wizard/project_issue_wizard.py
new file mode 100644
index 00000000000..4aef1529619
--- /dev/null
+++ b/addons/project_issue/wizard/project_issue_wizard.py
@@ -0,0 +1,98 @@
+# -*- 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: