From 5488e8ae0a1bc91e18a12524edc2304b0d18d5b1 Mon Sep 17 00:00:00 2001 From: "Purnendu Singh (OpenERP)" Date: Tue, 27 Mar 2012 17:14:44 +0530 Subject: [PATCH] [IMP] mail, account, sale, purchase: remove _hook_msg_sent from account, sale and purchase and revert all changes of mail as it will be done in other branch bzr revid: psi@tinyerp.com-20120327114444-qj9z73j0zaq4kkd2 --- addons/account/account_invoice.py | 16 +++++++++++----- addons/mail/mail_message.py | 4 ---- addons/mail/wizard/mail_compose_message.py | 4 +--- .../mail/wizard/mail_compose_message_view.xml | 1 - addons/purchase/purchase.py | 17 ++++++++++++----- addons/sale/sale.py | 17 ++++++++++++----- 6 files changed, 36 insertions(+), 23 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 3a82bfd9854..365200743d8 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -371,11 +371,6 @@ class account_invoice(osv.osv): _('There is no Accounting Journal of type Sale/Purchase defined!')) else: raise orm.except_orm(_('Unknown Error'), str(e)) - - def _hook_message_sent(self, cr, uid, invoice_id, context=None): - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'account.invoice', invoice_id, 'invoice_sent', cr) - return True def invoice_print(self, cr, uid, ids, context=None): wf_service = netsvc.LocalService('workflow') @@ -1699,4 +1694,15 @@ class res_partner(osv.osv): res_partner() +class mail_message(osv.osv): + _name = 'mail.message' + _inherit = 'mail.message' + + def _postprocess_sent_message(self, cr, uid, message, context=None): + if message.model == 'account.invoice': + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate(uid, 'account.invoice', message.res_id, 'invoice_sent', cr) + return super(mail_message, self)._postprocess_sent_message(cr, uid, message=message, context=context) + +mail_message() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index f2565decb79..695b0b905e8 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -464,7 +464,6 @@ class mail_message(osv.osv): msg['sub_type'] = msg['subtype'] or 'plain' return msg - def send(self, cr, uid, ids, auto_commit=False, context=None): """Sends the selected emails immediately, ignoring their current state (mails that have already been sent should not be passed @@ -521,9 +520,6 @@ class mail_message(osv.osv): message.write({'state':'sent', 'message_id': res}) else: message.write({'state':'exception'}) - model_pool = self.pool.get(message.model) - if hasattr(model_pool, '_hook_message_sent'): - model_pool._hook_message_sent(cr, uid, message.res_id, context=context) # if auto_delete=True then delete that sent messages as well as attachments message.refresh() if message.state == 'sent' and message.auto_delete: diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 4f1163c0d69..bc4a6fbe233 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -100,7 +100,6 @@ class mail_compose_message(osv.osv_memory): if not result.get('email_from'): current_user = self.pool.get('res.users').browse(cr, uid, uid, context) result['email_from'] = current_user.user_email or False - result['subtype'] = 'html' return result _columns = { @@ -159,9 +158,8 @@ class mail_compose_message(osv.osv_memory): if not (subject.startswith('Re:') or subject.startswith(re_prefix)): subject = "%s %s" % (re_prefix, subject) result.update({ - 'subtype' : message_data.subtype or 'plain', # default to the text version due to quoting + 'subtype' : 'plain', # default to the text version due to quoting 'body_text' : body, - 'body_html' : message_data.body_html, 'subject' : subject, 'attachment_ids' : [], 'model' : message_data.model or False, diff --git a/addons/mail/wizard/mail_compose_message_view.xml b/addons/mail/wizard/mail_compose_message_view.xml index 3a44b040139..d559d679c8b 100644 --- a/addons/mail/wizard/mail_compose_message_view.xml +++ b/addons/mail/wizard/mail_compose_message_view.xml @@ -23,7 +23,6 @@ - diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index b5f8568e5ca..0093222d78d 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -328,11 +328,6 @@ class purchase_order(osv.osv): self.write(cr, uid, ids, {'state': 'approved', 'date_approve': fields.date.context_today(self,cr,uid,context=context)}) return True - def _hook_message_sent(self, cr, uid, purchase_id, context=None): - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'purchase.order', purchase_id, 'send_rfq', cr) - return True - def wkf_send_rfq(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') template_id = self.pool.get('email.template').search(cr, uid, [('model_id', '=', 'purchase.order')]) @@ -1020,4 +1015,16 @@ class procurement_order(osv.osv): return res procurement_order() + +class mail_message(osv.osv): + _name = 'mail.message' + _inherit = 'mail.message' + + def _postprocess_sent_message(self, cr, uid, message, context=None): + if message.model == 'purchase.order': + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate(uid, 'purchase.order', message.res_id, 'send_rfq', cr) + return super(mail_message, self)._postprocess_sent_message(cr, uid, message=message, context=context) + +mail_message() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 3b7eff07cbf..50f6bf81153 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -752,11 +752,6 @@ class sale_order(osv.osv): 'nodestroy': True, } - def _hook_message_sent(self, cr, uid, sale_id, context=None): - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'sale.order', sale_id, 'quotation_sent', cr) - return True - def procurement_lines_get(self, cr, uid, ids, *args): res = [] for order in self.browse(cr, uid, ids, context={}): @@ -1520,4 +1515,16 @@ class sale_config_picking_policy(osv.osv_memory): sale_config_picking_policy() +class mail_message(osv.osv): + _name = 'mail.message' + _inherit = 'mail.message' + + def _postprocess_sent_message(self, cr, uid, message, context=None): + if message.model == 'sale.order': + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate(uid, 'sale.order', message.res_id, 'quotation_sent', cr) + return super(mail_message, self)._postprocess_sent_message(cr, uid, message=message, context=context) + +mail_message() + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: