本文整理匯總了Python中odoo.http.request.env方法的典型用法代碼示例。如果您正苦於以下問題:Python request.env方法的具體用法?Python request.env怎麽用?Python request.env使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類odoo.http.request
的用法示例。
在下文中一共展示了request.env方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: list
# 需要導入模塊: from odoo.http import request [as 別名]
# 或者: from odoo.http.request import env [as 別名]
def list(self, sub_domain, categoryId=False, nameLike=False, **kwargs):
category_id = categoryId
try:
ret, entry = self._check_domain(sub_domain)
if ret: return ret
domain = [('wxxcx_published', '=', True)]
if category_id:
cate_ids = [int(category_id)] + request.env['wxxcx.course.category'].sudo().browse(
int(category_id)).child_ids.ids
domain.append(('wxxcx_category_id', 'in', cate_ids))
if nameLike:
domain.append(('name', 'ilike', nameLike))
course_list = request.env['course.template'].sudo().search(domain)
if not course_list:
return self.res_err(404)
return self.res_ok([self._course_basic_dict(each_goods) for each_goods in course_list])
except Exception as e:
_logger.exception(e)
return self.res_err(-1, e.message)
示例2: check_token
# 需要導入模塊: from odoo.http import request [as 別名]
# 或者: from odoo.http.request import env [as 別名]
def check_token(self, sub_domain, token=None, **kwargs):
try:
ret, entry = self._check_domain(sub_domain)
if ret:return ret
if not token:
return self.res_err(300)
access_token = request.env(user=1)['wxapp.access_token'].search([
('token', '=', token),
])
if not access_token:
return self.res_err(901)
return self.res_ok()
except Exception as e:
_logger.exception(e)
return self.res_err(-1, e.message)
示例3: get_timetable
# 需要導入模塊: from odoo.http import request [as 別名]
# 或者: from odoo.http.request import env [as 別名]
def get_timetable(self,sub_domain,uid=False,student_ids=False,**kwargs):
user_id = uid
try:
if not user_id:
return self.res_err(300)
ret, entry = self._check_domain(sub_domain)
if ret: return ret
user = request.env['wxxcx.user'].sudo().browse(int(user_id))
if not user or not user.partner_id :
return self.res_err(404)
except Exception as e:
_logger.exception(e)
return self.res_err(-1,e.message)
示例4: _check_user
# 需要導入模塊: from odoo.http import request [as 別名]
# 或者: from odoo.http.request import env [as 別名]
def _check_user(self, sub_domain, token):
user = request.env['wxxcx.config'].sudo().search([('sub_domain', '=', sub_domain)])
if not user:
return self.res_err(404), None, user
if not token:
return self.res_err(300), None, user
access_token = request.env(user=1)['wxxcx.access_token'].search([
('token', '=', token),
#('create_uid', '=', user.id)
])
if not access_token:
return self.res_err(901), None, user
wechat_user = request.env(user=1)['wxxcx.user'].search([
('open_id', '=', access_token.open_id),
#('create_uid', '=', user.id)
])
if not wechat_user:
return self.res_err(10000), None, user
return None, wechat_user, user
示例5: all_books_mark_mine
# 需要導入模塊: from odoo.http import request [as 別名]
# 或者: from odoo.http.request import env [as 別名]
def all_books_mark_mine(self):
records = request.env['library.book'].sudo().search([])
result = '<html><body><table>'
for record in records:
result += '<tr>'
if record.author_ids & request.env.user.partner_id:
result += '<th>'
else:
result += '<td>'
result += record.name
if record.author_ids & request.env.user.partner_id:
result += '</th>'
else:
result += '</td>'
result += '</tr>'
result += '</table></body></html>'
return result
示例6: books
# 需要導入模塊: from odoo.http import request [as 別名]
# 或者: from odoo.http.request import env [as 別名]
def books(self):
records = request.env['library.book'].sudo().search([])
result = '<html><body><table><tr><td>'
result += '</td></tr><tr><td>'.join(records.mapped('name'))
result += '</td></tr></table></body></html>'
# return request.make_response(
# result, [
# ('Last-modified', email.utils.formatdate(
# (
# fields.Datetime.from_string(
# request.env['library.book'].sudo()
# .search([], order='write_date desc', limit=1)
# .write_date) -
# datetime.datetime(1970, 1, 1)
# ).total_seconds(),
# usegmt=True)),
# ])
return result
# test this with
# curl -i -X POST -H "Content-Type: application/json" -d {} $URL
示例7: get
# 需要導入模塊: from odoo.http import request [as 別名]
# 或者: from odoo.http.request import env [as 別名]
def get(self, sub_domain, token=None, **kwargs):
try:
user = request.env['res.users'].sudo().search([('sub_domain', '=', sub_domain)])
if not user:
return request.make_response(json.dumps({'code': 404, 'msg': error_code[404]}))
if not token:
return request.make_response(json.dumps({'code': 300, 'msg': error_code[300].format('token')}))
access_token = request.env(user=user.id)['wechat_mall.access_token'].search([
('token', '=', token),
('create_uid', '=', user.id)
])
if not access_token:
return request.make_response(json.dumps({'code': 901, 'msg': error_code[901]}))
return request.make_response(json.dumps({'code': 0, 'msg': 'success'}))
except Exception as e:
_logger.exception(e)
return request.make_response(json.dumps({'code': -1, 'msg': error_code[-1], 'data': e.message}))
示例8: index
# 需要導入模塊: from odoo.http import request [as 別名]
# 或者: from odoo.http.request import env [as 別名]
def index(self, **kwargs):
Bugs = request.env['bm.bug']
bugs = Bugs.search([])
return request.render(
'bug-website.index',
{'bugs': bugs})
示例9: add
# 需要導入模塊: from odoo.http import request [as 別名]
# 或者: from odoo.http.request import env [as 別名]
def add(self, **kwargs):
users = request.env['res.users'].search([])
return request.render(
'bug-website.add', {'users': users})
示例10: library_books
# 需要導入模塊: from odoo.http import request [as 別名]
# 或者: from odoo.http.request import env [as 別名]
def library_books(self):
country_id = False
country_code = request.session.geoip and request.session.geoip.get('country_code') or False
if country_code:
country_ids = request.env['res.country'].sudo().search([('code', '=', country_code)])
if country_ids:
country_id = country_ids[0].id
domain = ['|', ('restrict_country_ids', '=', False), ('restrict_country_ids', 'not in', [country_id])]
return request.render(
'my_library.books', {
'books': request.env['library.book'].search(domain),
})
示例11: sitemap_books
# 需要導入模塊: from odoo.http import request [as 別名]
# 或者: from odoo.http.request import env [as 別名]
def sitemap_books(env, rule, qs):
Books = env['library.book']
dom = sitemap_qs2dom(qs, '/books', Books._rec_name)
for f in Books.search(dom):
loc = '/books/%s' % slug(f)
if not qs or qs.lower() in loc:
yield {'loc': loc}
示例12: books_issues
# 需要導入模塊: from odoo.http import request [as 別名]
# 或者: from odoo.http.request import env [as 別名]
def books_issues(self, **post):
if post.get('book_id'):
book_id = int(post.get('book_id'))
issue_description = post.get('issue_description')
request.env['book.issue'].sudo().create({
'book_id': book_id,
'issue_description': issue_description,
'submitted_by': request.env.user.id
})
return request.redirect('/books/submit_issues?submitted=1')
return request.render('my_library.books_issue_form', {
'books': request.env['library.book'].search([]),
'submitted': post.get('submitted', False)
})
示例13: library_books
# 需要導入模塊: from odoo.http import request [as 別名]
# 或者: from odoo.http.request import env [as 別名]
def library_books(self):
return request.render(
'my_library.books', {
'books': request.env['library.book'].search([]),
})
示例14: books
# 需要導入模塊: from odoo.http import request [as 別名]
# 或者: from odoo.http.request import env [as 別名]
def books(self):
books = request.env['library.book'].sudo().search([])
html_result = '<html><body><ul>'
for book in books:
html_result += "<li> %s </li>" % book.name
html_result += '</ul></body></html>'
return html_result
示例15: book_details
# 需要導入模塊: from odoo.http import request [as 別名]
# 或者: from odoo.http.request import env [as 別名]
def book_details(self, book_id):
record = request.env['library.book'].sudo().browse(int(book_id))
return u'<html><body><h1>%s</h1>Authors: %s' % (
record.name,
u', '.join(record.author_ids.mapped('name')) or 'none',
)