diff --git a/addons/crm/crm.py b/addons/crm/crm.py index d20b8e47a4a..684547e0410 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -188,7 +188,7 @@ class crm_case_rule(osv.osv): 'trg_section_id': fields.many2one('crm.case.section', 'Section'), -# 'trg_categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',trg_section_id)]"), + 'trg_categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',trg_section_id)]"), 'trg_user_id': fields.many2one('res.users', 'Responsible'), 'trg_partner_id': fields.many2one('res.partner', 'Partner'), @@ -365,7 +365,7 @@ class crm_case(osv.osv): def _get_section(self, cr, uid, context): user = self.pool.get('res.users').browse(cr, uid, uid,context=context) - return user.context_section_id + return user.context_section_id.id or False _defaults = { 'active': lambda *a: 1, @@ -586,7 +586,7 @@ class crm_case(osv.osv): def __history(self, cr, uid, cases, keyword, history=False, email=False, details=None, context={}): - model_obj = self.pool.get('ir.model') + model_obj = self.pool.get('ir.model') for case in cases: model_ids = model_obj.search(cr, uid, [('model','=',case._name)]) data = { diff --git a/addons/crm/crm_mailgate.py b/addons/crm/crm_mailgate.py index e66e2784f2a..67164961663 100644 --- a/addons/crm/crm_mailgate.py +++ b/addons/crm/crm_mailgate.py @@ -36,7 +36,7 @@ class crm_cases(osv.osv): _name = "crm.case" _inherit = "crm.case" - def msg_new(self, cr, uid, msg): + def msg_new(self, cr, uid, msg): mailgate_obj = self.pool.get('mail.gateway') msg_body = mailgate_obj.msg_body_get(msg) data = { @@ -54,7 +54,11 @@ class crm_cases(osv.osv): self._history(cr, uid, cases, _('Receive'), history=True, email=msg['From']) return res - def msg_update(self, cr, uid, ids, msg, data={}, default_act='pending'): + def msg_update(self, cr, uid, ids, msg, data={}, default_act='pending'): + if isinstance(ids, (str, int, long)): + select = [ids] + else: + select = ids mailgate_obj = self.pool.get('mail.gateway') msg_actions, body_data = mailgate_obj.msg_act_get(msg) data.update({ @@ -65,26 +69,24 @@ class crm_cases(osv.osv): if msg_actions['state'] in ['draft','close','cancel','open','pending']: act = 'case_' + msg_actions['state'] - for k1,k2 in [('cost','planned_cost'),('revenue','planned_revenue'),('probability','probability')]: - try: + for k1,k2 in [('cost','planned_cost'),('revenue','planned_revenue'),('probability','probability')]: + if k1 in msg_actions: data[k2] = float(msg_actions[k1]) - except: - pass if 'priority' in msg_actions: if msg_actions['priority'] in ('1','2','3','4','5'): data['priority'] = msg_actions['priority'] if 'partner' in msg_actions: - data['email_from'] = msg_actions['partner'][:128] + data['email_from'] = msg_actions['partner'][:128] - res = self.write(cr, uid, ids, data) - cases = self.browse(cr, uid, [res]) + res = self.write(cr, uid, select, data) + cases = self.browse(cr, uid, select) self._history(cr, uid, cases, _('Receive'), history=True, email=msg['From']) - getattr(self,act)(cr, uid, ids) + getattr(self,act)(cr, uid, select) return res - def emails_get(self, cr, uid, ids, context={}): + def emails_get(self, cr, uid, ids, context={}): res = [] if isinstance(ids, (str, int, long)): select = [ids] @@ -94,7 +96,7 @@ class crm_cases(osv.osv): user_email = (case.user_id and case.user_id.address_id and case.user_id.address_id.email) or False res += [(user_email, case.email_from, case.email_cc, case.priority)] if isinstance(ids, (str, int, long)): - return len(res) and res[0] or False + return len(res) and res[0] or False return res def msg_send(self, cr, uid, id, *args, **argv): diff --git a/addons/mail_gateway/mail_gateway.py b/addons/mail_gateway/mail_gateway.py index c047c3840b4..ee7676d4423 100644 --- a/addons/mail_gateway/mail_gateway.py +++ b/addons/mail_gateway/mail_gateway.py @@ -116,10 +116,11 @@ class mail_gateway(osv.osv): msg_id = msg_txt['Message-ID'] res_id = self.msg_parse(cr, uid, gateway_id, msg_txt) except Exception, e: - note = "Error in Parsing Mail: %s " %(str(e)) - if mailgateway: - netsvc.Logger().notifyChannel('Emailgate: Parsing mail:%s' % (mailgateway.name or - '%s (%s)'%(mailgateway.server_id.login, mailgateway.server_id.name)), netsvc.LOG_ERROR, str(e)) + import traceback + note = "Error in Parsing Mail: %s " %(str(e)) + netsvc.Logger().notifyChannel('Emailgate: Parsing mail:%s' % (mailgateway and (mailgateway.name or + '%s (%s)'%(mailgateway.server_id.login, mailgateway.server_id.name))) or '' + , netsvc.LOG_ERROR, traceback.format_exc()) mail_history_obj.create(cr, uid, {'name': msg_id, 'res_id': res_id, 'gateway_id': mailgateway.id, 'note': note}) return res_id, note @@ -181,9 +182,11 @@ class mail_gateway(osv.osv): imap_server.logout() except Exception, e: - log_messages.append("Error in Fetching Mail: %s " %(str(e))) - if mailgate_server: - netsvc.Logger().notifyChannel('Emailgate: Fetching mail:[%d]%s' % (mailgate_server.id, mailgate_server.name), netsvc.LOG_ERROR, str(e)) + import traceback + log_messages.append("Error in Fetching Mail: %s " %(str(e))) + netsvc.Logger().notifyChannel('Emailgate: Fetching mail:[%d]%s' % + (mailgate_server and mailgate_server.id or 0, mailgate_server and mailgate_server.name or ''), + netsvc.LOG_ERROR, traceback.format_exc()) log_messages.append("-"*25) log_messages.append("Total Read Mail: %d\n\n" %(len(new_messages))) @@ -305,7 +308,7 @@ class mail_gateway(osv.osv): res_model = self.pool.get(res_model) return res_model.msg_update(cr, uid, res_id, msg, data=data, default_act='pending') - def msg_send(self, msg, reply_to, emails, priority=None, res_id=False): + def msg_send(self, msg, reply_to, emails, priority=None, res_id=False): if not emails: return False msg_to = [emails[0]] @@ -390,6 +393,7 @@ class mail_gateway_history(osv.osv): 'gateway_id': fields.many2one('mail.gateway',"Mail Gateway", required=True), 'model_id':fields.related('gateway_id', 'object_id', type='many2one', relation='ir.model', string='Model'), 'note': fields.text('Notes'), + 'create_date': fields.datetime('Created Date'), } _order = 'id desc' mail_gateway_history() diff --git a/addons/mail_gateway/mail_gateway_view.xml b/addons/mail_gateway/mail_gateway_view.xml index fa4f1146311..b6112e1482f 100644 --- a/addons/mail_gateway/mail_gateway_view.xml +++ b/addons/mail_gateway/mail_gateway_view.xml @@ -8,6 +8,7 @@
+ @@ -24,6 +25,7 @@ +