[MERGE] html5 amnifest

bzr revid: fva@openerp.com-20120814120052-s9avcsbsxl06zewr
This commit is contained in:
Frédéric van der Essen 2012-08-14 14:00:52 +02:00
commit 36ea689ad9
7 changed files with 36 additions and 2613 deletions

View File

@ -83,7 +83,6 @@ Main features:
'application': True,
# Web client
'js': [
'static/lib/backbone/backbone-0.9.2.js',
'static/lib/mousewheel/jquery.mousewheel-3.0.6.js',
'static/src/js/pos_db.js',
'static/src/js/pos_models.js',

View File

@ -0,0 +1,3 @@
import main
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,14 +1,45 @@
# -*- coding: utf-8 -*-
import logging
import simplejson
try:
import openerp.addons.web.common.http as openerpweb
from openerp.addons.web.controllers.main import manifest_list, module_boot, html_template
except ImportError:
import web.common.http as openerpweb
class PointOfSaleController(openerpweb.Controller):
_cp_path = '/pos'
@openerpweb.httprequest
def app(self, req, s_action=None, **kw):
js = "\n ".join('<script type="text/javascript" src="%s"></script>' % i for i in manifest_list(req, None, 'js'))
css = "\n ".join('<link rel="stylesheet" href="%s">' % i for i in manifest_list(req, None, 'css'))
cookie = req.httprequest.cookies.get("instance0|session_id")
session_id = cookie.replace("%22","")
template = html_template.replace('<html','<html manifest="/pos/manifest?session_id=%s"'%session_id)
r = template % {
'js': js,
'css': css,
'modules': simplejson.dumps(module_boot(req)),
'init': 'var wc = new s.web.WebClient();wc.appendTo($(document.body));'
}
return r
@openerpweb.httprequest
def manifest(self, req, **kwargs):
ml = ["CACHE MANIFEST"]
Products = req.session.model('product.product')
for p in Products.search_read([('pos_categ_id','!=',False)], ['name', 'dependencies_id']):
session_id = req.session_id
product_id = p['id']
url = "/web/binary/image?session_id=%s&model=product.product&field=image&id=%s" % (session_id, product_id)
ml.append(url)
ml += ["NETWORK:","*"]
m = "\n".join(ml)
return m
@openerpweb.jsonrequest
def dispatch(self, request, iface, **kwargs):
method = 'iface_%s' % iface
@ -109,3 +140,4 @@ class PointOfSaleController(openerpweb.Controller):
print 'print_receipt' + str(receipt)
return

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -242,7 +242,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
this.renderElement();
},
get_image_url: function() {
return 'web/binary/image?session_id='+instance.connection.session_id+'&model=product.product&field=image&id='+this.model.get('id')+'&cache=1800';
return '/web/binary/image?session_id='+instance.connection.session_id+'&model=product.product&field=image&id='+this.model.get('id');
},
renderElement: function() {
this._super();

View File

@ -1,22 +0,0 @@
<!doctype html>
<html>
<head>
<title>JSON</title>
<script type="text/javascript" src="http://localhost:8069/web/webclient/js"></script>
</head>
<body>
<h1>JSON</h1>
<p id="response"></p>
<script type="text/javascript">
var c = new openerp.init(['web', 'point_of_sale']);
c.connection.session_bind('http://localhost:8069').then(function() {
var w = new c.point_of_sale.test();
w.appendTo($("#response"));
});
</script>
</body>
</html>