From 5fa1a6dd068c57ffda5d817ef7fceaa757caa5a0 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 28 Oct 2011 13:33:57 +0200 Subject: [PATCH] [IMP] edi: improve EDI preview sidebar bzr revid: odo@openerp.com-20111028113357-ymc6amfurpyo17e9 --- addons/edi/static/src/css/edi.css | 34 +++++++++++++++++++++--- addons/edi/static/src/js/edi.js | 44 +++++++++++++++++++++---------- addons/edi/static/src/xml/edi.xml | 42 ++++++++++++++++++----------- 3 files changed, 88 insertions(+), 32 deletions(-) diff --git a/addons/edi/static/src/css/edi.css b/addons/edi/static/src/css/edi.css index 88cb22fe9ca..0cd977c1512 100644 --- a/addons/edi/static/src/css/edi.css +++ b/addons/edi/static/src/css/edi.css @@ -31,7 +31,7 @@ button.oe_edi_action_print img { font-size: 1.3em; } .oe_edi_nested_block { - margin-left: 25px; + margin: 0px 40px; padding: 0px; display: none; /* made visible by click on parent input/label */ } @@ -51,7 +51,10 @@ button.oe_edi_action_print img { background: #e8e8e8; } .oe_edi_import_button { - margin: 1em 2em; + margin: 2px 10px; +} +.oe_edi_small, .oe_edi_small input { + font-size: 90%; } /** Paperbox, from http://www.sitepoint.com/pure-css3-paper-curl/ **/ @@ -166,4 +169,29 @@ table.oe_edi_data, .oe_edi_doc_title { } .oe_edi_summary_value { float: right; -} \ No newline at end of file +} + + +/** Python code highlighting **/ +/* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann + (http://qbnz.com/highlighter/ and http://geshi.org/) */ +.python .de1, .python .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;} +.python {font-family:monospace;} +.python .imp {font-weight: bold; color: red;} +.python li, .python .li1 {background: #ffffff; list-style: none;} +.python .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;} +.python .li2 {background: #f8f8f8;} +.python .kw1 {color: #ff7700;font-weight:bold;} +.python .kw2 {color: #008000;} +.python .kw3 {color: #dc143c;} +.python .kw4 {color: #0000cd;} +.python .co1 {color: #808080; font-style: italic;} +.python .coMULTI {color: #808080; font-style: italic;} +.python .es0 {color: #000099; font-weight: bold;} +.python .br0 {color: black;} +.python .sy0 {color: #66cc66;} +.python .st0 {color: #483d8b;} +.python .nu0 {color: #ff4500;} +.python .me1 {color: black;} +.python span.xtra { display:block; } +.python ol { padding: 0px; } \ 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 859935ab9eb..d3cbc0486c0 100644 --- a/addons/edi/static/src/js/edi.js +++ b/addons/edi/static/src/js/edi.js @@ -36,25 +36,41 @@ openerp.edi.EdiView = openerp.web.Widget.extend({ 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); + this.$element.find('button#oe_edi_import_existing').bind('click', this.do_import_existing); + this.$element.find('button#oe_edi_import_create').bind('click', this.do_import_create); + this.$element.find('button#oe_edi_download').bind('click', this.do_download); + this.$element.find('.oe_edi_import_choice, .oe_edi_import_choice_label').bind('click', this.toggle_choice); + this.$element.find('#oe_edi_download_show_code').bind('click', this.show_code); + }, + show_code: function($event) { + $('#oe_edi_download_code').show(); + return false; + }, + get_download_url: function() { + var l = window.location; + var url_prefix = l.protocol + '//' + l.host; + return url_prefix +'/edi/download?db=' + this.db + '&token=' + this.token; + }, + toggle_choice: function($e) { + $('.oe_edi_nested_block').hide(); + $('.'+$e.target.id+'_nested').show(); + return true; }, do_print: function(e){ var l = window.location; window.location = l.protocol + '//' + l.host + "/edi/download_attachment?db=" + this.db + "&token=" + this.token; }, - do_import: function(e){ - var l = window.location; - var url_prefix = l.protocol + '//' + l.host; - var url_download = url_prefix +'/edi/download?db=' + this.db + '&token=' + this.token; - - if (this.$element.find('#oe_edi_import_openerp').attr('checked') == 'checked') { - var server_url = this.$element.find('#oe_edi_txt_server_url').val() - window.location = 'http://' + server_url + '/edi/import_url?url=' + encodeURIComponent(url_download); - } else if (this.$element.find('#oe_edi_import_saas').attr('checked') == 'checked') { - window.location = "https://cc.my.openerp.com/odms/create_edi?url=" + encodeURIComponent(url_download); - } else if (this.$element.find('#oe_edi_import_download').attr('checked') == 'checked') { - window.location = url_download - } + do_import_existing: function(e) { + var url_download = this.get_download_url(); + var server_url = this.$element.find('#oe_edi_txt_server_url').val() + window.location = 'http://' + server_url + '/edi/import_url?url=' + encodeURIComponent(url_download); + }, + do_import_create: function(e){ + var url_download = this.get_download_url(); + window.location = "https://cc.my.openerp.com/odms/create_edi?url=" + encodeURIComponent(url_download); + }, + do_download: function(e){ + window.location = this.get_download_url(); } }); diff --git a/addons/edi/static/src/xml/edi.xml b/addons/edi/static/src/xml/edi.xml index 7c455b6f4c7..cfbb55189d6 100644 --- a/addons/edi/static/src/xml/edi.xml +++ b/addons/edi/static/src/xml/edi.xml @@ -29,38 +29,50 @@ -

+


- http:// + http://
+

+

+ +

- - +

+ OpenERP's Electronic Data Interchange documents are based on a generic and language + independent JSON serialization of the document's attribute. + It is usually very quick and straightforward to create a small plug-in for your preferred + application that will be capable of importing any OpenERP EDI document. + You can find out more details about how to do this and what the content of OpenERP EDI documents + is like in the OpenERP documentation. +
+ To get started immediately, see is all it takes to use this EDI document in Python. +

+
+
  1. import urllib2, simplejson
  2. +
  3. edi_document = urllib2.urlopen('').read()
  4. +
  5. document_data = simplejson.loads(edi_document)[0]
  6. +
  7. print "Amount: ", document_data['amount_total']
  8. +
+

+ You can download the raw EDI document here:
+ + +

- -