From aa8e83ea2d44f8e59f4b6dee915f0aea101063fa Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Mon, 2 Apr 2012 18:06:51 +0530 Subject: [PATCH] [IMP] account, sale, purchase : Cleanup the use of dicts, remove the automatic email send by the EDI and use proper template based on an XML ID. bzr revid: mdi@tinyerp.com-20120402123651-ekqw8z66ltpqnxgz --- addons/account/account_invoice.py | 7 ++++--- addons/account/edi/invoice.py | 4 +--- addons/account/edi/invoice_action_data.xml | 4 ++++ addons/purchase/edi/purchase_order.py | 4 +--- addons/purchase/edi/purchase_order_action_data.xml | 6 +++++- addons/purchase/purchase.py | 9 ++++----- addons/sale/edi/sale_order.py | 6 ++---- addons/sale/edi/sale_order_action_data.xml | 4 ++++ addons/sale/sale.py | 7 ++++--- 9 files changed, 29 insertions(+), 22 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 8d0d185db23..d715778584f 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -388,11 +388,12 @@ class account_invoice(osv.osv): def action_invoice_sent(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', '=', 'account.invoice')], context=context)[0] + template = mod_obj.get_object_reference(cr, uid, 'account', 'email_template_edi_invoice') + template_id = template and template[1] or False res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form') res_id = res and res[1] or False - ctx = context.copy() - ctx.update({'active_model': 'account.invoice', 'active_id': ids[0], 'mail.compose.template_id': template_id}) + ctx = dict(context, active_model='account.invoice', active_id=ids[0]) + ctx.update({'mail.compose.template_id': template_id}) return { 'view_type': 'form', 'view_mode': 'form', diff --git a/addons/account/edi/invoice.py b/addons/account/edi/invoice.py index eb9f97c80db..6e4d601e987 100644 --- a/addons/account/edi/invoice.py +++ b/addons/account/edi/invoice.py @@ -79,9 +79,7 @@ class account_invoice(osv.osv, EDIMixin): invoice_objs = self.browse(cr, uid, ids, context=context) edi_token = self.pool.get('edi.document').export_edi(cr, uid, invoice_objs, context = context)[0] web_root_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url') - edi_context = dict(context, edi_web_url_view=edi.EDI_VIEW_WEB_URL % (web_root_url, cr.dbname, edi_token)) - ctx = context.copy() - ctx.update(edi_context) + ctx = dict(context, edi_web_url_view=edi.EDI_VIEW_WEB_URL % (web_root_url, cr.dbname, edi_token)) return super(account_invoice, self).action_invoice_sent(cr, uid, ids, context=ctx) def edi_export(self, cr, uid, records, edi_struct=None, context=None): diff --git a/addons/account/edi/invoice_action_data.xml b/addons/account/edi/invoice_action_data.xml index ce837c6662b..4dd225a493d 100644 --- a/addons/account/edi/invoice_action_data.xml +++ b/addons/account/edi/invoice_action_data.xml @@ -2,6 +2,7 @@ + @@ -31,9 +33,11 @@ so users can freely customize/delete them --> + diff --git a/addons/purchase/edi/purchase_order.py b/addons/purchase/edi/purchase_order.py index 1994668b35b..3a82e990a14 100644 --- a/addons/purchase/edi/purchase_order.py +++ b/addons/purchase/edi/purchase_order.py @@ -69,9 +69,7 @@ class purchase_order(osv.osv, EDIMixin): purchase_objs = self.browse(cr, uid, ids, context=context) edi_token = self.pool.get('edi.document').export_edi(cr, uid, purchase_objs, context = context)[0] web_root_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url') - edi_context = dict(context, edi_web_url_view=edi.EDI_VIEW_WEB_URL % (web_root_url, cr.dbname, edi_token)) - ctx = context.copy() - ctx.update(edi_context) + ctx = dict(context, edi_web_url_view=edi.EDI_VIEW_WEB_URL % (web_root_url, cr.dbname, edi_token)) return super(purchase_order, self).wkf_send_rfq(cr, uid, ids, context=ctx) def edi_export(self, cr, uid, records, edi_struct=None, context=None): diff --git a/addons/purchase/edi/purchase_order_action_data.xml b/addons/purchase/edi/purchase_order_action_data.xml index c4a7f75819a..5fafa1f4b1a 100644 --- a/addons/purchase/edi/purchase_order_action_data.xml +++ b/addons/purchase/edi/purchase_order_action_data.xml @@ -2,6 +2,7 @@ + @@ -27,9 +29,11 @@ so users can freely customize/delete them --> + @@ -151,4 +155,4 @@ ${object.company_id.website or ''} ]]> - \ No newline at end of file + diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 7e5c28d0050..19e3ce5db95 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -327,13 +327,12 @@ class purchase_order(osv.osv): 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')], context=context)[0] - + template = mod_obj.get_object_reference(cr, uid, 'purchase', 'email_template_edi_purchase') + template_id = template and template[1] or False res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form') res_id = res and res[1] or False - - ctx = context.copy() - ctx.update({'active_model': 'purchase.order', 'active_id': ids[0], 'mail.compose.template_id': template_id}) + ctx = dict(context, active_model='purchase.order', active_id=ids[0]) + ctx.update({'mail.compose.template_id': template_id}) return { 'view_type': 'form', 'view_mode': 'form', diff --git a/addons/sale/edi/sale_order.py b/addons/sale/edi/sale_order.py index 02c6ce617e9..b49f6c1e415 100644 --- a/addons/sale/edi/sale_order.py +++ b/addons/sale/edi/sale_order.py @@ -71,9 +71,7 @@ class sale_order(osv.osv, EDIMixin): sale_objs = self.browse(cr, uid, ids, context=context) edi_token = self.pool.get('edi.document').export_edi(cr, uid, sale_objs, context = context)[0] web_root_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url') - edi_context = dict(context, edi_web_url_view=edi.EDI_VIEW_WEB_URL % (web_root_url, cr.dbname, edi_token)) - ctx = context.copy() - ctx.update(edi_context) + ctx = dict(context, edi_web_url_view=edi.EDI_VIEW_WEB_URL % (web_root_url, cr.dbname, edi_token)) return super(sale_order, self).action_quotation_sent(cr, uid, ids, context=ctx) def edi_export(self, cr, uid, records, edi_struct=None, context=None): @@ -226,4 +224,4 @@ class sale_order_line(osv.osv, EDIMixin): edi_doc_list.append(edi_doc) return edi_doc_list -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale/edi/sale_order_action_data.xml b/addons/sale/edi/sale_order_action_data.xml index 9fcee173014..a92c87de46f 100644 --- a/addons/sale/edi/sale_order_action_data.xml +++ b/addons/sale/edi/sale_order_action_data.xml @@ -2,6 +2,7 @@ + @@ -29,9 +31,11 @@ so users can freely customize/delete them --> + diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 9eb1336a0d9..8f88e28a3b8 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -730,11 +730,12 @@ class sale_order(osv.osv): def action_quotation_sent(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', '=', 'sale.order')], context=context)[0] + template = mod_obj.get_object_reference(cr, uid, 'sale', 'email_template_edi_sale') + template_id = template and template[1] or False res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form') res_id = res and res[1] or False - ctx = context.copy() - ctx.update({'active_model': 'sale.order', 'active_id': ids[0], 'mail.compose.template_id': template_id}) + ctx = dict(context, active_model='sale.order', active_id=ids[0]) + ctx.update({'mail.compose.template_id': template_id}) return { 'view_type': 'form', 'view_mode': 'form',