Example #1
0
 def _email_notify(self, cr, uid, ids, mail_type, context=None):
     mail_types = {'confirmed':{'action':'need your approval','groups':['metro_purchase.group_pur_req_checker']},
               'approved':{'action':'approved, please issue PO','groups':['metro_purchase.group_pur_req_buyer']},
               'rejected':{'action':'was rejected, please check','groups':[]},
               'in_purchase':{'action':'is in purchasing','groups':[],},
               'done':{'action':'was done','groups':['metro_purchase.group_pur_req_buyer']},
               'cancel':{'action':'was cancelled','groups':[]},
               }
     model_obj = self.pool.get('ir.model.data')
     if mail_types.get(mail_type,False):
         action_name = mail_types[mail_type]['action']
         group_params = mail_types[mail_type]['groups']
         for order in self.browse(cr, uid, ids, context=context):
             #email to groups
             email_group_ids = []
             for group_param in group_params:
                 grp_data = group_param.split('.')
                 email_group_ids.append(model_obj.get_object_reference(cr, uid, grp_data[0], grp_data[1])[1])
             #email to users
             email_to = None
             if mail_type in (' rejected', 'done', 'cancel'):
                 email_to = order.user_id.email
             email_cc = None
             if mail_type in ('approved', 'in_purchase'):
                 email_cc = order.user_id.email
             #email messages             
             email_subject = 'Purchase Requisition: %s %s'%(order.name,action_name)
             email_body = email_subject
             #the current user is the from user
             email_from = self.pool.get("res.users").read(cr, uid, uid, ['email'],context=context)['email']
             #send emails
             utils.email_send_group(cr, uid, email_from, email_to, email_subject,email_body, email_group_ids, email_cc=email_cc,context=context)   
 def _email_notify(self,
                   cr,
                   uid,
                   ids,
                   action_name,
                   group_params,
                   context=None):
     for order in self.browse(cr, uid, ids, context=context):
         for group_param in group_params:
             email_group_id = self.pool.get(
                 'ir.config_parameter').get_param(cr,
                                                  uid,
                                                  group_param,
                                                  context=context)
             if email_group_id:
                 email_subject = 'CNC reminder: %s %s' % (order.name,
                                                          action_name)
                 mfg_id_names = ','.join(
                     [mfg_id.name for mfg_id in order.sale_product_ids])
                 email_body = '%s %s, MFG IDs:%s' % (
                     order.name, action_name, mfg_id_names)
                 email_from = self.pool.get("res.users").read(
                     cr, uid, uid, ['email'], context=context)['email']
                 utils.email_send_group(cr,
                                        uid,
                                        email_from,
                                        None,
                                        email_subject,
                                        email_body,
                                        email_group_id,
                                        context=context)
Example #3
0
 def _email_notify(self,
                   cr,
                   uid,
                   ids,
                   action_name,
                   group_params,
                   context=None):
     #ids 是int 需要转成list
     if isinstance(ids, (int, long)):
         ids = [ids]
     for order in self.browse(cr, uid, ids, context=context):
         for group_param in group_params:
             email_group_id = self.pool.get(
                 'ir.config_parameter').get_param(cr,
                                                  uid,
                                                  group_param,
                                                  context=context)
             if email_group_id:
                 email_subject = 'Future Shipment reminder: %s %s' % (
                     order.code, action_name)
                 email_body_string = 'The Future Shipment({0}) has been changed.'
                 email_body = email_body_string.format(order.code, )
                 email_from = self.pool.get("res.users").read(
                     cr, uid, uid, ['email'], context=context)['email']
                 utils.email_send_group(cr,
                                        uid,
                                        email_from,
                                        None,
                                        email_subject,
                                        email_body,
                                        email_group_id,
                                        context=context)
Example #4
0
 def _email_notify(self, cr, uid, ids, action_name, group_params, context=None):
     for order in self.browse(cr, uid, ids, context=context):
         for group_param in group_params:
             email_group_id = self.pool.get('ir.config_parameter').get_param(cr, uid, group_param, context=context)
             if email_group_id:                    
                 email_subject = 'CNC reminder: %s %s'%(order.name,action_name)
                 mfg_id_names = ','.join([mfg_id.name for mfg_id in order.sale_product_ids])
                 email_body = '%s %s, MFG IDs:%s'%(order.name,action_name,mfg_id_names)
                 email_from = self.pool.get("res.users").read(cr, uid, uid, ['email'],context=context)['email']
                 utils.email_send_group(cr, uid, email_from, None,email_subject,email_body, email_group_id, context=context)        
