[MERGE] Merge with dev-addons3 branch
[odoo/odoo.git] / addons / scrum / scrum.py
index b734473..f76545d 100644 (file)
@@ -106,7 +106,7 @@ class scrum_sprint(osv.osv):
         'name' : fields.char('Sprint Name', required=True, size=64),
         'date_start': fields.date('Starting Date', required=True),
         'date_stop': fields.date('Ending Date', required=True),
-        '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."),
+        'project_id': fields.many2one('project.project', 'Project', required=True, help="If you have [?] in the project name, it means there are no analytic account linked to this project."),
         'product_owner_id': fields.many2one('res.users', 'Product Owner', required=True,help="The person who is responsible for the product"),
         'scrum_master_id': fields.many2one('res.users', 'Scrum Manager', required=True,help="The person who is maintains the processes for the product"),
         'meeting_ids': fields.one2many('scrum.meeting', 'sprint_id', 'Daily Scrum'),
@@ -236,7 +236,7 @@ class scrum_product_backlog(osv.osv):
         'name' : fields.char('Feature', size=64, required=True),
         'note' : fields.text('Note'),
         'active' : fields.boolean('Active', help="If Active field is set to true, it will allow you to hide the product backlog without removing it."),
-        '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."),
+        'project_id': fields.many2one('project.project', 'Project', required=True, help="If you have [?] in the project name, it means there are no analytic account linked to this project."),
         'user_id': fields.many2one('res.users', 'Responsible'),
         'sprint_id': fields.many2one('scrum.sprint', 'Sprint'),
         'sequence' : fields.integer('Sequence', help="Gives the sequence order when displaying a list of product backlog."),
@@ -305,23 +305,31 @@ class scrum_meeting(osv.osv):
     }
 
     def button_send_to_master(self, cr, uid, ids, context=None):
+        if context is None:
+            context = {}
         meeting_id = self.browse(cr, uid, ids)[0]
-        user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
-        if meeting_id and meeting_id.sprint_id.scrum_master_id.user_email:
-            self.email_send(cr, uid, ids, email)
+        email = meeting_id.sprint_id.scrum_master_id.user_email
+        if email:
+            self.email_send(cr, uid, ids, email, context=context)
         else:
             raise osv.except_osv(_('Error !'), _('Please provide email address for scrum master defined on sprint.'))
         return True
 
     def button_send_product_owner(self, cr, uid, ids, context=None):
+        if context is None:
+            context = {}
+        context.update({'button_send_product_owner': True})
         meeting_id = self.browse(cr, uid, ids)[0]
-        if meeting_id.sprint_id.product_owner_id.user_email:
-            self.email_send(cr,uid,ids,email)
+        email = meeting_id.sprint_id.product_owner_id.user_email
+        if email:
+            self.email_send(cr, uid, ids, email, context=context)
         else:
             raise osv.except_osv(_('Error !'), _('Please provide email address for product owner defined on sprint.'))
         return True
 
     def email_send(self, cr, uid, ids, email, context=None):
+        if context is None:
+            context = {}
         email_from = tools.config.get('email_from', False)
         meeting_id = self.browse(cr,uid,ids)[0]
         user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
@@ -332,7 +340,12 @@ class scrum_meeting(osv.osv):
         sub_name = meeting_id.name or 'Scrum Meeting of %s '%meeting_id.date
         flag = tools.email_send(user_email , [email], sub_name, body, reply_to=None, openobject_id=str(meeting_id.id))
         if not flag:
-            raise osv.except_osv(_('Error !'), _(' Email Not send to %s!' % meeting_id.sprint_id.product_owner_id.name))
+            if context.get('button_send_product_owner', False):
+                raise osv.except_osv(_('Error !'), _(' Email Not send to the product owner %s!' % meeting_id.sprint_id.product_owner_id.name))
+            raise osv.except_osv(_('Error !'), _(' Email Not send to the scrum master %s!' % meeting_id.sprint_id.scrum_master_id.name))
+        if context.get('button_send_product_owner', False):
+            raise osv.except_osv(_('Information !'), _(' Email send successfully to product owner %s!' % meeting_id.sprint_id.product_owner_id.name))
+        raise osv.except_osv(_('Information!'), _(' Email send successfully to scrum master %s!'% meeting_id.sprint_id.scrum_master_id.name))
         return True
 
 scrum_meeting()