[imp] sale improve sale and mail

bzr revid: psi@tinyerp.com-20120307064022-4q3j3uqoao20eqqy
This commit is contained in:
Purnendu Singh (OpenERP) 2012-03-07 12:10:22 +05:30
parent da74d3cde0
commit 553f0fe846
4 changed files with 16 additions and 5 deletions

View File

@ -100,6 +100,7 @@ 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 = {
@ -158,7 +159,7 @@ 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' : 'plain', # default to the text version due to quoting
'subtype' : message_data.subtype or 'plain', # default to the text version due to quoting
'body_text' : body,
'body_html' : message_data.body_html,
'subject' : subject,

View File

@ -23,6 +23,7 @@
<notebook colspan="4">
<page string="Body">
<field name="body_text" colspan="4" nolabel="1" height="300" width="300"/>
<field name="body_html" invisible="1"/>
</page>
<page string="Attachments">
<field name="attachment_ids" colspan="4" nolabel="1"/>

View File

@ -24,6 +24,7 @@ from dateutil.relativedelta import relativedelta
from osv import fields, osv, orm
from edi import EDIMixin
from edi.models import edi
from tools import DEFAULT_SERVER_DATE_FORMAT
SALE_ORDER_LINE_EDI_STRUCT = {
@ -64,6 +65,17 @@ SALE_ORDER_EDI_STRUCT = {
class sale_order(osv.osv, EDIMixin):
_inherit = 'sale.order'
def action_quotation_sent(self, cr, uid, ids, context=None):
if context is None:
context = {}
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)
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):
"""Exports a Sale order"""
edi_struct = dict(edi_struct or SALE_ORDER_EDI_STRUCT)

View File

@ -675,11 +675,8 @@ class sale_order(osv.osv):
template_id = self.pool.get('email.template').search(cr, uid, [('model_id', '=', 'sale.order')], context=context)
model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','email_compose_message_wizard_form')], context=context)
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
#EDI EXport data
# if not self.browse(cr, uid, id, context).partner_id.opt_out:
# order.edi_export_and_email(template_ext_id='sale.email_template_edi_sale', context=context)
ctx = context.copy()
ctx.update({'active_model': 'sale.order', 'active_id': id[0], 'mail.compose.template_id': template_id})
ctx.update({'active_model': 'sale.order', 'active_id': ids[0], 'mail.compose.template_id': template_id})
return {
'view_type': 'form',
'view_mode': 'form',