494c8a4cd78deadc2a685baed39020d34c9f7b1e
1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # POS Membership module for OpenERP, Manage membership payments from POS.
5 # Copyright (C) 2013 L'Heureux Cyclage (<http://www.heureux-cyclage.org>)
7 # This file is a part of POS Membership
9 # POS Membership is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # ReMembership is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 ##############################################################################
26 from openerp
.addons
.web
.controllers
.main
import manifest_list
, module_boot
, html_template
27 from openerp
.addons
.point_of_sale
.controllers
.main
import PointOfSaleController
29 class PointOfSaleController(PointOfSaleController
):
31 @openerp.addons
.web
.http
.httprequest
32 def app(self
, req
, s_action
=None, **kw
):
33 js
= "\n ".join('<script type="text/javascript" src="%s"></script>' % i
for i
in manifest_list(req
, None, 'js'))
34 css
= "\n ".join('<link rel="stylesheet" href="%s">' % i
for i
in manifest_list(req
, None, 'css'))
36 cookie
= req
.httprequest
.cookies
.get("instance0|session_id")
37 session_id
= cookie
.replace("%22","")
38 template
= html_template
.replace('<html','<html manifest="/pos/manifest?session_id=%s"'%session
_id
)
42 'modules': simplejson
.dumps(module_boot(req
)),
43 'init': 'var wc = new s.web.WebClient();wc.appendTo($(document.body));'
45 print ("DEV: [pos_membership] [controllers] [main] [app] return=%s" % str(r
))
48 @openerp.addons
.web
.http
.httprequest
49 def manifest(self
, req
, **kwargs
):
50 """ This generates a HTML5 cache manifest files that preloads the categories and products thumbnails
51 and other ressources necessary for the point of sale to work offline """
52 ml
= ["CACHE MANIFEST"]
54 # loading all the images in the static/src/img/* directories
55 def load_css_img(srcdir
,dstdir
):
56 for f
in os
.listdir(srcdir
):
57 path
= os
.path
.join(srcdir
,f
)
58 dstpath
= os
.path
.join(dstdir
,f
)
59 if os
.path
.isdir(path
) :
60 load_css_img(path
,dstpath
)
61 elif f
.endswith(('.png','.PNG','.jpg','.JPG','.jpeg','.JPEG','.gif','.GIF')):
64 imgdir
= openerp
.modules
.get_module_resource('point_of_sale','static/src/img');
65 load_css_img(imgdir
,'/point_of_sale/static/src/img')
67 products
= req
.session
.model('product.product')
68 for p
in products
.search_read([('pos_categ_id','!=',False)], ['name']):
70 url
= "/web/binary/image?session_id=%s&model=product.product&field=image&id=%s" % (req
.session_id
, product_id
)
73 categories
= req
.session
.model('pos.category')
74 for c
in categories
.search_read([],['name']):
76 url
= "/web/binary/image?session_id=%s&model=pos.category&field=image&id=%s" % (req
.session_id
, category_id
)
79 partners
= req
.session
.model('res.partner')
80 for c
in partners
.search_read([],['name']):
82 url
= "/web/binary/image?session_id=%s&model=res.partner&field=image&id=%s" % (req
.session_id
, partner_id
)
85 ml
+= ["NETWORK:","*"]
88 print ("DEV: [pos_membership] [controllers] [main] [manifest] return=%s" % m
)
91 PointOfSaleController()
92 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: