diff --git a/addons/website_quotation/__openerp__.py b/addons/website_quotation/__openerp__.py index 92547bb7cbe..79bd188edcd 100644 --- a/addons/website_quotation/__openerp__.py +++ b/addons/website_quotation/__openerp__.py @@ -9,7 +9,7 @@ OpenERP Sale Quote Roller """, 'author': 'OpenERP SA', - 'depends': ['website','sale', 'portal_sale', 'mail'], + 'depends': ['website','sale', 'portal_sale', 'mail','document'], 'data': [ 'views/website_quotation.xml', 'views/website_quotation_backend.xml', diff --git a/addons/website_quotation/controllers/main.py b/addons/website_quotation/controllers/main.py index 4eb588b8a04..c3be03922f1 100644 --- a/addons/website_quotation/controllers/main.py +++ b/addons/website_quotation/controllers/main.py @@ -40,12 +40,21 @@ class sale_quote(http.Controller): } return request.website.render('website_quotation.so_quotation', values) - @website.route(['/quote///accept'], type='http', auth="public") - def accept(self, order_id, token, **post): - order = request.registry.get('sale.order').browse(request.cr, SUPERUSER_ID, order_id) + @website.route(['/quote/accept'], type='json', auth="public") + def accept(self, order_id=None, token=None, signer=None, sign=None, **post): + 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!' - request.registry.get('sale.order').write(request.cr, request.uid, [order_id], {'state': 'manual'}) - return request.redirect("/quote/%s/%s" % (order_id, token)) + attachment = { + 'name': 'sign.png', + 'datas':sign, + 'datas_fname': 'sign.png', + 'res_model': 'sale.order', + 'res_id': order_id, + } + request.registry['ir.attachment'].create(request.cr, request.uid, attachment, context=request.context) + order_obj.write(request.cr, request.uid, [order_id], {'signer_name':signer,'state': 'manual'}) + return [] @website.route(['/quote///decline'], type='http', auth="public") def decline(self, order_id, token, **post): diff --git a/addons/website_quotation/models/order.py b/addons/website_quotation/models/order.py index 9a301c7e49d..7f16bd8d758 100644 --- a/addons/website_quotation/models/order.py +++ b/addons/website_quotation/models/order.py @@ -90,6 +90,7 @@ class sale_order(osv.osv): 'template_id': fields.many2one('sale.quote.template', 'Quote Template'), 'website_description': fields.html('Description'), 'options' : fields.one2many('sale.option.line', 'option_id', 'Optional Products Lines'), + 'signer_name': fields.char('Signer Name', size=256), } _defaults = { 'access_token': lambda self, cr, uid, ctx={}: str(uuid.uuid4()) diff --git a/addons/website_quotation/static/lib/jSignature/jSignature.min.js b/addons/website_quotation/static/lib/jSignature/jSignature.min.js new file mode 100644 index 00000000000..3c5590659a8 --- /dev/null +++ b/addons/website_quotation/static/lib/jSignature/jSignature.min.js @@ -0,0 +1,77 @@ +/* + +jSignature v2 "2012-11-01T22:48" "commit ID 1c15dfafecc75925c3b7d529356a558b59220edb" +Copyright (c) 2012 Willow Systems Corp http://willow-systems.com +Copyright (c) 2010 Brinley Ang http://www.unbolt.net +MIT License + + +Simplify.js BSD +(c) 2012, Vladimir Agafonkin +mourner.github.com/simplify-js + + +base64 encoder +MIT, GPL +http://phpjs.org/functions/base64_encode ++ original by: Tyler Akins (http://rumkin.com) ++ improved by: Bayron Guevara ++ improved by: Thunder.m ++ improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) ++ bugfixed by: Pellentesque Malesuada ++ improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) ++ improved by: Rafal Kukawski (http://kukawski.pl) + + +jSignature v2 jSignature's Undo Button and undo functionality plugin + + +jSignature v2 jSignature's custom "base30" format export and import plugins. + + +jSignature v2 SVG export plugin. + +*/ +(function(){function q(b){for(var j,s=b.css("color"),g,b=b[0],c=!1;b&&!g&&!c;){try{j=$(b).css("background-color")}catch(d){j="transparent"}"transparent"!==j&&"rgba(0, 0, 0, 0)"!==j&&(g=j);c=b.body;b=b.parentNode}var b=/rgb[a]*\((\d+),\s*(\d+),\s*(\d+)/,c=/#([AaBbCcDdEeFf\d]{2})([AaBbCcDdEeFf\d]{2})([AaBbCcDdEeFf\d]{2})/,a;j=void 0;(j=s.match(b))?a={r:parseInt(j[1],10),g:parseInt(j[2],10),b:parseInt(j[3],10)}:(j=s.match(c))&&(a={r:parseInt(j[1],16),g:parseInt(j[2],16),b:parseInt(j[3],16)});var f;g? +(j=void 0,(j=g.match(b))?f={r:parseInt(j[1],10),g:parseInt(j[2],10),b:parseInt(j[3],10)}:(j=g.match(c))&&(f={r:parseInt(j[1],16),g:parseInt(j[2],16),b:parseInt(j[3],16)})):f=a?127').appendTo(g); +this.isCanvasEmulator=!1;a=this.canvas=this.initializeCanvas(d);j=$(a);this.$controlbarLower=$('
').appendTo(g);this.canvasContext=a.getContext("2d");j.data(e+".this",this);g=(g=d.lineWidth)?g:Math.max(Math.round(a.width/400),2);d.lineWidth=g;this.lineCurveThreshold=3*d.lineWidth;d.cssclass&&""!=$.trim(d.cssclass)&&j.addClass(d.cssclass); +this.fatFingerCompensation=0;var g=function(b){var j,a,g=function(g){g=g.changedTouches&&0d.minFatFingerCompensation? +-3*d.lineWidth:d.minFatFingerCompensation;i(b);h.ontouchend=l;h.ontouchstart=i;h.ontouchmove=p},h.onmousedown=function(b){h.ontouchstart=void 0;h.ontouchend=void 0;h.ontouchmove=void 0;i(b);h.onmousedown=i;h.onmouseup=l;h.onmousemove=p});b[e+".windowmouseup"]=c.subscribe(e+".windowmouseup",g.drawEndHandler);this.events.publish(e+".attachingEventHandlers");var n=this,b=d.width.toString(10),w=e;if("ratio"===b||"%"===b.split("")[b.length-1])this.eventTokens[w+".parentresized"]=c.subscribe(w+".parentresized", +function(b,j,a){return function(){var g=j.width();if(g!==a){for(var d in b)b.hasOwnProperty(d)&&(c.unsubscribe(b[d]),delete b[d]);var s=n.settings;n.$parent.children().remove();for(d in n)n.hasOwnProperty(d)&&delete n[d];d=s.data;var g=1*g/a,f=[],l,i,e,h,k,p;i=0;for(e=d.length;ithis.lineCurveThreshold){i=2this.lineCurveThreshold){if(1').appendTo(this.$controlbarLower),k=e.width();e.css("left",Math.round((this.canvas.width-k)/2));k!==e.width()&&e.width(k);return e});var k=m.call(this), +t=this;t.events.subscribe("jSignature.change",function(){t.dataEngine.data.length?k.show():k.hide()});var r=this,e=(this.events.topics.hasOwnProperty("jSignature.undo")?q:"jSignature")+".undo";k.bind("click",function(){r.events.publish(e)});r.events.subscribe(e,function(){var e=r.dataEngine.data;e.length&&(e.pop(),r.resetCanvas(e))})}})})})(); +(function(){for(var q={},m={},k="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX".split(""),t=k.length/2,r=t-1;-1l&&0f&&(f=1,h.push("Y")),c=Math.abs(l),c>=t?h.push(e(c.toString(t))):h.push(c.toString(t));return h.join("")},v=function(e){for(var h= +[],e=e.split(""),a=e.length,f,d=1,c=[],l=0,i=0;id?(d=2f){var d=(new m(a.x[d-2],a.y[d-2])).getVectorToPoint(e),e=c.angleTo(d.reverse()),i=0.35*c.getLength(),d=(new q(d.x+c.x,d.y+c.y)).resizeTo(Math.max(0.05,e)*i);return["c",k(d.x,2),k(d.y,2),k(c.x, +2),k(c.y,2),k(c.x,2),k(c.y,2)]}return["l",k(c.x,2),k(c.y,2)]}function e(a,e,d){for(var e=["M",k(a.x[0]-e,2),k(a.y[0]-d,2)],d=1,c=a.x.length-1;d',''],d,c=a.length,l,i=[],h=[],k=l=d=0,n=0,p=[];if(0!==c){for(d=0;da?0:a;n=0>i?0:i;d=c-a;l=h-i}f.push('');d=0;for(c=p.length;d< +c;d++)l=p[d],f.push('');f.push("");return f.join("")}function v(a){return[p,y(a)]}function z(a){return[h,x(y(a))]}var u=window;"use strict";("undefined"!=typeof exports?exports:u).simplify=function(a,e,d){e=void 0!==e?e*e:1;if(!d){for(var c=a.length,l,i=a[0],h=[i],d=1;de&&(h.push(l),i=l)}a=(i!==l&&h.push(l),h)}l=a;var d=l.length, +c=new ("undefined"!=typeof Uint8Array?Uint8Array:Array)(d),i=0,h=d-1,m,p,b=[],j=[],s=[];for(c[i]=c[h]=1;h;){n=0;for(k=i+1;kn&&(p=k,n=m)}n>e&&(c[p]=1,b.push(i),j.push(p),b.push(p),j.push(h));i=b.pop();h=j.pop()}for(k=0;k>18&63,c=i>>12&63,h=i>>6&63,i&=63,n[m++]=e[d]+e[c]+e[h]+e[i];while(k + @@ -179,18 +180,25 @@ -
+