Dalam mengembangkan aplikasi berteknologi Odoo kita mungkin ingin menampikan suatu informasi dimana informasi yang disajikan sesuai yang diinput pengguna. Di sini kita akan menggunakan routing dengan parameter.
Route dengan parameter pada pemrograman berteknologi Odoo adalah seperti pada berikut ini
- Start SSH file system

- Source code main.py pada controllers
from odoo import http from odoo.http import request class Main(http.Controller): @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 upgrade modul


- Hasil pada tampilan

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