1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
24 from mx.DateTime import now
28 bts_form = """<?xml version="1.0" ?>
29 <form string="Assign Sprint">
31 <field name="sprint_id" colspan="2"/>
34 <separator colspan="2"/>
37 <field name="state_open" colspan="1"/>
38 <field name="convert_to_task" colspan="1"/>
43 'sprint_id' : {'string':'Sprint Name', 'type':'many2one', 'relation':'scrum.sprint', 'required':True},
44 'state_open' : {'string':'Set Open', 'type':'boolean'},
45 'convert_to_task' : {'string':'Convert To Task', 'type':'boolean'}
48 def _assign_sprint(self, cr, uid, data, context):
49 pool = pooler.get_pool(cr.dbname)
50 backlog_obj = pool.get('scrum.product.backlog')
51 task = pool.get('project.task')
53 state_open=data['form']['state_open']
54 convert_to_task = data['form']['convert_to_task']
56 for backlog in backlog_obj.browse(cr, uid, data['ids']):
57 backlog_obj.write(cr, uid, backlog.id, {'sprint_id':data['form']['sprint_id']})
59 task.create(cr, uid, {
60 'product_backlog_id': backlog.id,
62 'description': backlog.note,
63 'project_id': backlog.project_id.id,
64 'user_id': (backlog.user_id and backlog.user_id.id) or uid,
65 'planned_hours': backlog.planned_hours
68 if backlog.state == "draft":
69 backlog_obj.write(cr, uid, backlog.id, {'state':'open'})
72 class wiz_bts(wizard.interface):
76 'result': {'type':'form', 'arch':bts_form, 'fields':bts_fields, 'state':[('end', 'Cancel'), ('assign', 'Assign Sprint')] },
80 'result': {'type':'action', 'action': _assign_sprint, 'state':'end'},
83 wiz_bts('scrum.product.backlog.sprint.assign')
86 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: