2009-10-13 05:58:37 +00:00
# -*- coding: utf-8 -*-
2006-12-07 13:41:40 +00:00
##############################################################################
2010-04-16 13:34:26 +00:00
#
2009-10-14 11:15:34 +00:00
# OpenERP, Open Source Management Solution
2010-01-12 09:18:39 +00:00
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
2008-06-16 11:00:21 +00:00
#
2008-11-03 19:18:56 +00:00
# This program is free software: you can redistribute it and/or modify
2009-10-14 11:15:34 +00:00
# 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.
2006-12-07 13:41:40 +00:00
#
2008-11-03 19:18:56 +00:00
# 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
2009-10-14 11:15:34 +00:00
# GNU Affero General Public License for more details.
2006-12-07 13:41:40 +00:00
#
2009-10-14 11:15:34 +00:00
# You should have received a copy of the GNU Affero General Public License
2010-04-16 13:34:26 +00:00
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2006-12-07 13:41:40 +00:00
#
##############################################################################
2010-09-27 13:44:03 +00:00
from osv import fields , osv
from tools . translate import _
2006-12-07 13:41:40 +00:00
import re
2010-09-27 13:44:03 +00:00
import time
2010-06-02 10:58:32 +00:00
import tools
2010-09-30 14:41:19 +00:00
from datetime import datetime
from dateutil . relativedelta import relativedelta
2006-12-07 13:41:40 +00:00
2010-07-15 05:47:56 +00:00
class project_scrum_project ( osv . osv ) :
2008-07-22 15:11:28 +00:00
_inherit = ' project.project '
_columns = {
2010-06-08 12:34:12 +00:00
' product_owner_id ' : fields . many2one ( ' res.users ' , ' Product Owner ' , help = " The person who is responsible for the product " ) ,
' sprint_size ' : fields . integer ( ' Sprint Days ' , help = " Number of days allocated for sprint " ) ,
2010-02-23 07:38:48 +00:00
' scrum ' : fields . integer ( ' Is a Scrum Project ' ) ,
2008-07-22 15:11:28 +00:00
}
_defaults = {
2010-08-10 04:41:51 +00:00
' product_owner_id ' : lambda self , cr , uid , context = { } : uid ,
2010-05-05 10:11:11 +00:00
' sprint_size ' : 15 ,
' scrum ' : 1
2008-07-22 15:11:28 +00:00
}
2010-07-15 05:47:56 +00:00
project_scrum_project ( )
2006-12-07 13:41:40 +00:00
2010-07-15 05:47:56 +00:00
class project_scrum_sprint ( osv . osv ) :
_name = ' project.scrum.sprint '
_description = ' Project Scrum Sprint '
2010-11-15 07:00:33 +00:00
_order = ' date_start desc '
2010-08-27 15:04:44 +00:00
def _compute ( self , cr , uid , ids , fields , arg , context = None ) :
res = { } . fromkeys ( ids , 0.0 )
progress = { }
if not ids :
return res
2010-08-10 04:41:51 +00:00
if context is None :
context = { }
2010-08-27 15:04:44 +00:00
for sprint in self . browse ( cr , uid , ids , context = context ) :
2008-07-22 15:11:28 +00:00
tot = 0.0
prog = 0.0
2010-08-27 15:04:44 +00:00
effective = 0.0
progress = 0.0
2008-07-22 15:11:28 +00:00
for bl in sprint . backlog_ids :
2010-06-07 13:31:42 +00:00
tot + = bl . expected_hours
2010-08-27 15:04:44 +00:00
effective + = bl . effective_hours
2010-06-07 13:31:42 +00:00
prog + = bl . expected_hours * bl . progress / 100.0
2008-07-22 15:11:28 +00:00
if tot > 0 :
2010-08-27 15:04:44 +00:00
progress = round ( prog / tot * 100 )
res [ sprint . id ] = {
' progress ' : progress ,
' expected_hours ' : tot ,
' effective_hours ' : effective ,
}
2010-04-16 13:34:26 +00:00
return res
2010-05-28 12:04:47 +00:00
2010-08-10 04:41:51 +00:00
def button_cancel ( self , cr , uid , ids , context = None ) :
2010-02-24 16:28:53 +00:00
self . write ( cr , uid , ids , { ' state ' : ' cancel ' } , context = context )
return True
2010-05-28 12:04:47 +00:00
2010-08-10 04:41:51 +00:00
def button_draft ( self , cr , uid , ids , context = None ) :
2010-02-24 16:28:53 +00:00
self . write ( cr , uid , ids , { ' state ' : ' draft ' } , context = context )
return True
2010-05-28 12:04:47 +00:00
2010-08-10 04:41:51 +00:00
def button_open ( self , cr , uid , ids , context = None ) :
2010-02-24 16:28:53 +00:00
self . write ( cr , uid , ids , { ' state ' : ' open ' } , context = context )
2010-07-08 10:14:24 +00:00
for ( id , name ) in self . name_get ( cr , uid , ids ) :
2010-10-16 14:02:41 +00:00
message = _ ( " The sprint ' %s ' has been opened. " ) % ( name , )
2010-07-08 10:14:24 +00:00
self . log ( cr , uid , id , message )
2010-02-24 16:28:53 +00:00
return True
2010-05-28 12:04:47 +00:00
2010-08-10 04:41:51 +00:00
def button_close ( self , cr , uid , ids , context = None ) :
2010-02-24 16:28:53 +00:00
self . write ( cr , uid , ids , { ' state ' : ' done ' } , context = context )
2010-07-08 10:14:24 +00:00
for ( id , name ) in self . name_get ( cr , uid , ids ) :
2010-10-16 14:02:41 +00:00
message = _ ( " The sprint ' %s ' has been closed. " ) % ( name , )
2010-07-08 10:14:24 +00:00
self . log ( cr , uid , id , message )
2010-02-24 16:28:53 +00:00
return True
2010-05-28 12:04:47 +00:00
2010-08-10 04:41:51 +00:00
def button_pending ( self , cr , uid , ids , context = None ) :
2010-02-24 16:28:53 +00:00
self . write ( cr , uid , ids , { ' state ' : ' pending ' } , context = context )
return True
2010-05-28 12:04:47 +00:00
2008-07-22 15:11:28 +00:00
_columns = {
2008-09-10 09:31:28 +00:00
' name ' : fields . char ( ' Sprint Name ' , required = True , size = 64 ) ,
2008-07-22 15:11:28 +00:00
' date_start ' : fields . date ( ' Starting Date ' , required = True ) ,
' date_stop ' : fields . date ( ' Ending Date ' , required = True ) ,
2010-05-10 07:25:11 +00:00
' project_id ' : fields . many2one ( ' project.project ' , ' Project ' , required = True , domain = [ ( ' scrum ' , ' = ' , 1 ) ] , help = " If you have [?] in the project name, it means there are no analytic account linked to this project. " ) ,
2010-05-27 13:18:57 +00:00
' product_owner_id ' : fields . many2one ( ' res.users ' , ' Product Owner ' , required = True , help = " The person who is responsible for the product " ) ,
2011-06-06 06:34:46 +00:00
' scrum_master_id ' : fields . many2one ( ' res.users ' , ' Scrum Master ' , required = True , help = " The person who is maintains the processes for the product " ) ,
2010-07-15 05:47:56 +00:00
' meeting_ids ' : fields . one2many ( ' project.scrum.meeting ' , ' sprint_id ' , ' Daily Scrum ' ) ,
2008-07-22 15:11:28 +00:00
' review ' : fields . text ( ' Sprint Review ' ) ,
' retrospective ' : fields . text ( ' Sprint Retrospective ' ) ,
2010-07-15 05:47:56 +00:00
' backlog_ids ' : fields . one2many ( ' project.scrum.product.backlog ' , ' sprint_id ' , ' Sprint Backlog ' ) ,
2011-07-01 23:41:24 +00:00
' progress ' : fields . function ( _compute , group_operator = " avg " , type = ' float ' , multi = " progress " , string = ' Progress (0-100) ' , help = " Computed as: Time Spent / Total Time. " ) ,
' effective_hours ' : fields . function ( _compute , multi = " effective_hours " , string = ' Effective hours ' , help = " Computed using the sum of the task work done. " ) ,
' expected_hours ' : fields . function ( _compute , multi = " expected_hours " , string = ' Planned Hours ' , help = ' Estimated time to do the task. ' ) ,
2010-02-24 16:28:53 +00:00
' state ' : fields . selection ( [ ( ' draft ' , ' Draft ' ) , ( ' open ' , ' Open ' ) , ( ' pending ' , ' Pending ' ) , ( ' cancel ' , ' Cancelled ' ) , ( ' done ' , ' Done ' ) ] , ' State ' , required = True ) ,
2008-07-22 15:11:28 +00:00
}
_defaults = {
2010-05-05 10:11:11 +00:00
' state ' : ' draft ' ,
2010-11-02 11:29:09 +00:00
' date_start ' : lambda * a : time . strftime ( ' % Y- % m- %d ' ) ,
2008-07-22 15:11:28 +00:00
}
2010-05-05 10:11:11 +00:00
def copy ( self , cr , uid , id , default = None , context = None ) :
""" Overrides orm copy method
@param self : The object pointer
@param cr : the current row , from the database cursor ,
@param uid : the current user ’ s ID for security checks ,
@param ids : List of case ’ s IDs
@param context : A standard dictionary for contextual values
"""
if default is None :
default = { }
2010-05-14 10:18:29 +00:00
default . update ( { ' backlog_ids ' : [ ] , ' meeting_ids ' : [ ] } )
2010-09-21 06:33:50 +00:00
return super ( project_scrum_sprint , self ) . copy ( cr , uid , id , default = default , context = context )
2010-05-05 10:11:11 +00:00
2010-08-10 04:41:51 +00:00
def onchange_project_id ( self , cr , uid , ids , project_id = False ) :
2008-07-22 15:11:28 +00:00
v = { }
if project_id :
2010-02-23 07:38:48 +00:00
proj = self . pool . get ( ' project.project ' ) . browse ( cr , uid , [ project_id ] ) [ 0 ]
v [ ' product_owner_id ' ] = proj . product_owner_id and proj . product_owner_id . id or False
v [ ' scrum_master_id ' ] = proj . user_id and proj . user_id . id or False
2010-09-30 14:41:19 +00:00
v [ ' date_stop ' ] = ( datetime . now ( ) + relativedelta ( days = int ( proj . sprint_size or 14 ) ) ) . strftime ( ' % Y- % m- %d ' )
2008-07-22 15:11:28 +00:00
return { ' value ' : v }
2010-04-16 13:34:26 +00:00
2010-07-15 05:47:56 +00:00
project_scrum_sprint ( )
2006-12-07 13:41:40 +00:00
2010-07-15 05:47:56 +00:00
class project_scrum_product_backlog ( osv . osv ) :
_name = ' project.scrum.product.backlog '
2008-07-22 15:11:28 +00:00
_description = ' Product Backlog '
2006-12-07 13:41:40 +00:00
2009-12-09 11:43:34 +00:00
def name_search ( self , cr , uid , name , args = None , operator = ' ilike ' , context = None , limit = 100 ) :
2008-07-22 15:11:28 +00:00
if not args :
args = [ ]
2010-09-22 14:00:24 +00:00
if name :
match = re . match ( ' ^S \ (([0-9]+) \ )$ ' , name )
if match :
ids = self . search ( cr , uid , [ ( ' sprint_id ' , ' = ' , int ( match . group ( 1 ) ) ) ] , limit = limit , context = context )
return self . name_get ( cr , uid , ids , context = context )
2010-07-16 09:30:16 +00:00
return super ( project_scrum_product_backlog , self ) . name_search ( cr , uid , name , args , operator , context , limit = limit )
2006-12-07 13:41:40 +00:00
2010-08-27 15:04:44 +00:00
def _compute ( self , cr , uid , ids , fields , arg , context = None ) :
res = { } . fromkeys ( ids , 0.0 )
progress = { }
if not ids :
return res
for backlog in self . browse ( cr , uid , ids , context = context ) :
2008-07-22 15:11:28 +00:00
tot = 0.0
prog = 0.0
2010-08-27 15:04:44 +00:00
effective = 0.0
task_hours = 0.0
progress = 0.0
for task in backlog . tasks_id :
task_hours + = task . total_hours
effective + = task . effective_hours
2008-07-22 15:11:28 +00:00
tot + = task . planned_hours
prog + = task . planned_hours * task . progress / 100.0
if tot > 0 :
2010-08-27 15:04:44 +00:00
progress = round ( prog / tot * 100 )
res [ backlog . id ] = {
' progress ' : progress ,
' effective_hours ' : effective ,
' task_hours ' : task_hours
}
2008-07-22 15:11:28 +00:00
return res
2010-02-24 16:28:53 +00:00
2010-08-10 04:41:51 +00:00
def button_cancel ( self , cr , uid , ids , context = None ) :
2010-07-15 05:47:56 +00:00
obj_project_task = self . pool . get ( ' project.task ' )
2010-02-24 16:28:53 +00:00
self . write ( cr , uid , ids , { ' state ' : ' cancel ' } , context = context )
2010-04-16 13:34:26 +00:00
for backlog in self . browse ( cr , uid , ids , context = context ) :
2010-07-15 05:47:56 +00:00
obj_project_task . write ( cr , uid , [ i . id for i in backlog . tasks_id ] , { ' state ' : ' cancelled ' } )
2010-02-24 16:28:53 +00:00
return True
2010-05-28 12:04:47 +00:00
2010-08-10 04:41:51 +00:00
def button_draft ( self , cr , uid , ids , context = None ) :
2010-02-24 16:28:53 +00:00
self . write ( cr , uid , ids , { ' state ' : ' draft ' } , context = context )
return True
2010-05-28 12:04:47 +00:00
2010-08-10 04:41:51 +00:00
def button_open ( self , cr , uid , ids , context = None ) :
2010-02-24 16:28:53 +00:00
self . write ( cr , uid , ids , { ' state ' : ' open ' } , context = context )
return True
2010-05-28 12:04:47 +00:00
2010-08-10 04:41:51 +00:00
def button_close ( self , cr , uid , ids , context = None ) :
2010-07-15 05:47:56 +00:00
obj_project_task = self . pool . get ( ' project.task ' )
2010-02-24 16:28:53 +00:00
self . write ( cr , uid , ids , { ' state ' : ' done ' } , context = context )
2010-05-05 10:11:11 +00:00
for backlog in self . browse ( cr , uid , ids , context = context ) :
2010-07-15 05:47:56 +00:00
obj_project_task . write ( cr , uid , [ i . id for i in backlog . tasks_id ] , { ' state ' : ' done ' } )
2010-02-24 16:28:53 +00:00
return True
2010-05-28 12:04:47 +00:00
2010-08-10 04:41:51 +00:00
def button_pending ( self , cr , uid , ids , context = None ) :
2010-02-24 16:28:53 +00:00
self . write ( cr , uid , ids , { ' state ' : ' pending ' } , context = context )
return True
2010-06-08 09:01:04 +00:00
def button_postpone ( self , cr , uid , ids , context = None ) :
for product in self . browse ( cr , uid , ids , context = context ) :
tasks_id = [ ]
2010-06-02 13:11:32 +00:00
for task in product . tasks_id :
2010-06-08 09:01:04 +00:00
if task . state != ' done ' :
2010-06-02 13:11:32 +00:00
tasks_id . append ( task . id )
2010-06-08 09:01:04 +00:00
2010-06-02 13:11:32 +00:00
clone_id = self . copy ( cr , uid , product . id , {
2010-06-07 13:31:42 +00:00
' name ' : ' PARTIAL: ' + product . name ,
2010-06-02 13:11:32 +00:00
' sprint_id ' : False ,
' tasks_id ' : [ ( 6 , 0 , tasks_id ) ] ,
2010-06-08 09:01:04 +00:00
} )
2010-06-02 13:11:32 +00:00
self . write ( cr , uid , ids , { ' state ' : ' cancel ' } , context = context )
return True
2008-07-22 15:11:28 +00:00
_columns = {
2008-09-10 09:31:28 +00:00
' name ' : fields . char ( ' Feature ' , size = 64 , required = True ) ,
2008-07-22 15:11:28 +00:00
' note ' : fields . text ( ' Note ' ) ,
2010-05-03 08:30:24 +00:00
' active ' : fields . boolean ( ' Active ' , help = " If Active field is set to true, it will allow you to hide the product backlog without removing it. " ) ,
2010-09-29 15:07:02 +00:00
' project_id ' : fields . many2one ( ' project.project ' , ' Project ' , required = True , domain = [ ( ' scrum ' , ' = ' , 1 ) ] ) ,
2010-07-13 10:10:16 +00:00
' user_id ' : fields . many2one ( ' res.users ' , ' Author ' ) ,
2010-07-15 05:47:56 +00:00
' sprint_id ' : fields . many2one ( ' project.scrum.sprint ' , ' Sprint ' ) ,
2009-12-21 13:14:12 +00:00
' sequence ' : fields . integer ( ' Sequence ' , help = " Gives the sequence order when displaying a list of product backlog. " ) ,
2010-02-23 07:38:48 +00:00
' tasks_id ' : fields . one2many ( ' project.task ' , ' product_backlog_id ' , ' Tasks Details ' ) ,
2010-02-24 16:28:53 +00:00
' state ' : fields . selection ( [ ( ' draft ' , ' Draft ' ) , ( ' open ' , ' Open ' ) , ( ' pending ' , ' Pending ' ) , ( ' done ' , ' Done ' ) , ( ' cancel ' , ' Cancelled ' ) ] , ' State ' , required = True ) ,
2011-07-01 23:41:24 +00:00
' progress ' : fields . function ( _compute , multi = " progress " , group_operator = " avg " , type = ' float ' , string = ' Progress ' , help = " Computed as: Time Spent / Total Time. " ) ,
' effective_hours ' : fields . function ( _compute , multi = " effective_hours " , string = ' Spent Hours ' , help = " Computed using the sum of the time spent on every related tasks " , store = True ) ,
2010-06-07 13:31:42 +00:00
' expected_hours ' : fields . float ( ' Planned Hours ' , help = ' Estimated total time to do the Backlog ' ) ,
2010-05-28 12:04:47 +00:00
' create_date ' : fields . datetime ( " Creation Date " , readonly = True ) ,
2011-07-01 23:41:24 +00:00
' task_hours ' : fields . function ( _compute , multi = " task_hours " , string = ' Task Hours ' , help = ' Estimated time of the total hours of the tasks ' )
2008-07-22 15:11:28 +00:00
}
_defaults = {
2010-05-05 10:11:11 +00:00
' state ' : ' draft ' ,
' active ' : 1 ,
2010-05-06 12:55:54 +00:00
' user_id ' : lambda self , cr , uid , context : uid ,
2008-07-22 15:11:28 +00:00
}
2010-02-23 07:38:48 +00:00
_order = " sequence "
2010-07-15 05:47:56 +00:00
project_scrum_product_backlog ( )
2006-12-07 13:41:40 +00:00
2010-07-15 05:47:56 +00:00
class project_scrum_task ( osv . osv ) :
2010-02-26 13:42:56 +00:00
_name = ' project.task '
2008-07-22 15:11:28 +00:00
_inherit = ' project.task '
2010-05-28 12:04:47 +00:00
2010-08-10 04:41:51 +00:00
def _get_task ( self , cr , uid , ids , context = None ) :
2010-02-28 10:57:24 +00:00
result = { }
2010-07-15 05:47:56 +00:00
for line in self . pool . get ( ' project.scrum.product.backlog ' ) . browse ( cr , uid , ids , context = context ) :
2010-02-28 10:57:24 +00:00
for task in line . tasks_id :
result [ task . id ] = True
return result . keys ( )
2008-07-22 15:11:28 +00:00
_columns = {
2010-07-15 05:47:56 +00:00
' product_backlog_id ' : fields . many2one ( ' project.scrum.product.backlog ' , ' Product Backlog ' , help = " Related product backlog that contains this task. Used in SCRUM methodology " ) ,
' sprint_id ' : fields . related ( ' product_backlog_id ' , ' sprint_id ' , type = ' many2one ' , relation = ' project.scrum.sprint ' , string = ' Sprint ' ,
2010-02-28 10:57:24 +00:00
store = {
' project.task ' : ( lambda self , cr , uid , ids , c = { } : ids , [ ' product_backlog_id ' ] , 10 ) ,
2010-07-15 05:47:56 +00:00
' project.scrum.product.backlog ' : ( _get_task , [ ' sprint_id ' ] , 10 )
2010-02-28 10:57:24 +00:00
} ) ,
2008-07-22 15:11:28 +00:00
}
2010-05-28 12:04:47 +00:00
2010-08-10 04:41:51 +00:00
def onchange_backlog_id ( self , cr , uid , backlog_id = False ) :
2008-07-22 15:11:28 +00:00
if not backlog_id :
return { }
2010-07-15 05:47:56 +00:00
project_id = self . pool . get ( ' project.scrum.product.backlog ' ) . browse ( cr , uid , backlog_id ) . project_id . id
2008-07-22 15:11:28 +00:00
return { ' value ' : { ' project_id ' : project_id } }
2010-07-15 05:47:56 +00:00
project_scrum_task ( )
2006-12-07 13:41:40 +00:00
2010-07-15 05:47:56 +00:00
class project_scrum_meeting ( osv . osv ) :
_name = ' project.scrum.meeting '
2008-07-22 15:11:28 +00:00
_description = ' Scrum Meeting '
2010-05-03 07:20:35 +00:00
_order = ' date desc '
2008-07-22 15:11:28 +00:00
_columns = {
2010-05-05 10:11:11 +00:00
' name ' : fields . char ( ' Meeting Name ' , size = 64 ) ,
2008-07-22 15:11:28 +00:00
' date ' : fields . date ( ' Meeting Date ' , required = True ) ,
2010-07-15 05:47:56 +00:00
' sprint_id ' : fields . many2one ( ' project.scrum.sprint ' , ' Sprint ' , required = True ) ,
2010-04-16 13:34:26 +00:00
' project_id ' : fields . many2one ( ' project.project ' , ' Project ' ) ,
2008-07-22 15:11:28 +00:00
' question_yesterday ' : fields . text ( ' Tasks since yesterday ' ) ,
' question_today ' : fields . text ( ' Tasks for today ' ) ,
' question_blocks ' : fields . text ( ' Blocks encountered ' ) ,
' question_backlog ' : fields . text ( ' Backlog Accurate ' ) ,
2010-09-18 07:12:47 +00:00
' task_ids ' : fields . many2many ( ' project.task ' , ' meeting_task_rel ' , ' metting_id ' , ' task_id ' , ' Tasks ' ) ,
2010-10-12 14:50:30 +00:00
' user_id ' : fields . related ( ' sprint_id ' , ' scrum_master_id ' , type = ' many2one ' , relation = ' res.users ' , string = ' Scrum Master ' , readonly = True ) ,
2008-07-22 15:11:28 +00:00
}
#
2010-02-23 07:38:48 +00:00
# TODO: Find the right sprint thanks to users and date
2008-07-22 15:11:28 +00:00
#
_defaults = {
2011-03-04 05:57:08 +00:00
' date ' : lambda * a : time . strftime ( ' % Y- % m- %d ' ) ,
2008-07-22 15:11:28 +00:00
}
2010-06-02 10:58:32 +00:00
2010-06-08 09:01:04 +00:00
def button_send_to_master ( self , cr , uid , ids , context = None ) :
2010-11-19 13:48:01 +00:00
meeting_id = self . browse ( cr , uid , ids , context = context ) [ 0 ]
2010-06-08 09:01:04 +00:00
if meeting_id and meeting_id . sprint_id . scrum_master_id . user_email :
2010-07-02 08:21:48 +00:00
res = self . email_send ( cr , uid , ids , meeting_id . sprint_id . scrum_master_id . user_email )
if not res :
2010-11-19 12:20:03 +00:00
raise osv . except_osv ( _ ( ' Error ! ' ) , _ ( ' Email notification could not be sent to the scrum master %s ' ) % meeting_id . sprint_id . scrum_master_id . name )
2010-06-02 10:58:32 +00:00
else :
2010-06-08 09:01:04 +00:00
raise osv . except_osv ( _ ( ' Error ! ' ) , _ ( ' Please provide email address for scrum master defined on sprint. ' ) )
2010-06-02 10:58:32 +00:00
return True
2010-06-08 09:01:04 +00:00
def button_send_product_owner ( self , cr , uid , ids , context = None ) :
2010-06-22 08:41:42 +00:00
if context is None :
context = { }
context . update ( { ' button_send_product_owner ' : True } )
2010-11-19 13:48:01 +00:00
meeting_id = self . browse ( cr , uid , ids , context = context ) [ 0 ]
2010-06-08 09:01:04 +00:00
if meeting_id . sprint_id . product_owner_id . user_email :
2010-07-02 08:21:48 +00:00
res = self . email_send ( cr , uid , ids , meeting_id . sprint_id . product_owner_id . user_email )
if not res :
2010-11-19 12:20:03 +00:00
raise osv . except_osv ( _ ( ' Error ! ' ) , _ ( ' Email notification could not be sent to the product owner %s ' ) % meeting_id . sprint_id . product_owner_id . name )
2010-06-02 10:58:32 +00:00
else :
2010-06-08 09:01:04 +00:00
raise osv . except_osv ( _ ( ' Error ! ' ) , _ ( ' Please provide email address for product owner defined on sprint. ' ) )
2010-06-02 10:58:32 +00:00
return True
2010-06-08 09:01:04 +00:00
def email_send ( self , cr , uid , ids , email , context = None ) :
2010-11-22 10:37:53 +00:00
meeting_id = self . browse ( cr , uid , ids , context = context ) [ 0 ]
2010-06-02 10:58:32 +00:00
user = self . pool . get ( ' res.users ' ) . browse ( cr , uid , uid , context = context )
2011-06-06 06:21:51 +00:00
user_email = user . user_email or tools . config . get ( ' email_from ' , False )
2011-03-09 04:58:22 +00:00
body = _ ( " Hello %s , \n \n I am sending you Daily Meeting Details of date %s for the Sprint %s \n " ) % ( meeting_id . sprint_id . scrum_master_id . name , meeting_id . date , meeting_id . sprint_id . name )
2011-06-06 06:21:51 +00:00
body + = _ ( ' \n * Tasks since yesterday: \n _______________________ \n %s \n \n * Task for Today: \n _______________________ \n %s \n \n * Blocks encountered: \n _______________________ \n \n %s ' ) % ( meeting_id . question_yesterday , meeting_id . question_today , meeting_id . question_blocks or _ ( ' No Blocks ' ) )
2011-03-09 04:58:22 +00:00
body + = _ ( " \n \n Thank you, \n %s " ) % user . name
2010-11-19 12:20:03 +00:00
sub_name = meeting_id . name or _ ( ' Scrum Meeting of %s ' ) % meeting_id . date
2010-06-08 09:01:04 +00:00
flag = tools . email_send ( user_email , [ email ] , sub_name , body , reply_to = None , openobject_id = str ( meeting_id . id ) )
if not flag :
2010-07-02 08:21:48 +00:00
return False
2010-06-02 10:58:32 +00:00
return True
2010-06-08 09:01:04 +00:00
2010-07-15 05:47:56 +00:00
project_scrum_meeting ( )
2006-12-07 13:41:40 +00:00