From 0ff4c48cb92bff3595de644bfe6cbfe89e264cd7 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Sat, 25 Jan 2014 20:25:53 +0100 Subject: [PATCH] [FIX] misc fixes bzr revid: fp@tinyerp.com-20140125192553-7vg5iao6afp1anwn --- addons/website_quotation/controllers/main.py | 14 +++----- .../static/src/js/website_quotation.js | 35 ++++++++----------- .../views/website_quotation.xml | 14 ++++---- 3 files changed, 26 insertions(+), 37 deletions(-) diff --git a/addons/website_quotation/controllers/main.py b/addons/website_quotation/controllers/main.py index 52decbe6ab2..47b23cf5a3a 100644 --- a/addons/website_quotation/controllers/main.py +++ b/addons/website_quotation/controllers/main.py @@ -58,15 +58,11 @@ class sale_quote(http.Controller): order_obj = request.registry.get('sale.order') order = order_obj.browse(request.cr, SUPERUSER_ID, order_id) assert token == order.access_token, 'Access denied, wrong token!' - error = {} - if not signer: error['signer'] = 'missing' - if not sign: error['sign'] = 'missing' - if not error: - order_obj.signal_order_confirm(request.cr, SUPERUSER_ID, [order_id], context=request.context) - message = _('Order signed by %s') % (signer,) - self.__message_post(message, order_id, type='comment', subtype='mt_comment', - attachments=[('signature.png', sign)]) - return [error] + attachments=sign and [('signature.png', sign)] or [] + order_obj.signal_order_confirm(request.cr, SUPERUSER_ID, [order_id], context=request.context) + message = _('Order signed by %s') % (signer,) + self.__message_post(message, order_id, type='comment', subtype='mt_comment', attachments=attachments) + return True @http.route(['/quote///decline'], type='http', auth="public", website=True) def decline(self, order_id, token, **post): diff --git a/addons/website_quotation/static/src/js/website_quotation.js b/addons/website_quotation/static/src/js/website_quotation.js index ed9453c043f..277a77d3c12 100644 --- a/addons/website_quotation/static/src/js/website_quotation.js +++ b/addons/website_quotation/static/src/js/website_quotation.js @@ -37,34 +37,27 @@ $(document).ready(function () { var href = $link.attr("action"); var order_id = href.match(/accept\/([0-9]+)/); var token = href.match(/token=(.*)/); - var sign = false; - var signer_name = false; - if($('#signature').length > 0){ - var isSignature=$("#signature").jSignature('getData','image')[1].length>1?true:false; - if (isSignature) - { - sign = JSON.stringify($("#signature").jSignature("getData",'image')[1]); - } - signer_name = $("#name").val(); - } + + var signer_name = $("#name").val(); + var sign = $("#signature").jSignature("getData",'image')[1]; + $('#signer').toggleClass('has-error', ! signer_name); + $('#drawsign').toggleClass('panel-error', ! sign.length); + + if (! signer_name) + return false; + openerp.jsonRpc("/quote/accept/", 'call', { 'order_id': parseInt(order_id[1]), 'token': token[1], 'signer': signer_name, - 'sign': sign, - }) - .then(function (data) { - if(_.isEmpty(data[0])){ - $('#modelaccept').modal('hide'); - var url = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port : "") - window.location.replace(url +'/quote/'+order_id[1]+'/'+token[1]+'?message=3'); - } else{ - if (data[0]['signer']) $('#signer').addClass('has-error'); else $('#signer').removeClass('has-error'); - if (data[0]['sign']) $('#drawsign').addClass('panel-danger'); else $('#drawsign').removeClass('panel-danger'); - } + 'sign': sign?JSON.stringify(sign):false, + }).then(function (data) { + $('#modelaccept').modal('hide'); + window.location.replace(url +'/quote/'+order_id[1]+'/'+token[1]+'?message=3'); }); return false }); + // automatically generate a menu from h1 and h2 tag in content var ul = $('[data-id="quote_sidebar"]'); var sub_li = null; diff --git a/addons/website_quotation/views/website_quotation.xml b/addons/website_quotation/views/website_quotation.xml index 05214bc4fbb..102fbd4d2df 100644 --- a/addons/website_quotation/views/website_quotation.xml +++ b/addons/website_quotation/views/website_quotation.xml @@ -235,7 +235,7 @@ -