Example #5
0
 def action_reject_callback(self, cr, uid, ids, message, context=None):
     #set the draft state
     self._set_state(cr, uid, ids, 'rejected',context)
     self.write(cr,uid,ids,{'reject_message':message})
     #send email to the user for the rejection message
     email_from = self.pool.get("res.users").read(cr, uid, uid, ['email'],context=context)['email']
     for order in self.browse(cr, uid, ids, context=context):
         if order.create_uid.email:
             email_content = 'CNC reminder: %s was rejected'%(order.name)
             utils.email_send_group(cr, uid, email_from, order.create_uid.email,email_content,email_content, context = context) 
     return True
Example #6
0
 def action_reject_callback(self, cr, uid, ids, message, context=None):
     #set the draft state
     self._set_state(cr, uid, ids, 'rejected',context)
     self.write(cr,uid,ids,{'reject_message':message})
     #send email to the user for the rejection message
     email_from = self.pool.get("res.users").read(cr, uid, uid, ['email'],context=context)['email']
     for order in self.browse(cr, uid, ids, context=context):
         if order.create_uid.email:
             email_content = 'CNC reminder: %s was rejected'%(order.name)
             utils.email_send_group(cr, uid, email_from, order.create_uid.email,email_content,email_content, context = context) 
     return True
 def _email_notify(self, cr, uid, ids, action_name, group_params, context=None):
     #ids 是int 需要转成list
     if isinstance(ids, (int, long)):
         ids = [ids]
     for order in self.browse(cr, uid, ids, context=context):
         for group_param in group_params:
             email_group_id = self.pool.get('ir.config_parameter').get_param(cr, uid, group_param, context=context)
             if email_group_id:                    
                 email_subject = 'Future Shipment reminder: %s %s'%(order.code,action_name)
                 email_body_string = 'The Future Shipment({0}) has been changed.'
                 email_body = email_body_string.format(order.code,)
                 email_from = self.pool.get("res.users").read(cr, uid, uid, ['email'],context=context)['email']
                 utils.email_send_group(cr, uid, email_from, None, email_subject,email_body, email_group_id, context=context)      
Example #8
0
 def _email_notify(self, cr, uid, ids, action_name, group_params, context=None):
     for order in self.browse(cr, uid, ids, context=context):
         for group_param in group_params:
             email_group_id = self.pool.get('ir.config_parameter').get_param(cr, uid, group_param, context=context)
             if email_group_id:                    
                 email_subject = 'Drawing reminder: %s %s'%(order.name,action_name)
                 mfg_id_names = ','.join([mfg_id.name for mfg_id in order.sale_product_ids])
                 #[(id1,name1),(id2,name2),...(idn,namen)]
                 main_part_name = ''
                 if order.main_part_id:
                     main_part_name = self.pool.get('product.product').name_get(cr, uid,  [order.main_part_id.id], context=context)[0][1]
                 email_body = '%s %s %s, MFG IDs:%s'%(order.name,main_part_name, action_name,mfg_id_names)
                 email_from = self.pool.get("res.users").read(cr, uid, uid, ['email'],context=context)['email']
                 utils.email_send_group(cr, uid, email_from, None,email_subject,email_body, email_group_id, context=context)
