[IMP] edi web layer cleanups

bzr revid: al@openerp.com-20111018140627-str2i0uj4aswf3jx
This commit is contained in:
Antony Lesuisse 2011-10-18 16:06:27 +02:00
parent eec383a897
commit dbb5b3862a
18 changed files with 489 additions and 841 deletions

View File

@ -44,11 +44,9 @@ technical OpenERP documentation at http://doc.openerp.com
'test/edi_partner_test.yml',
],
'js': [
'static/src/js/sessionless.js',
'static/src/js/edi_import.js',
'static/src/js/edi_view.js',
'static/src/js/edi_invoice.js',
'static/src/js/edi_sale_purchase_order.js',
'static/src/js/edi.js',
#'static/src/js/edi_invoice.js',
#'static/src/js/edi_sale_purchase_order.js',
],
"css": [
"static/src/css/edi.css"
@ -58,4 +56,4 @@ technical OpenERP documentation at http://doc.openerp.com
'certificate': '002046536359186',
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,3 +1 @@
import edi_get
import edi_view
import edi_import
import main

View File

@ -1,25 +0,0 @@
import werkzeug.wrappers
import web.common.http as openerpweb
import json
class EDIGet(openerpweb.Controller):
# http://path.to.web.client:8080/web/get_edi?db=XXXX&token=XXXXXXXXXXX
_cp_path = "/web/get_edi"
@openerpweb.httprequest
def index(self, req, db, token):
result = req.session.proxy('edi').get_edi_document(db, token)
response = werkzeug.wrappers.Response(
result, headers=[('Content-Type', 'text/html; charset=utf-8'),
('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)
document = json.loads(result)
model = document and document[0].get('__model')
return {'token': token, 'db': db, 'model':model.replace('.','_'), 'document':document}

View File

@ -1,65 +0,0 @@
import werkzeug.wrappers
import web.common.http as openerpweb
import web.controllers.main as web
import json
import textwrap
edi_import_template = textwrap.dedent("""<!DOCTYPE html>
<html style="height: 100%%">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>OpenERP</title>
<link rel="shortcut icon" href="/web/static/src/img/favicon.ico" type="image/x-icon"/>
%(css)s
%(javascript)s
<script type="text/javascript" src="/edi/static/src/js/edi_import.js"></script>
<script type="text/javascript">
$(function() {
var c = new openerp.init();
openerp.web.edi_import(c)
var import_engine = new c.web.EdiImport("oe");
import_engine.import_edi('%(edi_url)s');
});
</script>
</head>
<body id="oe" class="openerp"></body>
</html>
""")
class EDIImport(web.WebClient):
#http://localhost:8002/web/import_edi?edi_url=XXXXX
# Note: edi_url should have url which passed from encodeURIComponent function
_cp_path = "/web/import_edi"
@openerpweb.httprequest
def index(self, req, edi_url):
# script tags
addons = ['web']
jslist = ['/web/view_edi/js']
if req.debug:
jslist = [i + '?debug=' + str(time.time()) for i in web.manifest_glob(req.config.addons_path, addons, 'js')]
js = "\n ".join(['<script type="text/javascript" src="%s"></script>'%i for i in jslist])
# css tags
csslist = ['/web/view_edi/css']
if req.debug:
csslist = [i + '?debug=' + str(time.time()) for i in web.manifest_glob(req.config.addons_path, addons, 'css')]
css = "\n ".join(['<link rel="stylesheet" href="%s">'%i for i in csslist])
r = edi_import_template % {
'javascript': js,
'css': css,
'edi_url': edi_url,
}
return r
@openerpweb.jsonrequest
def import_edi_url(self, req, edi_url):
# call EDI Service: import_edi_url
result = req.session.proxy('edi').import_edi_url(req.session._db, req.session._uid, req.session._password, edi_url)
return result

View File

@ -1,94 +0,0 @@
import werkzeug.wrappers
import web.common.http as openerpweb
import web.controllers.main as web
import json
import textwrap
edi_view_template = textwrap.dedent("""<!DOCTYPE html>
<html style="height: 100%%">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>OpenERP</title>
<link rel="shortcut icon" href="/web/static/src/img/favicon.ico" type="image/x-icon"/>
%(css)s
%(javascript)s
<script type="text/javascript">
$(function() {
var c = new openerp.init();
var files = eval(%(edi_js)s);
for(var i=0; i<files.length; i++) {
if(openerp.web[files[i]]) {
openerp.web[files[i]](c);
}
}
var edi_engine = new c.web.EdiView("oe");
edi_engine.view_edi('%(token)s', '%(db)s');
});
</script>
</head>
<body id="oe" class="openerp"></body>
</html>
""")
def edi_addons():
#FIXME: hardcoded to be able to test
return 'web,edi'
_addons = ['web', 'edi', 'sale', 'purchase']
for addon in openerpweb.addons_module:
if addon in _addons:
continue
manifest = openerpweb.addons_manifest.get(addon, {})
edi_addon = manifest.get('edi', False)
if edi_addon:
_addons.append(addon)
return _addons
class EDIView(web.WebClient):
# http://path.to.web.client:8080/web/view_edi?db=XXX&token=XXXXXXXXXXX
_cp_path = "/web/view_edi"
@openerpweb.httprequest
def css(self, req):
files = self.manifest_glob(req, edi_addons(), 'css')
content,timestamp = web.concat_files(req.config.addons_path[0], files)
# TODO request set the Date of last modif and Etag
return req.make_response(content, [('Content-Type', 'text/css')])
@openerpweb.httprequest
def js(self, req):
files = self.manifest_glob(req, edi_addons(), 'js')
content,timestamp = web.concat_files(req.config.addons_path[0], files)
# TODO request set the Date of last modif and Etag
return req.make_response(content, [('Content-Type', 'application/javascript')])
@openerpweb.httprequest
def index(self, req, token, db):
# script tags
addons = edi_addons()
jslist = ['/web/view_edi/js']
if req.debug:
jslist = [i + '?debug=' + str(time.time()) for i in self.manifest_glob(req, addons, 'js')]
js = "\n ".join(['<script type="text/javascript" src="%s"></script>'%i for i in jslist])
# css tags
csslist = ['/web/view_edi/css']
if req.debug:
csslist = [i + '?debug=' + str(time.time()) for i in self.manifest_glob(req, addons, 'css')]
css = "\n ".join(['<link rel="stylesheet" href="%s">'%i for i in csslist])
js_files = [str(js_file.split('/')[-1].split('.')[0]) for js_file in self.manifest_glob(req, addons, 'js')]
r = edi_view_template % {
'javascript': js,
'css': css,
'token': token,
'db': db,
'edi_js': js_files
}
return r

View File

@ -0,0 +1,73 @@
import json
import textwrap
import simplejson
import werkzeug.wrappers
import web.common.http as openerpweb
import web.controllers.main as web
edi_template = textwrap.dedent("""<!DOCTYPE html>
<html style="height: 100%%">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>OpenERP</title>
<link rel="shortcut icon" href="/web/static/src/img/favicon.ico" type="image/x-icon"/>
%(css)s
%(js)s
<script type="text/javascript">
$(function() {
var c = new openerp.init(%(modules)s);
//var wc = new c.web.WebClient("oe");
%(init)s
});
</script>
</head>
<body id="oe" class="openerp"></body>
</html>
""")
class EDI(openerpweb.Controller):
# http://hostname:8069/edi/view?db=XXXX&token=XXXXXXXXXXX
# http://hostname:8069/edi/import_url?url=URIEncodedURL
_cp_path = "/edi"
def template(self, req, mods='web,edi'):
self.wc = openerpweb.controllers_path['/web/webclient']
d = {}
d["js"] = "\n".join('<script type="text/javascript" src="%s"></script>'%i for i in self.wc.manifest_list(req, mods, 'js'))
d["css"] = "\n".join('<link rel="stylesheet" href="%s">'%i for i in self.wc.manifest_list(req, mods, 'css'))
d["modules"] = simplejson.dumps(mods.split(','))
return d
@openerpweb.httprequest
def view(self, req, db, token):
d = self.template(req)
d["init"] = 'var e = new c.edi.EdiView(null,"%s","%s");e.appendTo($("body"));'%(db,token)
r = edi_template % d
return r
@openerpweb.httprequest
def import_url(self, req, url):
d = self.template(req)
d["init"] = 'var e = new c.edi.EdiImportUrl(null,"%s");e.appendTo($("body"));'%(url)
r = edi_template % d
return r
@openerpweb.httprequest
def download(self, req, db, token):
result = req.session.proxy('edi').get_edi_document(db, token)
response = werkzeug.wrappers.Response( result, headers=[('Content-Type', 'text/html; charset=utf-8'), ('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)
return json.loads(result)
@openerpweb.jsonrequest
def import_edi_url(self, req, url):
result = req.session.proxy('edi').import_edi_url(req.session._db, req.session._uid, req.session._password, url)
return result
#

View File

@ -0,0 +1,165 @@
openerp.edi = function(openerp) {
openerp.web.qweb.add_template("/edi/static/src/xml/edi.xml");
openerp.web.qweb.add_template("/edi/static/src/xml/edi_account.xml");
openerp.web.qweb.add_template("/edi/static/src/xml/edi_sale_purchase.xml");
openerp.edi = {}
openerp.edi.EdiView = openerp.web.Widget.extend({
init: function(parent, db, token) {
this._super();
var self = this;
this.db = db;
this.token = token;
this.session = new openerp.web.Session();
this.template = "EdiEmpty";
},
start: function() {
this._super();
var param = {"db": this.db, "token": this.token};
console.log("load",param);
this.rpc('/edi/get_edi_document', param, this.on_document_loaded);
},
on_document_loaded: function(docs){
this.doc = docs[0];
//console.log("docs",this.doc);
var template = "Edi." + this.doc.__model;
var param = {"widget":this, "doc":this.doc};
this.center = openerp.web.qweb.render(template, param);
//console.log(this.center);
this.right = "";
this.$element.html(openerp.web.qweb.render("EdiView", param ));
//self.$element.delegate('button.oe_edi_button_import', 'click', this.do_import);
},
do_import: function(e){
$element = $(e.view.document.body)
token = e.data.edi.token
db = e.data.edi.db
var current_url = $(location).attr('href')
var pathName = current_url.substring(0, current_url.lastIndexOf('/') +1);
if ($element.find('#oe_edi_rd_import_openerp').attr('checked') == 'checked') {
server_url = $element.find('#oe_edi_txt_server_url').val()
edi_url = pathName + 'get_edi?db=' + db + '&token=' + token
edi_url = encodeURIComponent(edi_url)
window.location = 'http://' + server_url + '/web/import_edi?edi_url=' + edi_url
}
if ($element.find('#oe_edi_rd_import_saas_account').attr('checked') == 'checked') {
// create SAAS Account
}
if ($element.find('#oe_edi_rd_import_other').attr('checked') == 'checked') {
// GET EDI document
edi_url = pathName + 'get_edi?db=' + db + '&token=' + token
window.location = edi_url
}
}
});
openerp.edi.EdiImport = openerp.web.Widget.extend({
init: function(parent,url) {
this._super();
this.url = url;
this.session = new openerp.web.Session();
this.template = "EdiEmpty";
},
start: function() {
},
do_import: function(){
var self = this;
self.rpc('/web/import_edi/import_edi_url', self.params, function(response){
if (response.length) {
$('<div>Import successful, click Ok to see the new document</div>').dialog({
modal: true,
title: 'Successful',
buttons: {
Ok: function() {
$(this).dialog("close");
var action = {
"res_model": response[0][0],
"res_id": parseInt(response[0][1], 10),
"views":[[false,"form"]],
"type":"ir.actions.act_window",
"view_type":"form",
"view_mode":"form"
}
action.flags = {
search_view: false,
sidebar : false,
views_switcher : false,
action_buttons : false,
pager: false
}
var action_manager = new openerp.web.ActionManager(self);
action_manager.appendTo($("#oe_app"));
action_manager.start();
action_manager.do_action(action);
}
}
});
}
else{
$(QWeb.render("DialogWarning", "Sorry, Import is not successful.")).dialog({
modal: true,
buttons: {
Ok: function() {
$(this).dialog("close");
}
}
});
}
});
},
import_edi: function(edi_url) {
var self = this;
this.params = {};
if(edi_url) this.params['edi_url'] = decodeURIComponent(edi_url);
if (!this.session.db){
this.start();
this.session.on_session_valid.add_last(self.do_import);
} else{
self.do_import();
}
}
});
openerp.edi.EdiViewCenterInvoice = openerp.web.Class.extend({
init: function(element, edi){
var self = this;
this.edi_document = eval(edi.document)
this.$element = element;
QWeb.add_template("/web_edi_invoice/static/src/xml/edi_invoice.xml");
this.$_element = $('<div>')
.appendTo(document.body)
.delegate('#oe_edi_invoice_button_pay', 'click', {'edi': edi} , this.do_pay)
},
start: function() {
},
render: function(){
template = "InvoiceEdiView";
if (this.$current) {
this.$current.remove();
}
this.$current = this.$_element.clone(true);
this.$current.empty().append($(QWeb.render(template, {'invoices': this.edi_document})));
this.$element.append(this.$current);
},
do_pay: function(e){
$element = $(e.view.document.body)
token = e.data.edi.token
db = e.data.edi.db
var current_url = $(location).attr('href')
var pathName = current_url.substring(0, current_url.lastIndexOf('/') +1);
if ($element.find('#oe_edi_invoice_rd_pay_paypal').attr('checked') == 'checked') {
alert('Pay Invoice using Paypal service');
}
if ($element.find('#oe_edi_invoice_rd_pay_google_checkout').attr('checked') == 'checked') {
alert('Pay Invoice using Google Checkout');
}
if ($element.find('#oe_edi_invoice_rd_pay_bank').attr('checked') == 'checked') {
alert('Pay Invoice using Bankwire Trasnfer')
}
}
});
}
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:

View File

@ -1,75 +0,0 @@
openerp.web.edi_import = function(openerp) {
var QWeb = new QWeb2.Engine();
openerp.web.EdiImport = openerp.web.WebClient.extend({
init: function(element_id) {
this._super(element_id);
},
start: function() {
this._super();
},
do_import: function(){
var self = this;
self.rpc('/web/import_edi/import_edi_url', self.params, function(response){
if (response.length) {
$('<div>Import successful, click Ok to see the new document</div>').dialog({
modal: true,
title: 'Successful',
buttons: {
Ok: function() {
$(this).dialog("close");
var action = {
"res_model": response[0][0],
"res_id": parseInt(response[0][1], 10),
"views":[[false,"form"]],
"type":"ir.actions.act_window",
"view_type":"form",
"view_mode":"form"
}
action.flags = {
search_view: false,
sidebar : false,
views_switcher : false,
action_buttons : false,
pager: false
}
var action_manager = new openerp.web.ActionManager(self);
action_manager.appendTo($("#oe_app"));
action_manager.start();
action_manager.do_action(action);
}
}
});
}
else{
$(QWeb.render("DialogWarning", "Sorry, Import is not successful.")).dialog({
modal: true,
buttons: {
Ok: function() {
$(this).dialog("close");
}
}
});
}
});
},
import_edi: function(edi_url) {
var self = this;
this.params = {};
if(edi_url) this.params['edi_url'] = decodeURIComponent(edi_url);
if (!this.session.db){
this.start();
this.session.on_session_valid.add_last(self.do_import);
}
else{
self.do_import();
}
}
});
}
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:

View File

@ -1,9 +1,8 @@
/*---------------------------------------------------------
* EDI Web Interface for Invoice
*---------------------------------------------------------*/
//
openerp.web.edi_invoice = function(openerp) {
openerp.edi.edi_invoice = function(openerp) {
var QWeb = new QWeb2.Engine();
openerp.web.edi_views.add('view_center_account_invoice' , 'openerp.web.EdiViewCenterInvoice');
@ -35,17 +34,13 @@ openerp.web.EdiViewCenterInvoice = openerp.web.Class.extend({
var current_url = $(location).attr('href')
var pathName = current_url.substring(0, current_url.lastIndexOf('/') +1);
if ($element.find('#oe_edi_invoice_rd_pay_paypal').attr('checked') == 'checked')
{
if ($element.find('#oe_edi_invoice_rd_pay_paypal').attr('checked') == 'checked') {
alert('Pay Invoice using Paypal service');
}
if ($element.find('#oe_edi_invoice_rd_pay_google_checkout').attr('checked') == 'checked')
{
if ($element.find('#oe_edi_invoice_rd_pay_google_checkout').attr('checked') == 'checked') {
alert('Pay Invoice using Google Checkout');
}
if ($element.find('#oe_edi_invoice_rd_pay_bank').attr('checked') == 'checked')
{
if ($element.find('#oe_edi_invoice_rd_pay_bank').attr('checked') == 'checked') {
alert('Pay Invoice using Bankwire Trasnfer')
}
}

View File

@ -1,23 +0,0 @@
openerp.web.edi_sale_purchase_order = function(openerp) {
var QWeb = new QWeb2.Engine();
openerp.web.edi_views.add('view_center_sale_order' , 'openerp.web.EdiViewCenterSalePurchase');
openerp.web.edi_views.add('view_center_purchase_order' , 'openerp.web.EdiViewCenterSalePurchase');
openerp.web.EdiViewCenterSalePurchase = openerp.web.Class.extend({
init: function(element, edi){
var self = this;
this.edi_document = eval(edi.document)
this.$element = element;
QWeb.add_template("/edi/static/src/xml/edi_sale_purchase_order.xml");
},
start: function() {
},
render: function(){
template = "OrderEdiView";
this.$element.append($(QWeb.render(template, {'orders': this.edi_document})));
},
});
}
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:

View File

@ -1,148 +0,0 @@
openerp.web.edi_view = function(openerp) {
openerp.web.edi_views = new openerp.web.Registry();
var QWeb = new QWeb2.Engine();
// EDI View Engine
openerp.web.EdiView = openerp.web.Sessionless.extend({
init: function(element_id){
var self = this;
this.template = "EdiView";
this.element_id = element_id;
this.$element = $('#' + element_id);
QWeb.add_template("/edi/static/src/xml/edi.xml");
},
start: function() {
},
view_edi: function(token, db) {
var params = {};
if(token) params['token'] = token;
if(db) params['db'] = db;
this.rpc('/web/get_edi/get_edi_document', params, this.on_response);
},
on_response: function(value){
var self = this;
this.template = "EdiView";
this.element_id = "oe";
self.$element = $('#' + this.element_id);
self.$element.html(QWeb.render(self.template, this));
var edi_document = value.document;
var render = function(key, element_id, response){
var registry = openerp.web.edi_views;
model = response.model
// get namespace of view of particular model from registry
try {
edi_view = registry.get_object(key + '_' + model);
}catch (e) {
edi_view = undefined;
}
// if not found, take default namespace of view
if (edi_view == undefined){
edi_view = registry.get_object(key)
}
$edi_frame = self.$element.find(element_id);
// create instance of QWeb of view namespace
edi_qweb = new (edi_view)($edi_frame, response)
edi_qweb.render();
};
// EDI Center Frame
render('view_center', 'div.oe_edi_center', value)
// EDI Right TOP Frame
render('view_right_top', 'div.oe_edi_right_top', value)
//EDI Right Bottom Frame
render('view_right_bottom', 'div.oe_edi_right_bottom', value)
},
});
openerp.web.edi_views.add('view_center' , 'openerp.web.EdiViewCenter');
openerp.web.EdiViewCenter = openerp.web.Class.extend({
init: function(element, edi){
var self = this;
this.edi_document = edi.document;
this.$element = element;
QWeb.add_template("/edi/static/src/xml/edi.xml");
},
start: function() {
},
render: function(){
template = "EdiViewCenter";
this.$element.append($(QWeb.render(template, {'view': this})))
}
});
openerp.web.edi_views.add('view_right_top' , 'openerp.web.EdiViewRightTop');
openerp.web.EdiViewRightTop = openerp.web.Class.extend({
init: function(element, edi){
var self = this;
this.edi_document = edi.document;
this.$element = element;
QWeb.add_template("/edi/static/src/xml/edi.xml");
this.$_element = $('<div>')
.appendTo(document.body)
.delegate('button.oe_edi_button_import', 'click', {'edi': edi} , this.do_import)
},
start: function() {
},
render: function(){
template = "EdiViewRightTop";
if (this.$current) {
this.$current.remove();
}
this.$current = this.$_element.clone(true);
this.$current.empty().append(QWeb.render(template, this));
this.$element.append(this.$current);
},
do_import: function(e){
$element = $(e.view.document.body)
token = e.data.edi.token
db = e.data.edi.db
var current_url = $(location).attr('href')
var pathName = current_url.substring(0, current_url.lastIndexOf('/') +1);
if ($element.find('#oe_edi_rd_import_openerp').attr('checked') == 'checked')
{
// import EDI
server_url = $element.find('#oe_edi_txt_server_url').val()
edi_url = pathName + 'get_edi?db=' + db + '&token=' + token
edi_url = encodeURIComponent(edi_url)
window.location = 'http://' + server_url + '/web/import_edi?edi_url=' + edi_url
}
if ($element.find('#oe_edi_rd_import_saas_account').attr('checked') == 'checked')
{
// create SAAS Account
}
if ($element.find('#oe_edi_rd_import_other').attr('checked') == 'checked')
{
// GET EDI document
edi_url = pathName + 'get_edi?db=' + db + '&token=' + token
window.location = edi_url
}
}
});
openerp.web.edi_views.add('view_right_bottom' , 'openerp.web.EdiViewRightBottom');
openerp.web.EdiViewRightBottom = openerp.web.Class.extend({
init: function(element, edi){
var self = this;
this.edi_document = edi.document;
this.$element = element;
QWeb.add_template("/edi/static/src/xml/edi.xml");
},
start: function() {
},
render: function(){
template = "EdiViewRightBottom";
this.$element.append($(QWeb.render(template, this)))
}
});
}
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:

View File

@ -1,75 +0,0 @@
openerp.web.sessionless = function(openerp) {
var QWeb = new QWeb2.Engine();
openerp.web.Sessionless = openerp.web.SessionAware.extend({
rpc: function(url, params, success_callback, error_callback) {
var self = this;
// Call using the rpc_mode
var deferred = $.Deferred();
this.rpc_ajax(url, {
jsonrpc: "2.0",
method: "call",
params: params,
id:null
}).then(function () {deferred.resolve.apply(deferred, arguments);},
function(error) {deferred.reject(error, $.Event());});
return deferred.fail(function() {
deferred.fail(function(error, event) {
if (!event.isDefaultPrevented()) {
self.on_rpc_error(error, event);
}
});
}).then(success_callback, error_callback).promise();
},
/**
* Raw JSON-RPC call
*
* @returns {jQuery.Deferred} ajax-webd deferred object
*/
rpc_ajax: function(url, payload) {
var self = this;
this.on_rpc_request();
// url can be an $.ajax option object
if (_.isString(url)) {
url = {
url: url
}
}
var ajax = _.extend({
type: "POST",
url: url,
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify(payload),
processData: false
}, url);
var deferred = $.Deferred();
$.ajax(ajax).done(function(response, textStatus, jqXHR) {
self.on_rpc_response();
if (!response.error) {
deferred.resolve(response["result"], textStatus, jqXHR);
return;
}
if (response.error.data.type !== "session_invalid") {
deferred.reject(response.error);
return;
}
}).fail(function(jqXHR, textStatus, errorThrown) {
self.on_rpc_response();
var error = {
code: -32098,
message: "XmlHttpRequestError " + errorThrown,
data: {type: "xhr"+textStatus, debug: jqXHR.responseText, objects: [jqXHR, errorThrown] }
};
deferred.reject(error);
});
return deferred.promise();
},
on_rpc_request: function() {
},
on_rpc_response: function() {
},
on_rpc_error: function(error) {
},
});
}

View File

@ -1,100 +1,57 @@
<template>
<t t-name="EdiEmpty">
<div></div>
</t>
<t t-name="EdiView">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%" class="oe_forms">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%" id="oe_app" class="oe-application,oe_forms">
<tr>
<td colspan="2" valign="top">
<div id="oe_header" class="header">
<div>
<a href="/" class="company_logo_link">
<div class="company_logo" />
</a>
</div>
<div class="header_corner">
<button type="button" name="action_print">View/Print PDF</button>
</div>
</div>
<td colspan="2" valign="top" id="oe_header" class="header">
<div> <a href="/" class="company_logo_link"> <div class="company_logo" /> </a> </div>
<div class="header_corner"> <button type="button" name="action_print">View/Print PDF</button> </div>
</td>
</tr>
<tr>
<td colspan="2" valign="top" height="100%">
<table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
<tr>
<td valign="top" class="oe-application-container">
<div id="oe_app" class="oe-application">
<table width="100%" height="100%">
<tr class="oe_edi_preview_container">
<td class="oe_edi_preview">
<div class="oe_edi_center">
</div>
<div class="oe_edi_center_bottom" align="center">
<button type="button" name="action_print">View/Print PDF</button>
</div>
</td>
<td class="oe_edi_sidebar_container">
<div class="oe_edi_right_top">
</div>
<div class="oe_edi_right_bottom">
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<td class="oe_edi_view">
<p class="oe_form_paragraph"><t t-raw="widget.center"/></p>
</td>
</tr>
<tr>
<td colspan="2">
<div id="oe_footer" class="oe_footer">
<p class="oe_footer_powered">Powered by <a href="http://www.openerp.com">OpenERP</a>.</p>
</div>
</td>
</tr>
</table>
</t>
<t t-name="EdiViewCenter">
<div>
<p class="oe_form_paragraph"><t t-esc="view.value"/></p>
</div>
</t>
<td class="oe_edi_sidebar_container">
<button type="button" name="action_print">View/Print PDF</button>
<t t-name="EdiViewRightTop">
<div>
<p class="oe_edi_sidebar_title">
Push this document into your enterprise management system
</p>
<p>
<input type="radio" id="oe_edi_rd_import_openerp" name="oe_edi_rd_import" value="oe_edi_import_openerp"/>
<label for="oe_edi_rd_import_openerp">Import it into an existing OpenERP instance</label>
<p class="oe_edi_nested_block">
<label for="oe_edi_txt_saas_url">OpenERP instance address:</label> http://<input type="text" id="oe_edi_txt_server_url"/>
<p class="oe_edi_sidebar_title">
Push this document into your enterprise management system
</p>
</p>
<p>
<input type="radio" id="oe_edi_rd_import_saas_account" name="oe_edi_rd_import" value="oe_edi_create_saas_account"/>
<label for="oe_edi_rd_import_saas_account">Create a new OpenERP instance:</label>
<p class="oe_edi_nested_block"><label for="oe_edi_txt_saas_url">Company:</label><input type="text" name="oe_edi_txt_saas_url"/>.my.openerp.com</p>
<p class="oe_edi_nested_block"><label for="oe_edi_txt_saas_password">Password:</label><input type="password" name="oe_edi_txt_saas_password"/></p>
<p class="oe_edi_nested_block"><label for="oe_edi_txt_saas_email">Email:</label><input type="text" name="oe_edi_txt_saas_email"/></p>
</p>
<p>
<input type="radio" id="oe_edi_rd_import_other" name="oe_edi_rd_import" value="oe_edi_import_other"/>
<label for="oe_edi_rd_import_other">Import into another application</label>
</p>
<p>
<button type="button" class="oe_edi_button_import">Continue</button>
</p>
</div>
<p>
<input type="radio" id="oe_edi_rd_import_openerp" name="oe_edi_rd_import" value="oe_edi_import_openerp"/>
<label for="oe_edi_rd_import_openerp">Import it into my existing OpenERP instance</label>
<p class="oe_edi_nested_block">
<label for="oe_edi_txt_saas_url">OpenERP instance address:</label> http://<input type="text" id="oe_edi_txt_server_url"/>
</p>
</p>
<p>
<input type="radio" id="oe_edi_rd_import_saas_account" name="oe_edi_rd_import" value="oe_edi_create_saas_account"/>
<label for="oe_edi_rd_import_saas_account">Create a new OpenERP instance for me:</label>
<p class="oe_edi_nested_block"><label for="oe_edi_txt_saas_url">Company:</label><input type="text" name="oe_edi_txt_saas_url"/>.my.openerp.com</p>
<p class="oe_edi_nested_block"><label for="oe_edi_txt_saas_password">Password:</label><input type="password" name="oe_edi_txt_saas_password"/></p>
<p class="oe_edi_nested_block"><label for="oe_edi_txt_saas_email">Email:</label><input type="text" name="oe_edi_txt_saas_email"/></p>
</p>
<p>
<input type="radio" id="oe_edi_rd_import_other" name="oe_edi_rd_import" value="oe_edi_import_other"/>
<label for="oe_edi_rd_import_other">Import into another application</label>
</p>
<p>
<button type="button" class="oe_edi_button_import">Continue</button>
</p>
<div class="oe_edi_right_top">
</div>
<div class="oe_edi_right_bottom">
</div>
</td>
</tr>
<tr>
<td colspan="2" id="oe_footer" class="oe_footer">
<p class="oe_footer_powered">Powered by <a href="http://www.openerp.com">OpenERP</a>.</p>
</td>
</tr>
</table>
</t>
<t t-name="EdiViewRightBottom">
<div>
</div>
</t>
</template>

View File

@ -0,0 +1,115 @@
<template>
<t t-name="Edi.account.invoice">
<t t-if="!invoice.reconciled">
<table width="100%">
<tr>
<td>
<b>Pay this Invoice in Online</b>
</td>
</tr>
<tr>
<td>
<hr/>
</td>
</tr>
<tr>
<td>
<input type="radio" id="oe_edi_invoice_rd_pay_paypal" name="oe_edi_invoice_rd_pay" value="paypal">Paypal</input>
<input type="radio" id="oe_edi_invoice_rd_pay_google_checkout" name="oe_edi_invoice_rd_pay" value="google">Google Checkout</input>
<input type="radio" id="oe_edi_invoice_rd_pay_bank" name="oe_edi_invoice_rd_pay" value="bank">Bank wire Transfer</input>
<button type="button" id="oe_edi_invoice_button_pay" name="oe_edi_invoice_button_pay">Pay</button>
</td>
</tr>
</table>
</t>
<h1>Invoice <t t-esc="invoice.internal_number"/>: <t t-esc="invoice.amount_total"/><t t-esc="invoice.currency_id[1]"/></h1>
<p>
<b><t t-esc="invoice.company_id[1]"/></b><br/>
<t t-if="invoice.company_address">
<t t-esc="invoice.company_address.zip"/> <t t-esc="invoice.company_address.street"/><br/>
<t t-esc="invoice.company_address.city"/><br/>
<t t-if="invoice.company_address.country_id" t-esc="invoice.company_address.country_id[1]"/><br/>
Phone: <t t-esc="invoice.company_address.phone"/>
</t>
</p>
<p align="right">
<b><t t-esc="invoice.partner_id[1]"/></b><br/>
<t t-esc="invoice.address_invoice_id[1]"/>
</p>
<table width="100%">
<tr>
<th align="left">Description</th>
<th align="left">Date</th>
<th align="left">Origin</th>
<th align="left">Your Reference</th>
</tr>
<tr>
<td align="left"><t t-esc="invoice.name"/><t t-esc="invoice.comment"/></td>
<td align="left"><t t-esc="invoice.date_invoice"/></td>
<td align="left"><t t-esc="invoice.origin"/></td>
<td align="left"><t t-esc="invoice.reference"/></td>
</tr>
</table>
<table width="100%" >
<tr>
<th align="left">Product Description</th>
<th align="left">Quantity</th>
<th align="left">Unit Price</th>
<th align="left">Discount</th>
<th align="right">Price</th>
</tr>
<t t-if="invoice.invoice_line" t-foreach="invoice.invoice_line" t-as="invoice_line">
<tr>
<td align="left"><t t-esc="invoice_line.name"/><br/><t t-esc="invoice_line.note"/></td>
<td align="left"><t t-esc="invoice_line.quantity"/><t t-esc="invoice_line.uos_id[1]"/></td>
<td align="left"><t t-esc="invoice_line.price_unit"/></td>
<td align="left"><t t-esc="invoice_line.discount"/></td>
<td align="right"><t t-esc="invoice_line.price_subtotal"/><t t-esc="invoice.currency_id[1]"/></td>
</tr>
</t>
<tr>
<td colspan="3"></td>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td colspan="3"></td>
<td>Net Total: </td>
<td align="right"><t t-esc="invoice.amount_untaxed"/><t t-esc="invoice.currency_id[1]"/></td>
</tr>
<tr>
<td colspan="3"></td>
<td>Taxes: </td>
<td align="right"><t t-esc="invoice.amount_tax"/><t t-esc="invoice.currency_id[1]"/></td>
</tr>
<tr>
<td colspan="3"></td>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td colspan="3"></td>
<td>Total: </td>
<td align="right"><t t-esc="invoice.amount_total"/><t t-esc="invoice.currency_id[1]"/></td>
</tr>
<tr>
<td colspan="3">
<table width="100%">
<tr>
<th align="left">Tax</th>
<th align="right">Base Amount</th>
<th align="right">Amount</th>
</tr>
<t t-if="invoice.tax_line"><t t-foreach="invoice.tax_line" t-as="tax_line">
<tr>
<td align="left"><t t-esc="tax_line.name"/></td>
<td align="right"><t t-esc="tax_line.base_amount"/><t t-esc="invoice.currency_id[1]"/></td>
<td align="right"><t t-esc="tax_line.amount"/><t t-esc="invoice.currency_id[1]"/></td>
</tr>
</t>
</t>
</table>
</td>
<td colspan="2"></td>
</tr>
</table>
</t>
</template>

View File

@ -1,132 +0,0 @@
<template>
<t t-name="InvoiceEdiView">
<div>
<t t-foreach="invoices" t-as="invoice">
<t t-if="!invoice.reconciled">
<table width="100%">
<tr>
<td>
<b>Pay this Invoice in Online</b>
</td>
</tr>
<tr>
<td>
<hr/>
</td>
</tr>
<tr>
<td>
<input type="radio" id="oe_edi_invoice_rd_pay_paypal" name="oe_edi_invoice_rd_pay" value="paypal">Paypal</input>
<input type="radio" id="oe_edi_invoice_rd_pay_google_checkout" name="oe_edi_invoice_rd_pay" value="google">Google Checkout</input>
<input type="radio" id="oe_edi_invoice_rd_pay_bank" name="oe_edi_invoice_rd_pay" value="bank">Bank wire Transfer</input>
<button type="button" id="oe_edi_invoice_button_pay" name="oe_edi_invoice_button_pay">Pay</button>
</td>
</tr>
</table>
</t>
<h1>Invoice <t t-esc="invoice.internal_number"/>: <t t-esc="invoice.amount_total"/><t t-esc="invoice.currency_id[1]"/></h1>
<p>
<b><t t-esc="invoice.company_id[1]"/></b><br/>
<t t-if="invoice.company_address">
<t t-esc="invoice.company_address.zip"/> <t t-esc="invoice.company_address.street"/><br/>
<t t-esc="invoice.company_address.city"/><br/>
<t t-if="invoice.company_address.country_id" t-esc="invoice.company_address.country_id[1]"/><br/>
Phone: <t t-esc="invoice.company_address.phone"/>
</t>
</p>
<p align="right">
<b><t t-esc="invoice.partner_id[1]"/></b><br/>
<t t-esc="invoice.address_invoice_id[1]"/>
</p>
<table width="100%">
<tr>
<th align="left">Description</th>
<th align="left">Date</th>
<th align="left">Origin</th>
<th align="left">Your Reference</th>
</tr>
<tr>
<td align="left"><t t-esc="invoice.name"/><t t-esc="invoice.comment"/></td>
<td align="left"><t t-esc="invoice.date_invoice"/></td>
<td align="left"><t t-esc="invoice.origin"/></td>
<td align="left"><t t-esc="invoice.reference"/></td>
</tr>
</table>
<table width="100%" >
<tr>
<th align="left">Product Description</th>
<th align="left">Quantity</th>
<th align="left">Unit Price</th>
<th align="left">Discount</th>
<th align="right">Price</th>
</tr>
<t t-if="invoice.invoice_line" t-foreach="invoice.invoice_line" t-as="invoice_line">
<tr>
<td align="left"><t t-esc="invoice_line.name"/><br/><t t-esc="invoice_line.note"/></td>
<td align="left"><t t-esc="invoice_line.quantity"/><t t-esc="invoice_line.uos_id[1]"/></td>
<td align="left"><t t-esc="invoice_line.price_unit"/></td>
<td align="left"><t t-esc="invoice_line.discount"/></td>
<td align="right"><t t-esc="invoice_line.price_subtotal"/><t t-esc="invoice.currency_id[1]"/></td>
</tr>
</t>
<tr>
<td colspan="3"></td>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td colspan="3"></td>
<td>Net Total: </td>
<td align="right"><t t-esc="invoice.amount_untaxed"/><t t-esc="invoice.currency_id[1]"/></td>
</tr>
<tr>
<td colspan="3"></td>
<td>Taxes: </td>
<td align="right"><t t-esc="invoice.amount_tax"/><t t-esc="invoice.currency_id[1]"/></td>
</tr>
<tr>
<td colspan="3"></td>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td colspan="3"></td>
<td>Total: </td>
<td align="right"><t t-esc="invoice.amount_total"/><t t-esc="invoice.currency_id[1]"/></td>
</tr>
<tr>
<td colspan="3">
<table width="100%">
<tr>
<th align="left">Tax</th>
<th align="right">Base Amount</th>
<th align="right">Amount</th>
</tr>
<t t-if="invoice.tax_line"><t t-foreach="invoice.tax_line" t-as="tax_line">
<tr>
<td align="left"><t t-esc="tax_line.name"/></td>
<td align="right"><t t-esc="tax_line.base_amount"/><t t-esc="invoice.currency_id[1]"/></td>
<td align="right"><t t-esc="tax_line.amount"/><t t-esc="invoice.currency_id[1]"/></td>
</tr>
</t>
</t>
</table></td><td colspan="2"></td>
</tr>
</table>
</t>
</div>
</t>
</template>

View File

@ -0,0 +1,80 @@
<template>
<t t-name="Edi.sale.order">
<h1>Order <t t-esc="doc.name"/>: <t t-esc="doc.amount_total"/><t t-esc="doc.currency_id[1]"/></h1>
<p>
<b><t t-esc="doc.company_id[1]"/></b><br/>
<t t-if="doc.company_address">
<t t-esc="doc.company_address.zip"/> <t t-esc="doc.company_address.street"/><br/>
<t t-esc="doc.company_address.city"/><br/>
<t t-if="doc.company_address.country_id" t-esc="doc.company_address.country_id[1]"/><br/>
Phone: <t t-esc="doc.company_address.phone"/>
</t>
</p>
<p align="right">
<b><t t-esc="doc.partner_id[1]"/></b><br/>
<t t-if="doc.partner_order_id" t-esc="doc.partner_order_id[1]"/>
<t t-if="doc.partner_address_id" t-esc="doc.partner_address_id[1]"/>
</p>
<table width="100%">
<tr>
<th align="left">Description</th>
<th align="left">Date</th>
<th align="left">Origin</th>
<th align="left">Your Reference</th>
</tr>
<tr>
<td align="left"><t t-esc="doc.name"/></td>
<td align="left"><t t-esc="doc.date_order"/></td>
<td align="left"><t t-esc="doc.origin"/></td>
<td align="left">
<t t-if="doc.partner_ref" t-esc="doc.partner_ref"/>
<t t-if="doc.client_order_ref" t-esc="doc.client_order_ref"/>
</td>
</tr>
</table>
<table width="100%" >
<tr>
<th align="left">Product Description</th>
<th align="center">Unit Price</th>
<th align="center">Quantity</th>
<th align="center">UOM</th>
<th align="right">Price</th>
</tr>
<t t-if="doc.order_line" t-foreach="doc.order_line" t-as="doc_line">
<tr>
<td align="left"><t t-esc="doc_line.product_id[1]"/></td>
<td align="center"><t t-esc="doc_line.price_unit"/></td>
<td align="center">
<t t-if="doc_line.product_qty" t-esc="doc_line.product_qty"/>
<t t-if="doc_line.product_uom_qty" t-esc="doc_line.product_uom_qty"/>
</td>
<td align="center"><t t-esc="doc_line.product_uom[1]"/></td>
<td align="right"><t t-esc="doc_line.price_subtotal"/><t t-esc="doc.currency_id[1]"/></td>
</tr>
</t>
<tr>
<td colspan="3"></td>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td colspan="3"></td>
<td>Net Total: </td>
<td align="right"><t t-esc="doc.amount_untaxed"/><t t-esc="doc.currency_id[1]"/><t/></td>
</tr>
<tr>
<td colspan="3"></td>
<td>Taxes: </td>
<td align="right"><t t-esc="doc.amount_tax"/><t t-esc="doc.currency_id[1]"/><t/></td>
</tr>
<tr>
<td colspan="3"></td>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td colspan="3"></td>
<td>Total: </td>
<td align="right"><t t-esc="doc.amount_total"/><t t-esc="doc.currency_id[1]"/><t/></td>
</tr>
</table>
</t>
</template>

View File

@ -1,96 +0,0 @@
<template>
<t t-name="OrderEdiView">
<div>
<t t-foreach="orders" t-as="order">
<h1>Order <t t-esc="order.name"/>: <t t-esc="order.amount_total"/><t t-esc="order.currency_id[1]"/></h1>
<p>
<b><t t-esc="order.company_id[1]"/></b><br/>
<t t-if="order.company_address">
<t t-esc="order.company_address.zip"/> <t t-esc="order.company_address.street"/><br/>
<t t-esc="order.company_address.city"/><br/>
<t t-if="order.company_address.country_id" t-esc="order.company_address.country_id[1]"/><br/>
Phone: <t t-esc="order.company_address.phone"/>
</t>
</p>
<p align="right">
<b><t t-esc="order.partner_id[1]"/></b><br/>
<t t-if="order.partner_order_id" t-esc="order.partner_order_id[1]"/>
<t t-if="order.partner_address_id" t-esc="order.partner_address_id[1]"/>
</p>
<table width="100%">
<tr>
<th align="left">Description</th>
<th align="left">Date</th>
<th align="left">Origin</th>
<th align="left">Your Reference</th>
</tr>
<tr>
<td align="left"><t t-esc="order.name"/></td>
<td align="left"><t t-esc="order.date_order"/></td>
<td align="left"><t t-esc="order.origin"/></td>
<td align="left">
<t t-if="order.partner_ref" t-esc="order.partner_ref"/>
<t t-if="order.client_order_ref" t-esc="order.client_order_ref"/>
</td>
</tr>
</table>
<table width="100%" >
<tr>
<th align="left">Product Description</th>
<th align="center">Unit Price</th>
<th align="center">Quantity</th>
<th align="center">UOM</th>
<th align="right">Price</th>
</tr>
<t t-if="order.order_line" t-foreach="order.order_line" t-as="order_line">
<tr>
<td align="left"><t t-esc="order_line.product_id[1]"/></td>
<td align="center"><t t-esc="order_line.price_unit"/></td>
<td align="center">
<t t-if="order_line.product_qty" t-esc="order_line.product_qty"/>
<t t-if="order_line.product_uom_qty" t-esc="order_line.product_uom_qty"/>
</td>
<td align="center"><t t-esc="order_line.product_uom[1]"/></td>
<td align="right"><t t-esc="order_line.price_subtotal"/><t t-esc="order.currency_id[1]"/></td>
</tr>
</t>
<tr>
<td colspan="3"></td>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td colspan="3"></td>
<td>Net Total: </td>
<td align="right"><t t-esc="order.amount_untaxed"/><t t-esc="order.currency_id[1]"/><t/></td>
</tr>
<tr>
<td colspan="3"></td>
<td>Taxes: </td>
<td align="right"><t t-esc="order.amount_tax"/><t t-esc="order.currency_id[1]"/><t/></td>
</tr>
<tr>
<td colspan="3"></td>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td colspan="3"></td>
<td>Total: </td>
<td align="right"><t t-esc="order.amount_total"/><t t-esc="order.currency_id[1]"/><t/></td>
</tr>
</table>
</t>
</div>
</t>
</template>

View File

@ -12,7 +12,7 @@ try:
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/web/view_edi?db=%s&token=%s' %(web_root_url, cr.dbname, edi_token))
context.update(edi_web_url_view='%s/edi/view?idebug=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