def render(self, cr, uid, id_or_xml_id, values=None, engine='ir.qweb', context=None): if isinstance(id_or_xml_id, list): id_or_xml_id = id_or_xml_id[0] if not context: context = {} if values is None: values = dict() qcontext = dict( keep_query=keep_query, request=request, # might be unbound if we're not in an httprequest context debug=request.debug if request else False, json=simplejson, quote_plus=werkzeug.url_quote_plus, time=time, datetime=datetime, relativedelta=relativedelta, ) qcontext.update(values) # TODO: remove this as soon as the following branch is merged # lp:~openerp-dev/openerp-web/trunk-module-closure-style-msh from openerp.addons.web.controllers.main import module_boot qcontext['modules'] = simplejson.dumps(module_boot()) if request else None def loader(name): return self.read_template(cr, uid, name, context=context) return self.pool[engine].render(cr, uid, id_or_xml_id, qcontext, loader=loader, context=context)
def a(self, debug=False, **k): if not request.session.uid: return login_redirect() js_list = manifest_list('js', db=request.db, debug=debug) css_list = manifest_list('css', db=request.db, debug=debug) js = "\n".join('<script type="text/javascript" src="%s"></script>' % i for i in js_list) #css = "\n".join('<link rel="stylesheet" href="%s">' % i for i in css_list) r = html_template % { 'js': js, # 'css': css, 'modules': simplejson.dumps(module_boot(request.db)), 'init': """ var wc = new s.web.WebClient(); wc.show_application = function(){ wc.action_manager.do_action("pos.ui"); }; wc.appendTo($(document.body)); """ } return r
def a(self, debug=False, **k): cr, uid, context, session = request.cr, request.uid, request.context, request.session if not session.uid: return login_redirect() PosSession = request.registry['pos.session'] pos_session_ids = PosSession.search(cr, uid, [('state', '=', 'opened'), ('user_id', '=', session.uid)], context=context) if not pos_session_ids: return werkzeug.utils.redirect( '/web#action=point_of_sale_bg.action_pos_session_opening') PosSession.login(cr, uid, pos_session_ids, context=context) modules = simplejson.dumps(module_boot(request.db)) init = """ var wc = new s.web.WebClient(); wc._title_changed = function() {} wc.show_application = function(){ wc.action_manager.do_action("pos.ui"); }; wc.setElement($(document.body)); wc.start(); """ html = request.registry.get('ir.ui.view').render( cr, session.uid, 'point_of_sale_bg.index', { 'modules': modules, 'init': init, }) return html
def a(self, debug=False, **k): cr, uid, context, session = request.cr, request.uid, request.context, request.session if not session.uid: return login_redirect() PosSession = request.registry['pos.session'] pos_session_ids = PosSession.search(cr, uid, [('state','=','opened'),('user_id','=',session.uid)], context=context) if not pos_session_ids: return werkzeug.utils.redirect('/web#action=point_of_sale.action_pos_session_opening') PosSession.login(cr,uid,pos_session_ids,context=context) modules = simplejson.dumps(module_boot(request.db)) init = """ var wc = new s.web.WebClient(); wc.show_application = function(){ wc.action_manager.do_action("pos.ui"); }; wc.setElement($(document.body)); wc.start(); """ html = request.registry.get('ir.ui.view').render(cr, session.uid,'point_of_sale.index',{ 'modules': modules, 'init': init, }) return html
def view(self, db, token, action, id, view='calendar'): registry = openerp.modules.registry.RegistryManager.get(db) meeting_pool = registry.get('calendar.event') attendee_pool = registry.get('calendar.attendee') with registry.cursor() as cr: attendee_data = meeting_pool.get_attendee(cr, openerp.SUPERUSER_ID, id) attendee = attendee_pool.search_read( cr, openerp.SUPERUSER_ID, [('access_token', '=', token)], []) if attendee: attendee_data['current_attendee'] = attendee[0] js = "\n ".join( '<script type="text/javascript" src="%s"></script>' % i for i in webmain.manifest_list('js', db=db)) css = "\n ".join('<link rel="stylesheet" href="%s">' % i for i in webmain.manifest_list('css', db=db)) return webmain.html_template % { 'js': js, 'css': css, 'modules': simplejson.dumps(webmain.module_boot(db)), 'init': "s.calendar.event('%s', '%s', '%s', '%s' , '%s');" % (db, action, id, 'form', json.dumps(attendee_data)), }
def index(self, req, s_action=None, db=None, **kw): db, redir = db_monodb_redirect(req) if redir: return redirect_with_hash(req, redir) js = "\n ".join( '<script type="text/javascript" src="%s"></script>' % i for i in manifest_list(req, 'js', db=db)) css = "\n ".join('<link rel="stylesheet" href="%s">' % i for i in manifest_list(req, 'css', db=db)) # Load the extra files js += "\n ".join( '<script type="text/javascript" src="%s"></script>' % i for i in js_extras) css += "\n ".join('<link rel="stylesheet" href="%s">' % i for i in css_extras) r = html_template % { 'js': js, 'css': css, 'modules': simplejson.dumps(module_boot(req, db=db)), 'init': 'var wc = new s.web.WebClient();wc.appendTo($(document.body));' } return r
def view(self, db, token, action, id, view='calendar'): registry = openerp.modules.registry.RegistryManager.get(db) meeting_pool = registry.get('calendar.event') attendee_pool = registry.get('calendar.attendee') partner_pool = registry.get('res.partner') with registry.cursor() as cr: attendee = attendee_pool.search_read(cr, openerp.SUPERUSER_ID, [('access_token', '=', token)], []) if attendee and attendee[0] and attendee[0].get('partner_id'): partner_id = int(attendee[0].get('partner_id')[0]) tz = partner_pool.read(cr, openerp.SUPERUSER_ID, partner_id, ['tz'])['tz'] else: tz = False attendee_data = meeting_pool.get_attendee(cr, openerp.SUPERUSER_ID, id, dict(tz=tz)) if attendee: attendee_data['current_attendee'] = attendee[0] css = '<link rel="stylesheet" href="/web/css/web.assets_backend"/>' js = '<script type="text/javascript" src="/web/js/web.assets_backend"></script>' return webmain.html_template % { 'js': js, 'css': css, 'modules': simplejson.dumps(webmain.module_boot(db)), 'init': "s.calendar.event('%s', '%s', '%s', '%s' , '%s');" % (db, action, id, 'form', json.dumps(attendee_data)), }
def app(self, req, s_action=None, **kw): template = html_template.replace('<html','<html manifest="/pod"') r = template % { 'modules': simplejson.dumps(module_boot(req)), 'init': 'var wc = new s.web.WebClient();wc.appendTo($(document.body));' } return r
def manager(self, **kw): # TODO: migrate the webclient's database manager to server side views request.session.logout() return env1.get_template("commgate_database_manager.html").render({ 'modules': simplejson.dumps(module_boot()), })
def exec_workflow(self, req, model, id, signal): addons = oeweb.module_boot(req, req.session._db) if addons : if 'workflow_info_user' in addons : can_pro = self.check_workflow_user(req, model, id, signal) if not can_pro: return {} return req.session.exec_workflow(model, id, signal)
def import_url(self, req, url): modules = webmain.module_boot(req) + ['edi'] modules_str = ','.join(modules) modules_json = simplejson.dumps(modules) js = "\n ".join('<script type="text/javascript" src="%s"></script>' % i for i in webmain.manifest_list(req, modules_str, 'js')) css = "\n ".join('<link rel="stylesheet" href="%s">' % i for i in webmain.manifest_list(req, modules_str, 'css')) return webmain.html_template % { 'js': js, 'css': css, 'modules': modules_json, 'init': 's.edi.edi_import("%s");' % url, }
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
def a(self, binary, tipo, **k): cr, uid, context, session = request.cr, request.uid, request.context, request.session print str( k ) + "---------------------------------------------------------------------------------------------------------------------\ ---------------------------------------------------------------------------------------------------------------" if not session.uid: return login_redirect() #modelo_registro = request.registry['rbs.documento.mercantil.'+k['tipo']] #registro_ids = registro.search(cr, uid, [('id','=',)], context=context) #registro = modelo_registro.browse(cr,uid,[1,],context = context) #data = registro.filedata #tiffstack = Image.open(BytesIO(base64.b64decode(data))) #tiffstack.load() #tiffstack.show() '''buffer = cStringIO.StringIO() tiffstack.seek(0) for l in range(tiffstack.n_frames): #tiffstack.show() tiffstack.save(buffer, format="JPEG") img_str = base64.b64encode(buffer.getvalue()) init +="document.getElementById('img').setAttribute( 'src', 'data:image/png;base64,"+img_str+"' );\n" ''' #PosSession = request.registry['pos.session'] #pos_session_ids = PosSession.search(cr, uid, [('state','=','opened'),('user_id','=',session.uid)], context=context) #if not pos_session_ids: # return werkzeug.utils.redirect('/web#action=web_tiff_widget.action_pos_session_opening') #PosSession.login(cr,uid,pos_session_ids,context=context) modules = simplejson.dumps(module_boot(request.db)) print modules init = "var tiff = TifWIdget('" + tipo + "'," + binary + ");" html = request.registry.get('ir.ui.view').render( cr, session.uid, 'web_tiff_widget.TiffEditWidget', { 'init': init, 'modules': modules, }) return html
def import_url(self, req, url): modules = webmain.module_boot(req) + ['edi'] modules_str = ','.join(modules) modules_json = simplejson.dumps(modules) js = "\n ".join( '<script type="text/javascript" src="%s"></script>' % i for i in webmain.manifest_list(req, modules_str, 'js')) css = "\n ".join( '<link rel="stylesheet" href="%s">' % i for i in webmain.manifest_list(req, modules_str, 'css')) return webmain.html_template % { 'js': js, 'css': css, 'modules': modules_json, 'init': 's.edi.edi_import("%s");' % url, }
def a(self, debug=False, **k): if not request.session.uid: return http.local_redirect('/web/login?redirect=/barcode/web') r = html_template % { 'modules': simplejson.dumps(module_boot(request.db)), 'init': """ var wc = new s.web.WebClient(); wc.show_application = function(){ wc.action_manager.do_action("stock.ui", {}); }; wc.do_push_state = function(state){}; wc.appendTo($(document.body)); """ } return r
def import_url(self, req, url): modules = webmain.module_boot(req) + ['edi'] modules_str = ','.join(modules) modules_json = simplejson.dumps(modules) js = "\n ".join('<script type="text/javascript" src="%s"></script>' % i for i in webmain.manifest_list(req, modules_str, 'js')) css = "\n ".join('<link rel="stylesheet" href="%s">' % i for i in webmain.manifest_list(req, modules_str, 'css')) # `url` may contain a full URL with a valid query string, we basically want to watch out for XML brackets and double-quotes safe_url = urllib.quote_plus(url,':/?&;=') return webmain.html_template % { 'js': js, 'css': css, 'modules': modules_json, 'init': 's.edi.edi_import("%s");' % safe_url, }
def a(self, debug=True, **k): if not request.session.uid: return login_redirect() values = { 'modules': simplejson.dumps(module_boot(request.db)), 'init': """ var wc = new s.web.WebClient(); wc.show_application = function(){ wc.action_manager.do_action("pos.ui"); }; wc.appendTo($(document.body)); """ } return request.render('point_of_sale_debug.web', values)
def a(self, debug=False, **k): if not request.session.uid: return login_redirect() r = html_template % { 'modules': simplejson.dumps(module_boot(request.db)), 'init': """ var wc = new s.web.WebClient(); wc.show_application = function(){ wc.action_manager.do_action("pos.ui"); }; wc.appendTo($(document.body)); """ } return r
def import_url(self, url): # http://hostname:8069/edi/import_url?url=URIEncodedURL req = openerp.http.request modules = webmain.module_boot(req) + ["edi"] modules_str = ",".join(modules) modules_json = simplejson.dumps(modules) css = '<link rel="stylesheet" href="/web/css/web.assets_backend"/>' js = '<script type="text/javascript" src="/web/js/web.assets_backend"></script>' # `url` may contain a full URL with a valid query string, we basically want to watch out for XML brackets and double-quotes safe_url = werkzeug.url_quote_plus(url, ":/?&;=") return webmain.html_template % { "js": js, "css": css, "modules": modules_json, "init": 's.edi.edi_import("%s");' % safe_url, }
def import_url(self, url): # http://hostname:8069/edi/import_url?url=URIEncodedURL req = openerp.http.request modules = webmain.module_boot(req) + ['edi'] modules_str = ','.join(modules) modules_json = simplejson.dumps(modules) css = '<link rel="stylesheet" href="/web/css/web.assets_backend"/>' js = '<script type="text/javascript" src="/web/js/web.assets_backend"></script>' # `url` may contain a full URL with a valid query string, we basically want to watch out for XML brackets and double-quotes safe_url = werkzeug.url_quote_plus(url, ':/?&;=') return webmain.html_template % { 'js': js, 'css': css, 'modules': modules_json, 'init': 's.edi.edi_import("%s");' % safe_url, }
def view(self, db, token, action, id, view='calendar'): registry = openerp.modules.registry.RegistryManager.get(db) meeting_pool = registry.get('calendar.event') attendee_pool = registry.get('calendar.attendee') with registry.cursor() as cr: attendee_data = meeting_pool.get_attendee(cr, openerp.SUPERUSER_ID, id); attendee = attendee_pool.search_read(cr, openerp.SUPERUSER_ID, [('access_token','=',token)],[]) if attendee: attendee_data['current_attendee'] = attendee[0] js = "\n ".join('<script type="text/javascript" src="%s"></script>' % i for i in webmain.manifest_list('js', db=db)) css = "\n ".join('<link rel="stylesheet" href="%s">' % i for i in webmain.manifest_list('css',db=db)) return webmain.html_template % { 'js': js, 'css': css, 'modules': simplejson.dumps(webmain.module_boot(db)), 'init': "s.calendar.event('%s', '%s', '%s', '%s' , '%s');" % (db, action, id, 'form', json.dumps(attendee_data)), }
def a(self, **kwargs): cr, session, context, uid = request.cr, request.session, request.context, request.uid modules = simplejson.dumps(module_boot(request.db)) init = """ var wc = new s.web.WebClient(); wc._title_changed = function(){} wc.show_application = function(){ wc.action_manager.do_action("calc.ui"); }; wc.setElement($(document.body)); wc.start(); """ html = request.registry.get('ir.ui.view').render( cr, session.uid, 'calc.home', { 'modules': modules, 'init': init, }) return html
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
def a(self, debug=False, **k): if not request.session.uid: return login_redirect() modules = simplejson.dumps(module_boot(request.db)) init = """ var wc = new s.web.WebClient(); wc.show_application = function(){ wc.action_manager.do_action("pos.ui"); }; wc.setElement($(document.body)); wc.start(); """ html = request.registry.get('ir.ui.view').render(request.cr, request.session.uid,'point_of_sale.index',{ 'modules': modules, 'init': init, }) return html
def view(self, db, token, action, id, view="calendar"): registry = openerp.modules.registry.RegistryManager.get(db) meeting_pool = registry.get("calendar.event") attendee_pool = registry.get("calendar.attendee") with registry.cursor() as cr: attendee_data = meeting_pool.get_attendee(cr, openerp.SUPERUSER_ID, id) attendee = attendee_pool.search_read(cr, openerp.SUPERUSER_ID, [("access_token", "=", token)], []) if attendee: attendee_data["current_attendee"] = attendee[0] js = "\n ".join( '<script type="text/javascript" src="%s"></script>' % i for i in webmain.manifest_list("js", db=db) ) css = "\n ".join('<link rel="stylesheet" href="%s">' % i for i in webmain.manifest_list("css", db=db)) return webmain.html_template % { "js": js, "css": css, "modules": simplejson.dumps(webmain.module_boot(db)), "init": "s.calendar.event('%s', '%s', '%s', '%s' , '%s');" % (db, action, id, "form", json.dumps(attendee_data)), }
def a(self, debug=False, **k): cr, uid, context, session = request.cr, request.uid, request.context, request.session if not session.uid: return login_redirect() PosSession = request.registry['pos.session'] pos_session_ids = PosSession.search(cr, uid, [('state', '=', 'opened'), ('user_id', '=', session.uid)], context=context) if not pos_session_ids: return werkzeug.utils.redirect( '/web#action=point_of_sale.action_pos_session_opening') PosSession.login(cr, uid, pos_session_ids, context=context) modules = simplejson.dumps(module_boot(request.db)) html = request.registry.get('ir.ui.view').render( cr, session.uid, 'point_of_sale.index', {'modules': modules}) return html
def a(self, debug=False, **k): if not request.session.uid: return login_redirect() js_list = manifest_list('js',db=request.db, debug=debug) css_list = manifest_list('css',db=request.db, debug=debug) js = "\n".join('<script type="text/javascript" src="%s"></script>' % i for i in js_list) #css = "\n".join('<link rel="stylesheet" href="%s">' % i for i in css_list) r = html_template % { 'js': js, # 'css': css, 'modules': simplejson.dumps(module_boot(request.db)), 'init': """ var wc = new s.web.WebClient(); wc.show_application = function(){ wc.action_manager.do_action("pos.ui"); }; wc.appendTo($(document.body)); """ } return r
def a(self, debug=False, **k): if not request.session.uid: return login_redirect() js_list = manifest_list('js',db=request.db, debug=debug) js = "\n".join('<script type="text/javascript" src="%s"></script>' % i for i in js_list) modules = simplejson.dumps(module_boot(request.db)) init = """ var wc = new s.web.WebClient(); wc.show_application = function(){ wc.action_manager.do_action("pos.ui"); }; wc.appendTo($(document.body)); """ html = request.registry.get('ir.ui.view').render(request.cr, request.session.uid,'point_of_sale.index',{ 'js': js, 'modules': modules, 'init': init, }) return html
def a_s(self, **k): cr, uid, context, session = request.cr, request.uid, request.context, request.session print str( k ) + "---------------------------------------------------------------------------------------------------------------------\ ---------------------------------------------------------------------------------------------------------------" if not session.uid: return login_redirect() modules = simplejson.dumps(module_boot(request.db)) print modules #init ="var tiff = TifWIdget('"+tipo+"',"+binary+");" html = request.registry.get('ir.ui.view').render( cr, session.uid, 'web_tiff_widget.TiffSeparator', { # 'init': init, 'modules': modules, }) return html
def view(self, db, token, action, id, view='calendar'): registry = openerp.modules.registry.RegistryManager.get(db) meeting_pool = registry.get('calendar.event') attendee_pool = registry.get('calendar.attendee') partner_pool = registry.get('res.partner') with registry.cursor() as cr: attendee = attendee_pool.search_read( cr, openerp.SUPERUSER_ID, [('access_token', '=', token)], []) if attendee and attendee[0] and attendee[0].get('partner_id'): partner_id = int(attendee[0].get('partner_id')[0]) tz = partner_pool.read(cr, openerp.SUPERUSER_ID, partner_id, ['tz'])['tz'] else: tz = False attendee_data = meeting_pool.get_attendee(cr, openerp.SUPERUSER_ID, id, dict(tz=tz)) if attendee: attendee_data['current_attendee'] = attendee[0] css = '<link rel="stylesheet" href="/web/css/web.assets_backend"/>' js = '<script type="text/javascript" src="/web/js/web.assets_backend"></script>' return webmain.html_template % { 'js': js, 'css': css, 'modules': simplejson.dumps(webmain.module_boot(db)), 'init': "s.calendar.event('%s', '%s', '%s', '%s' , '%s');" % (db, action, id, 'form', json.dumps(attendee_data)), }
def get_modules_order(): if request: from openerp.addons.web.controllers.main import module_boot return simplejson.dumps(module_boot()) return '[]'