Example #9
0
 def _email_notify(self, cr, uid, ids, action_name, group_params, context=None):
     for order in self.browse(cr, uid, ids, context=context):
         for group_param in group_params:
             email_group_id = self.pool.get('ir.config_parameter').get_param(cr, uid, group_param, context=context)
             if email_group_id:                    
                 email_subject = 'Drawing reminder: %s %s'%(order.name,action_name)
                 mfg_id_names = ','.join([mfg_id.name for mfg_id in order.sale_product_ids])
                 #[(id1,name1),(id2,name2),...(idn,namen)]
                 main_part_name = ''
                 if order.main_part_id:
                     main_part_name = self.pool.get('product.product').name_get(cr, uid,  [order.main_part_id.id], context=context)[0][1]
                 email_body = '%s %s %s, MFG IDs:%s'%(order.name,main_part_name, action_name,mfg_id_names)
                 email_from = self.pool.get("res.users").read(cr, uid, uid, ['email'],context=context)['email']
                 utils.email_send_group(cr, uid, email_from, None,email_subject,email_body, email_group_id, context=context)
 def send(self, cr, uid, ids, context=None):
     order = self.browse(cr, uid, ids[0], context=context)
     email_tos = [partner.email for partner in order.partner_ids if partner.email]
     emp_ids = order.emp_ids
     email_from = self.pool.get("res.users").read(cr, uid, uid, ['email'],context=context)['email']
     if email_from and email_tos and emp_ids:
         subject = 'Employee Welcome Checklist'
         emp_names = ', '.join([emp.name for emp in emp_ids])
         body = '%s:%s'%(subject,emp_names)
         #generate the attachments by PDF report
         attachments = []
         report_name = 'Employee Welcome Checklist'
         report_service = netsvc.LocalService('report.hr.welcome.checklist')
         rpt_emp_ids = [emp.id for emp in emp_ids]            
         (result, format) = report_service.create(cr, uid, rpt_emp_ids, {'model': 'hr.employee'}, context)
         ext = "." + format
         if not report_name.endswith(ext):
             report_name += ext
         attachments.append((report_name, result))
         
         utils.email_send_group(cr, uid, email_from, email_tos, subject, body, context=context, attachments=attachments)
         
     return True
    def send(self, cr, uid, ids, context=None):
        order = self.browse(cr, uid, ids[0], context=context)
        email_tos = [
            partner.email for partner in order.partner_ids if partner.email
        ]
        emp_ids = order.emp_ids
        email_from = self.pool.get("res.users").read(cr,
                                                     uid,
                                                     uid, ['email'],
                                                     context=context)['email']
        if email_from and email_tos and emp_ids:
            subject = 'Employee Welcome Checklist'
            emp_names = ', '.join([emp.name for emp in emp_ids])
            body = '%s:%s' % (subject, emp_names)
            #generate the attachments by PDF report
            attachments = []
            report_name = 'Employee Welcome Checklist'
            report_service = netsvc.LocalService('report.hr.welcome.checklist')
            rpt_emp_ids = [emp.id for emp in emp_ids]
            (result, format) = report_service.create(cr, uid, rpt_emp_ids,
                                                     {'model': 'hr.employee'},
                                                     context)
            ext = "." + format
            if not report_name.endswith(ext):
                report_name += ext
            attachments.append((report_name, result))

            utils.email_send_group(cr,
                                   uid,
                                   email_from,
                                   email_tos,
                                   subject,
                                   body,
                                   context=context,
                                   attachments=attachments)

        return True
Example #12
0
 def _email_notify(self, cr, uid, ids, mail_type, context=None):
     mail_types = {
         'confirmed': {
             'action': 'need your approval',
             'groups': ['metro_purchase.group_pur_req_checker']
         },
         'approved': {
             'action': 'approved, please issue PO',
             'groups': ['metro_purchase.group_pur_req_buyer']
         },
         'rejected': {
             'action': 'was rejected, please check',
             'groups': []
         },
         'in_purchase': {
             'action': 'is in purchasing',
             'groups': [],
         },
         'done': {
             'action': 'was done',
             'groups': ['metro_purchase.group_pur_req_buyer']
         },
         'cancel': {
             'action': 'was cancelled',
             'groups': []
         },
     }
     model_obj = self.pool.get('ir.model.data')
     if mail_types.get(mail_type, False):
         action_name = mail_types[mail_type]['action']
         group_params = mail_types[mail_type]['groups']
         for order in self.browse(cr, uid, ids, context=context):
             #email to groups
             email_group_ids = []
             for group_param in group_params:
                 grp_data = group_param.split('.')
                 email_group_ids.append(
                     model_obj.get_object_reference(cr, uid, grp_data[0],
                                                    grp_data[1])[1])
             #email to users
             email_to = None
             if mail_type in (' rejected', 'done', 'cancel'):
                 email_to = order.user_id.email
             email_cc = None
             if mail_type in ('approved', 'in_purchase'):
                 email_cc = order.user_id.email
             #email messages
             email_subject = 'Purchase Requisition: %s %s' % (order.name,
                                                              action_name)
             email_body = email_subject
             #the current user is the from user
             email_from = self.pool.get("res.users").read(
                 cr, uid, uid, ['email'], context=context)['email']
             #send emails
             utils.email_send_group(cr,
                                    uid,
                                    email_from,
                                    email_to,
                                    email_subject,
                                    email_body,
                                    email_group_ids,
                                    email_cc=email_cc,
                                    context=context)