[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
This commit is contained in:
Divyesh Makwana (Open ERP) 2012-04-02 18:06:51 +05:30
parent e9efa4f61e
commit aa8e83ea2d
9 changed files with 29 additions and 22 deletions

View File

@ -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',

View File

@ -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):

View File

@ -2,6 +2,7 @@
<openerp>
<data>
<!-- EDI Export + Send email Action -->
<!--
<record id="ir_actions_server_edi_invoice" model="ir.actions.server">
<field name="code">if (object.type in ('out_invoice', 'out_refund')) and not object.partner_id.opt_out: object.edi_export_and_email(template_ext_id='account.email_template_edi_invoice', context=context)</field>
<field eval="6" name="sequence"/>
@ -11,6 +12,7 @@
<field name="condition">True</field>
<field name="name">Auto-email confirmed invoices</field>
</record>
-->
<!-- EDI related Email Templates menu -->
<record model="ir.actions.act_window" id="action_email_templates">
@ -31,9 +33,11 @@
so users can freely customize/delete them -->
<data noupdate="1">
<!-- bind the mailing server action to invoice open activity -->
<!--
<record id="account.act_open" model="workflow.activity">
<field name="action_id" ref="ir_actions_server_edi_invoice"/>
</record>
-->
<!--Email template -->
<record id="email_template_edi_invoice" model="email.template">

View File

@ -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):

View File

@ -2,6 +2,7 @@
<openerp>
<data>
<!--Export edi document -->
<!--
<record id="ir_actions_server_edi_purchase" model="ir.actions.server">
<field name="code">if not object.partner_id.opt_out: object.edi_export_and_email(template_ext_id='purchase.email_template_edi_purchase', context=context)</field>
<field name="state">code</field>
@ -10,6 +11,7 @@
<field name="condition">True</field>
<field name="name">Auto-email confirmed purchase orders</field>
</record>
-->
<!-- EDI related Email Templates menu -->
<record model="ir.actions.act_window" id="action_email_templates">
@ -27,9 +29,11 @@
so users can freely customize/delete them -->
<data noupdate="1">
<!-- bind the mailing server action to purchase.order confirmed activity -->
<!--
<record id="purchase.act_confirmed" model="workflow.activity">
<field name="action_id" ref="ir_actions_server_edi_purchase"/>
</record>
-->
<!--Email template -->
<record id="email_template_edi_purchase" model="email.template">
@ -151,4 +155,4 @@ ${object.company_id.website or ''}
]]></field>
</record>
</data>
</openerp>
</openerp>

View File

@ -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',

View File

@ -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:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -2,6 +2,7 @@
<openerp>
<data>
<!-- EDI Export + Send email Action -->
<!--
<record id="ir_actions_server_edi_sale" model="ir.actions.server">
<field name="code">if not object.partner_id.opt_out: object.edi_export_and_email(template_ext_id='sale.email_template_edi_sale', context=context)</field>
<field name="state">code</field>
@ -10,6 +11,7 @@
<field name="condition">True</field>
<field name="name">Auto-email confirmed sale orders</field>
</record>
-->
<!-- EDI related Email Templates menu -->
<record model="ir.actions.act_window" id="action_email_templates">
@ -29,9 +31,11 @@
so users can freely customize/delete them -->
<data noupdate="1">
<!-- bind the mailing server action to sale.order confirmed activity -->
<!--
<record id="sale.act_wait_ship" model="workflow.activity">
<field name="action_id" ref="ir_actions_server_edi_sale"/>
</record>
-->
<!--Email template -->

View File

@ -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',