本文整理匯總了Python中odoo.http.route方法的典型用法代碼示例。如果您正苦於以下問題:Python http.route方法的具體用法?Python http.route怎麽用?Python http.route使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類odoo.http
的用法示例。
在下文中一共展示了http.route方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: pos_web
# 需要導入模塊: from odoo import http [as 別名]
# 或者: from odoo.http import route [as 別名]
def pos_web(self, debug=False, **k):
pos_sessions = request.env['pos.session'].search([
('state', '=', 'opened'),
('user_id', '=', request.session.uid),
('name', 'not like', '(RESCUE FOR')])
if not pos_sessions:
return werkzeug.utils.redirect('/web#action=gooderp_pos.action_client_pos_menu')
pos_sessions.login()
context = {
'session_info': json.dumps(request.env['ir.http'].session_info())
}
return request.render('gooderp_pos.index', qcontext=context)
# @http.route('/pos/sale_details_report', type='http', auth='user')
# def print_sale_details(self, date_start=False, date_stop=False, **kw):
# r = request.env['report.gooderp_pos.report_saledetails']
# pdf = request.env['report'].with_context(date_start=date_start, date_stop=date_stop).get_pdf(r, 'gooderp_pos.report_saledetails')
# pdfhttpheaders = [('Content-Type', 'application/pdf'), ('Content-Length', len(pdf))]
# return request.make_response(pdf, headers=pdfhttpheaders)
示例2: test1
# 需要導入模塊: from odoo import http [as 別名]
# 或者: from odoo.http import route [as 別名]
def test1(self):
result = ''
openacademy_course = http.request.env['openacademy.course']
result += openacademy_course.search([]).__str__() + '<br/>'
result += openacademy_course.search([], limit=1).name.__str__() + '<br/>'
# result += openacademy_course.create({'name': "new_course1"}).__str__() + '<br/>'
result += openacademy_course.browse([1]).name.__str__() + '<br/>'
result += openacademy_course.search_count([]).__str__() + '<br/>'
# result += openacademy_course.search([('name', '=', 'new_course1')])\
# .write({'name': 'new_course11'}).__str__() + '<br/>'
# result += openacademy_course.search([('name', '=', 'new_course11')]).unlink().__str__() + '<br/>'
# result += openacademy_course.search([]).__str__() + '<br/>'
return result
# class CrudTest(http.Controller):
# @http.route('/crud_test/crud_test/', auth='public')
# def index(self, **kw):
# return "Hello, world"
# @http.route('/crud_test/crud_test/objects/', auth='public')
# def list(self, **kw):
# return http.request.render('crud_test.listing', {
# 'root': '/crud_test/crud_test',
# 'objects': http.request.env['crud_test.crud_test'].search([]),
# })
# @http.route('/crud_test/crud_test/objects/<model("crud_test.crud_test"):obj>/', auth='public')
# def object(self, obj, **kw):
# return http.request.render('crud_test.object', {
# 'object': obj
# })