From 326a7b562caecd8021755adae4380aa5ab447e14 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 26 Oct 2011 02:01:10 +0200 Subject: [PATCH] [IMP] edi: review/improve EDI templates, cleanup, minor fixes (wip) bzr revid: odo@openerp.com-20111026000110-12zecr32uyola9lc --- addons/account/__openerp__.py | 2 +- addons/account/edi/invoice.py | 20 +- addons/account/edi/invoice_action_data.xml | 26 +- addons/edi/__openerp__.py | 2 +- addons/edi/controllers/main.py | 17 +- addons/edi/models/edi.py | 68 ++++- addons/edi/models/res_company.py | 8 +- addons/edi/static/src/css/edi.css | 141 ++++++++-- addons/edi/static/src/js/edi.js | 18 +- addons/edi/static/src/xml/edi.xml | 11 +- addons/edi/static/src/xml/edi_account.xml | 241 +++++++++--------- .../edi/static/src/xml/edi_sale_purchase.xml | 163 ++++++++---- addons/purchase/edi/purchase_order.py | 6 + .../edi/purchase_order_action_data.xml | 26 +- addons/sale/edi/sale_order.py | 7 + addons/sale/edi/sale_order_action_data.xml | 26 +- 16 files changed, 511 insertions(+), 271 deletions(-) diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 008e7d78139..81d09b30ae9 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -53,7 +53,7 @@ module named account_voucher. 'website': 'http://www.openerp.com', 'images' : ['images/accounts.jpeg','images/bank_statement.jpeg','images/cash_register.jpeg','images/chart_of_accounts.jpeg','images/customer_invoice.jpeg','images/journal_entries.jpeg'], 'init_xml': [], - "depends" : ["base_setup", "product", "analytic", "process", "board", "edi", "email_template"], + "depends" : ["base_setup", "product", "analytic", "process", "board", "edi"], 'update_xml': [ 'security/account_security.xml', 'security/ir.model.access.csv', diff --git a/addons/account/edi/invoice.py b/addons/account/edi/invoice.py index ff9ae27dbaf..c3968e0ec6e 100644 --- a/addons/account/edi/invoice.py +++ b/addons/account/edi/invoice.py @@ -31,6 +31,9 @@ INVOICE_LINE_EDI_STRUCT = { 'quantity': True, 'discount': True, 'note': True, + + # fields used for web preview only - discarded on import + 'price_subtotal': True, } INVOICE_TAX_LINE_EDI_STRUCT = { @@ -57,6 +60,12 @@ INVOICE_EDI_STRUCT = { #custom: currency_id 'invoice_line': INVOICE_LINE_EDI_STRUCT, 'tax_line': INVOICE_TAX_LINE_EDI_STRUCT, + + # fields used for web preview only - discarded on import + #custom: 'partner_ref' + 'amount_total': True, + 'amount_untaxed': True, + 'amount_tax': True, } class account_invoice(osv.osv, EDIMixin): @@ -71,15 +80,14 @@ class account_invoice(osv.osv, EDIMixin): for invoice in records: # generate the main report self._edi_generate_report_attachment(cr, uid, invoice, context=context) - edi_doc = super(account_invoice,self).edi_export(cr, uid, [invoice], edi_struct, context)[0] edi_doc.update({ 'company_address': res_company.edi_export_address(cr, uid, invoice.company_id, context=context), 'company_paypal_account': invoice.company_id.paypal_account, 'partner_address': res_partner_address.edi_export(cr, uid, [invoice.address_invoice_id], context=context)[0], - 'currency': self.pool.get('res.currency').edi_export(cr, uid, [invoice.currency_id], context=context), - #'company_logo': #TODO + 'currency': self.pool.get('res.currency').edi_export(cr, uid, [invoice.currency_id], context=context)[0], + 'partner_ref': invoice.reference or False, }) edi_doc_list.append(edi_doc) return edi_doc_list @@ -200,6 +208,9 @@ class account_invoice(osv.osv, EDIMixin): # internal number: reset to False, auto-generated edi_document['internal_number'] = False + # discard web preview fields, if present + edi_document.pop('partner_ref', None) + # journal_id: should be selected based on type: simply put the 'type' in the context when calling create(), will be selected correctly context.update(type=invoice_type) @@ -213,6 +224,9 @@ class account_invoice(osv.osv, EDIMixin): # account = fpos_obj.map_account(cr, uid, fiscal_position_id, account.id) edi_invoice_line['account_id'] = self.edi_m2o(cr, uid, account, context=context) if account else False + # discard web preview fields, if present + edi_invoice_line.pop('price_subtotal', None) + # for tax lines, we disconnect from the invoice.line, so all tax lines will be of type 'manual', and default accounts should be picked based # on the tax config of the DB where it is imported. tax_account = self._edi_tax_account(cr, uid, context=context) diff --git a/addons/account/edi/invoice_action_data.xml b/addons/account/edi/invoice_action_data.xml index 73328c392bc..1d601ccef52 100644 --- a/addons/account/edi/invoice_action_data.xml +++ b/addons/account/edi/invoice_action_data.xml @@ -3,19 +3,7 @@ - ") - - # accessing the template will fail if it has been deleted - so we'll skip everything - tmpl = self.pool.get('ir.model.data').get_object(cr, uid, 'account', 'email_template_edi_invoice') - - edi_token = self.pool.get('edi.document').export_edi(cr, uid, [object], context = context)[0] - context.update(edi_web_url_view='%s/web/view_edi?db=%s&token=%s' %(web_root_url, cr.dbname, edi_token)) - self.pool.get('email.template').send_mail(cr, uid,tmpl.id,object.id,context=context) -except: - pass]]> + code ir.actions.server @@ -61,7 +49,7 @@ except:

You can view the invoice document, download it and pay online using the following link:

- View Invoice % if object.company_id.paypal_account: @@ -77,7 +65,7 @@ except: %>

It is also possible to directly pay with Paypal:

- Pay with Paypal % endif @@ -86,12 +74,12 @@ except:

Thank you for choosing ${object.company_id.name or 'us'}!



-
-

+
+

${object.company_id.name}

-
- +
+ % if object.company_id.street: ${object.company_id.street}
% endif diff --git a/addons/edi/__openerp__.py b/addons/edi/__openerp__.py index 47838897164..54635a54f48 100644 --- a/addons/edi/__openerp__.py +++ b/addons/edi/__openerp__.py @@ -36,7 +36,7 @@ technical OpenERP documentation at http://doc.openerp.com """, 'author': 'OpenERP SA', 'website': 'http://www.openerp.com', - 'depends': ['base'], + 'depends': ['base', 'email_template'], 'data': [ 'security/ir.model.access.csv', ], diff --git a/addons/edi/controllers/main.py b/addons/edi/controllers/main.py index d83e9ef2df0..9558a27bd34 100644 --- a/addons/edi/controllers/main.py +++ b/addons/edi/controllers/main.py @@ -53,11 +53,22 @@ class EDI(openerpweb.Controller): filename_utf8 = attachment['file_name'] filename_encoded = "%s=%s" % ('filename*', utils.encode_rfc2231(filename_utf8, 'utf-8')) - response = werkzeug.wrappers.Response( result, headers=[('Content-Type', 'application/pdf'), - ('Content-Disposition', 'inline; ' + filename_encoded), - ('Content-Length', len(result))]) + response = werkzeug.wrappers.Response(result, headers=[('Content-Type', 'application/pdf'), + ('Content-Disposition', 'inline; ' + filename_encoded), + ('Content-Length', len(result))]) return response + @openerpweb.httprequest + def binary(self, req, db, token, field_path="company_address.logo", content_type='image/png'): + result = req.session.proxy('edi').get_edi_document(db, token) + doc = json.loads(result)[0] + for name in field_path.split("."): + doc = doc[name] + result = doc.decode('base64') + response = werkzeug.wrappers.Response(result, headers=[('Content-Type', content_type), + ('Content-Length', len(result))]) + return response + @openerpweb.jsonrequest def get_edi_document(self, req, db, token): result = req.session.proxy('edi').get_edi_document(db, token) diff --git a/addons/edi/models/edi.py b/addons/edi/models/edi.py index 636e5493589..21f7c35cff3 100644 --- a/addons/edi/models/edi.py +++ b/addons/edi/models/edi.py @@ -24,24 +24,27 @@ import hashlib import json import logging import re +import threading import time import urllib2 import openerp import openerp.release as release import netsvc -from osv import osv,fields +import pooler +from osv import osv,fields,orm from tools.translate import _ from tools.parse_version import parse_version from tools.safe_eval import safe_eval as eval -EXTERNAL_ID_PATTERN = re.compile(r'^(\S+:)?(\S+?)\.(\S+)$') +EXTERNAL_ID_PATTERN = re.compile(r'^([^.:]+)(?::([^.]+))?\.(\S+)$') +EDI_VIEW_WEB_URL = '%s/edi/view?debug=1&db=%s&token=%s' def split_external_id(ext_id): match = EXTERNAL_ID_PATTERN.match(ext_id) assert match, \ _("'%s' is an invalid external ID") % (ext_id) - return {'module': match.group(1) and match.group(1)[:-1], + return {'module': match.group(1), 'db_uuid': match.group(2), 'id': match.group(3), 'full': match.group(0)} @@ -408,11 +411,8 @@ class EDIMixin(object): for field in fields_to_export: column = self._all_columns[field].column value = getattr(record, field) - if not value: + if not value and value not in ('', 0): continue - #if _fields[field].has_key('function') or _fields[field].has_key('related_columns'): - # # Do not Export Function Fields and related fields - # continue elif column._type == 'many2one': value = self.edi_m2o(cr, uid, value, context=context) elif column._type == 'many2many': @@ -423,6 +423,48 @@ class EDIMixin(object): results.append(edi_dict) return results + def edi_export_and_email(self, cr, uid, ids, template_ext_id, context=None): + """Export the given records just like :meth:`~.export_edi`, the render the + given email template, in order to trigger appropriate notifications. + This method is intended to be called as part of business documents' + lifecycle, so it silently ignores any error occurring during the process, + as this is usually non-critical. To avoid any delay, it is also asynchronous + and will spawn a short-lived thread to perform the action. + + :param str template_ext_id: external id of the email.template to use for + the mail notifications + :return: True + """ + def email_task(): + db = pooler.get_db(cr.dbname) + local_cr = None + try: + time.sleep(1) # FIXME: workaround to wait for commit of parent transaction + # grab a fresh browse_record on local cursor + local_cr = db.cursor() + web_root_url = self.pool.get('ir.config_parameter').get_param(local_cr, uid, 'web.base.url') + if not web_root_url: + _logger.warning('Ignoring EDI mail notification, web.base.url not defined in parameters') + return + mail_tmpl = self._edi_get_object_by_external_id(local_cr, uid, template_ext_id, 'email.template', context=context) + if not mail_tmpl: + # skip EDI export if the template was not found + _logger.warning('Ignoring EDI mail notification, template %s cannot be located', template_ext_id) + return + for edi_record in self.browse(local_cr, uid, ids, context=context): + edi_token = self.pool.get('edi.document').export_edi(local_cr, uid, [edi_record], context = context)[0] + edi_context = dict(context, edi_web_url_view=EDI_VIEW_WEB_URL % (web_root_url, local_cr.dbname, edi_token)) + self.pool.get('email.template').send_mail(local_cr, uid, mail_tmpl.id, edi_record.id, context=edi_context) + except Exception: + _logger.warning('Ignoring EDI mail notification, failed to generate it.', exc_info=True) + finally: + if local_cr: + local_cr.commit() + local_cr.close() + + threading.Thread(target=email_task, name='EDI ExportAndEmail for %s %r' % (self._name, ids)).start() + return True + def _edi_get_object_by_name(self, cr, uid, name, model_name, context=None): model = self.pool.get(model_name) search_results = model.name_search(cr, uid, name, operator='=', context=context) @@ -448,7 +490,9 @@ class EDIMixin(object): if not report.attachment or not eval(report.attachment, eval_context): # no auto-saving of report as attachment, need to do it manually result = base64.b64encode(result) - file_name = report.report_name+".printout.pdf" + file_name = record.name_get()[0][1] + file_name = re.sub(r'[^a-zA-Z0-9_-]', '_', file_name) + file_name += ".pdf" ir_attachment = self.pool.get('ir.attachment').create(cr, uid, {'name': file_name, 'datas': result, @@ -493,9 +537,11 @@ class EDIMixin(object): db_uuid = self.pool.get('ir.config_parameter').get_param(cr, uid, 'database.uuid') module = ext_id_members['module'] ext_id = ext_id_members['id'] - ext_module = '%s:%s' % (module, ext_id_members['db_uuid']) - modules = [ext_module] - if ext_id_members['db_uuid'] == db_uuid: + modules = [] + ext_db_uuid = ext_id_members['db_uuid'] + if ext_db_uuid: + modules.append('%s:%s' % (module, ext_id_members['db_uuid'])) + if ext_db_uuid is None or ext_db_uuid == db_uuid: # local records may also be registered without the db_uuid modules.append(module) data_ids = ir_model_data.search(cr, uid, [('model','=',model), diff --git a/addons/edi/models/res_company.py b/addons/edi/models/res_company.py index b81f5aa1d1f..8ac924e25dc 100644 --- a/addons/edi/models/res_company.py +++ b/addons/edi/models/res_company.py @@ -40,7 +40,11 @@ class res_company(osv.osv): res_partner_address = self.pool.get('res.partner.address') addresses = res_partner.address_get(cr, uid, [company.partner_id.id], ['default', 'contact', 'invoice']) addr_id = addresses['invoice'] or addresses['contact'] or addresses['default'] + result = {} if addr_id: address = res_partner_address.browse(cr, uid, addr_id, context=context) - return res_partner_address.edi_export(cr, uid, [address], edi_struct=edi_address_struct, context=context)[0] - return {} + result = res_partner_address.edi_export(cr, uid, [address], edi_struct=edi_address_struct, context=context)[0] + if company.logo: + result['logo'] = company.logo # already base64-encoded + + return result diff --git a/addons/edi/static/src/css/edi.css b/addons/edi/static/src/css/edi.css index a759699b5e6..93cec34bd88 100644 --- a/addons/edi/static/src/css/edi.css +++ b/addons/edi/static/src/css/edi.css @@ -1,44 +1,39 @@ - - -td.oe_edi_view { +/** EDI content **/ +.openerp .company_logo { + background-size: 180px 46px; +} +.oe_edi_view { width: 65%; vertical-align: top; - padding: 10px; + padding: 0px 25px; border-right: 1px solid #D2CFCF; } - .oe_edi_sidebar_container { width: 35%; - padding: 10px; + padding: 0px 10px; vertical-align: top; } - -div.oe_edi_center { - margin: 25px; -} - -.oe_edi_right_top { - margin-right: 5px; -} - button.oe_edi_action_print { font-size: 1.5em; margin-left: 35%; + margin-bottom: 20px; +} +button.oe_edi_action_print img { + vertical-align: bottom; + width: 32px; + height: 32px; } /** EDI Sidebar **/ - .oe_edi_sidebar_title { border-bottom: 1px solid #D2CFCF; font-weight: bold; font-size: 1.3em; } - .oe_edi_nested_block { margin-left: 25px; padding: 0px; } - .oe_edi_right_top .oe_edi_nested_block label { float: left; text-align: right; @@ -47,3 +42,113 @@ button.oe_edi_action_print { font-weight: bold; min-width: 5em; } + +/** Paperbox, from http://www.sitepoint.com/pure-css3-paper-curl/ **/ +body { + background: #EEE; /* contrast with paper */ +} +.oe_edi_paperbox { + position: relative; + width: 80%; + padding: 5%; + margin: 0 auto; + background-color: #fff; + -webkit-box-shadow: 0 0 4px rgba(0, 0, 0, 0.2), inset 0 0 50px rgba(0, 0, 0, 0.1); + -moz-box-shadow: 0 0 4px rgba(0, 0, 0, 0.2), inset 0 0 50px rgba(0, 0, 0, 0.1); + box-shadow: 0 0 5px rgba(0, 0, 0, 0.2), inset 0 0 50px rgba(0, 0, 0, 0.1); +} +.oe_edi_paperbox:before, .oe_edi_paperbox:after { + position: absolute; + width: 40%; + height: 10px; + content: ' '; + left: 12px; + bottom: 13px; + background: transparent; + -webkit-transform: skew(-5deg) rotate(-5deg); + -moz-transform: skew(-5deg) rotate(-5deg); + -ms-transform: skew(-5deg) rotate(-5deg); + -o-transform: skew(-5deg) rotate(-5deg); + transform: skew(-5deg) rotate(-5deg); + -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3); + -moz-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3); + box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3); + z-index: -1; +} +.oe_edi_paperbox:after { + left: auto; right: 12px; + -webkit-transform: skew(5deg) rotate(5deg); + -moz-transform: skew(5deg) rotate(5deg); + -ms-transform: skew(5deg) rotate(5deg); + -o-transform: skew(5deg) rotate(5deg); + transform: skew(5deg) rotate(5deg); +} + +/** Sale Order / Purchase Order Preview **/ +table.oe_edi_data, .oe_edi_doc_title { + border-collapse: collapse; + clear: both; +} +.oe_edi_data .oe_edi_floor { + border-bottom: 1px solid black; +} +.oe_edi_data .oe_edi_ceiling { + border-top: 1px solid black; +} +.oe_edi_data .oe_edi_data_row { + border-bottom: 1px solid #D2CFCF; +} +.oe_edi_data_row td { + vertical-align: top; +} +.oe_edi_inner_note { + font-style: italic; + font-size: 95%; + padding-left: 10px; +} +.oe_edi_shade { + background: #e8e8e8; +} +.oe_edi_company_name { + text-transform: uppercase; + font-weight: bold; +} +.oe_edi_address_from { + float: left; +} +.oe_edi_address_to { + float: right; + margin-top: 25px; + margin-bottom: 30px; +} +.oe_edi_company_block_title { + width: 375px; + margin: 0px; + padding: 2px 14px; + background-color: rgb(142, 0, 0); + border-top-left-radius: 5px 5px; + border-top-right-radius: 5px 5px; + background-repeat: repeat no-repeat; +} +.oe_edi_company_block_title .oe_edi_company_name { + margin: 0px; + font-size: 1em; + color: #FFF; +} +.oe_edi_company_block_body { + width: 375px; + margin: 0px; + padding: 5px 14px; + line-height: 16px; + background-color: rgb(242, 242, 242); +} +.oe_edi_company_block_body p { + color: #222; + margin: 5px 0px; +} +.oe_edi_summary_label { + float: left; +} +.oe_edi_summary_value { + float: right; +} \ No newline at end of file diff --git a/addons/edi/static/src/js/edi.js b/addons/edi/static/src/js/edi.js index acf32decc37..859935ab9eb 100644 --- a/addons/edi/static/src/js/edi.js +++ b/addons/edi/static/src/js/edi.js @@ -11,6 +11,8 @@ openerp.edi.EdiView = openerp.web.Widget.extend({ this.token = token; this.session = new openerp.web.Session(); this.template = "EdiEmpty"; + this.content = ""; + this.sidebar = ""; }, start: function() { this._super(); @@ -20,12 +22,18 @@ openerp.edi.EdiView = openerp.web.Widget.extend({ }, on_document_loaded: function(docs){ this.doc = docs[0]; - //console.log("docs",this.doc); - var template = "Edi." + this.doc.__model + ".content"; + console.log("docs",this.doc); + var template_content = "Edi." + this.doc.__model + ".content"; + var template_sidebar = "Edi." + this.doc.__model + ".sidebar"; var param = {"widget":this, "doc":this.doc}; - this.center = openerp.web.qweb.render(template, param); - //console.log(this.center); - this.right = ""; + if (openerp.web.qweb.templates[template_sidebar]) { + this.sidebar = openerp.web.qweb.render(template_sidebar, param); + } + console.log("sidebar",this.sidebar); + if (openerp.web.qweb.templates[template_content]) { + this.content = openerp.web.qweb.render(template_content, param); + } + console.log("sidebar",this.sidebar); this.$element.html(openerp.web.qweb.render("EdiView", param)); this.$element.find('button.oe_edi_action_print').bind('click', this.do_print); this.$element.find('button.oe_edi_import_button').bind('click', this.do_import); diff --git a/addons/edi/static/src/xml/edi.xml b/addons/edi/static/src/xml/edi.xml index 567e244caeb..2da35fae2ea 100644 --- a/addons/edi/static/src/xml/edi.xml +++ b/addons/edi/static/src/xml/edi.xml @@ -6,7 +6,9 @@ @@ -14,8 +16,10 @@
-
diff --git a/addons/edi/static/src/xml/edi_account.xml b/addons/edi/static/src/xml/edi_account.xml index d422f76431d..47bf97d26fb 100644 --- a/addons/edi/static/src/xml/edi_account.xml +++ b/addons/edi/static/src/xml/edi_account.xml @@ -1,123 +1,136 @@ diff --git a/addons/edi/static/src/xml/edi_sale_purchase.xml b/addons/edi/static/src/xml/edi_sale_purchase.xml index 12af4b0a147..dc6d9330af0 100644 --- a/addons/edi/static/src/xml/edi_sale_purchase.xml +++ b/addons/edi/static/src/xml/edi_sale_purchase.xml @@ -1,80 +1,137 @@ diff --git a/addons/purchase/edi/purchase_order.py b/addons/purchase/edi/purchase_order.py index 939fd9f9a6e..d6909b381fc 100644 --- a/addons/purchase/edi/purchase_order.py +++ b/addons/purchase/edi/purchase_order.py @@ -35,6 +35,9 @@ PURCHASE_ORDER_LINE_EDI_STRUCT = { 'price_unit': True, 'product_qty': True, 'notes': True, + + # fields used for web preview only - discarded on import + 'price_subtotal': True, } PURCHASE_ORDER_EDI_STRUCT = { @@ -174,6 +177,7 @@ class purchase_order(osv.osv, EDIMixin): edi_document.pop('amount_total', None) edi_document.pop('amount_tax', None) edi_document.pop('amount_untaxed', None) + edi_document.pop('payment_term', None) for order_line in edi_document['order_line']: self._edi_requires_attributes(('date_planned', 'product_id', 'product_uom', 'product_qty', 'price_unit'), order_line) @@ -185,6 +189,8 @@ class purchase_order(osv.osv, EDIMixin): # sale order lines have sequence numbers, not purchase order lines order_line.pop('sequence', None) + # discard web preview fields, if present + order_line.pop('price_subtotal', None) return super(purchase_order,self).edi_import(cr, uid, edi_document, context=context) class purchase_order_line(osv.osv, EDIMixin): diff --git a/addons/purchase/edi/purchase_order_action_data.xml b/addons/purchase/edi/purchase_order_action_data.xml index 956c257608d..c8c83efed6f 100644 --- a/addons/purchase/edi/purchase_order_action_data.xml +++ b/addons/purchase/edi/purchase_order_action_data.xml @@ -3,19 +3,7 @@ - ") - - # accessing the template will fail if it has been deleted - so we'll skip everything - tmpl = self.pool.get('ir.model.data').get_object(cr, uid, 'purchase', 'email_template_edi_purchase') - - edi_token = self.pool.get('edi.document').export_edi(cr, uid, [object], context = context)[0] - context.update(edi_web_url_view='%s/web/view_edi?db=%s&token=%s' %(web_root_url, cr.dbname, edi_token)) - self.pool.get('email.template').send_mail(cr, uid,tmpl.id,object.id,context=context) -except: - pass]]> + code ir.actions.server @@ -63,7 +51,7 @@ except:

You can view the order confirmation document, download it and pay online using the following link:

- View Order % if object.company_id.paypal_account: @@ -80,7 +68,7 @@ except: %>

It is also possible to directly pay with Paypal:

- Pay with Paypal % endif @@ -89,12 +77,12 @@ except:

Thank you for choosing ${object.company_id.name or 'us'}!



-
-

+
+

${object.company_id.name}

-
- +
+ % if object.company_id.street: ${object.company_id.street}
% endif diff --git a/addons/sale/edi/sale_order.py b/addons/sale/edi/sale_order.py index ba79f543650..9fd332ed345 100644 --- a/addons/sale/edi/sale_order.py +++ b/addons/sale/edi/sale_order.py @@ -36,6 +36,9 @@ SALE_ORDER_LINE_EDI_STRUCT = { #custom: 'product_qty' 'discount': True, 'notes': True, + + # fields used for web preview only - discarded on import + 'price_subtotal': True, } SALE_ORDER_EDI_STRUCT = { @@ -53,6 +56,7 @@ SALE_ORDER_EDI_STRUCT = { 'amount_total': True, 'amount_untaxed': True, 'amount_tax': True, + 'payment_term': True, } class sale_order(osv.osv, EDIMixin): @@ -186,6 +190,9 @@ class sale_order(osv.osv, EDIMixin): delay = (datetime.strptime(date_planned, DEFAULT_SERVER_DATE_FORMAT) - \ datetime.strptime(date_order, DEFAULT_SERVER_DATE_FORMAT)).days order_line['delay'] = delay + + # discard web preview fields, if present + order_line.pop('price_subtotal', None) return super(sale_order,self).edi_import(cr, uid, edi_document, context=context) class sale_order_line(osv.osv, EDIMixin): diff --git a/addons/sale/edi/sale_order_action_data.xml b/addons/sale/edi/sale_order_action_data.xml index a0085c42092..943473cc140 100644 --- a/addons/sale/edi/sale_order_action_data.xml +++ b/addons/sale/edi/sale_order_action_data.xml @@ -3,19 +3,7 @@ - ") - - # accessing the template will fail if it has been deleted - so we'll skip everything - tmpl = self.pool.get('ir.model.data').get_object(cr, uid, 'sale', 'email_template_edi_sale') - - edi_token = self.pool.get('edi.document').export_edi(cr, uid, [object], context = context)[0] - context.update(edi_web_url_view='%s/edi/view?debug=1&db=%s&token=%s' %(web_root_url, cr.dbname, edi_token)) - self.pool.get('email.template').send_mail(cr, uid,tmpl.id,object.id,context=context) -except: - pass]]> + code ir.actions.server @@ -65,7 +53,7 @@ except:

You can view the order confirmation document, download it and pay online using the following link:

- View Order % if object.company_id.paypal_account: @@ -82,7 +70,7 @@ except: %>

It is also possible to directly pay with Paypal:

- Pay with Paypal % endif @@ -91,12 +79,12 @@ except:

Thank you for choosing ${object.company_id.name or 'us'}!



-
-

+
+

${object.company_id.name}

-
- +
+ % if object.company_id.street: ${object.company_id.street}
% endif

-

- +

+

@@ -42,6 +46,7 @@

+