Dalam menampilkan informasi kepada pengguna kita mungkin akan menampilkan gambar yang selalu tetap tertentu misalnya logo. Di sini kita dapat menggunakan static resources.
Static resources pada pemrograman Odoo adalah seperti berikut ini
- Start SSH file system


- Controller main
from odoo import http from odoo.http import request from odoo.addons.website.controllers.main import Website class WebsiteInfo(Website): @http.route() def website_info(self): result = super(WebsiteInfo,self).website_info() result.qcontext['apps'] = result.qcontext['apps'].filtered( lambda x: x.name != 'website' ) return result class Main(http.Controller): @http.route('/demo_page',type='http',auth='none') def demoku(self): image_url = '/asramaku/static/src/image/odoo.png' html_result = """<html> <body> <img src="%s" /> </body> </html>""" % image_url return html_result @http.route('/asramaku/student_details', type='http', auth='none') def student_details(self,student_id): record = request.env['asrama.student'].sudo().browse(int(student_id)) return u'<html><body><h1>%s</h1> Room No: %s' % ( record.name, str(record.room_id.room_no) or 'none', ) @http.route('/asramaku/student_details/<model("asrama.student"):student>', type='http', auth='none') def student_details_in_path(self,student): return self.student_details(student.id) @http.route('/asramaku/all-students',type='http',auth='none') def all_students(self): students = request.env['asrama.student'].sudo().search([]) html_result = '<html><body><ul>' for student in students: html_result += "<li> %s </li>" % student.name html_result += '</ul></body></html>' return html_result @http.route('/asramaku/all-students/mark-mine',type='http', auth='public') def all_students_mark_mine(self): students = request.env['asrama.student'].sudo().search([]) hostels = request.env['asrama.hostel'].sudo().search([('rector','=', request.env.user.partner_id.id)]) hostel_rooms = request.env['asrama.room'].sudo().search([('hostel_id','in',hostels.ids)]) html_result = '<html><body><ul>' for student in students: if student.id in hostel_rooms.student_ids.ids: html_result += "<li> <b>%s</b> </li>" % student.name else: html_result += "<li> %s </li>" % student.name html_result += '</ul></body></html>' return html_result @http.route('/asramaku/all-students/mine',type='http', auth='user') def all_students_mine(self): hostels = request.env['asrama.hostel'].sudo().search([('rector','=', request.env.user.partner_id.id)]) students = request.env['asrama.room'].sudo().search([('hostel_id','in',hostels.ids)]).student_ids html_result = '<html><body><ul>' for student in students: html_result += "<li> %s </li>" % student.name html_result += '</ul></body></html>' return html_result @http.route('/asramaku/students', type='http', auth='none') def students(self): students = request.env['asrama.student'].sudo().search([]) html_result = '<html><body><ul>' for student in students: html_result += "<li> %s </li>" % student.name html_result += '</ul></body></html>' return html_result @http.route('/asramaku/students/json',type='json',auth='none') def students_json(self): records = request.env['asrama.student'].sudo().search([]) return records.read(['name']) - Start SSH dengan update modul



- Tampilan static resources

Kunjungi https://www.proweb.co.id/implementasi-odoo/ untuk menambah wawasan anda mengenai Odoo.
