當前位置: 首頁>>代碼示例>>Python>>正文


Python request.env方法代碼示例

本文整理匯總了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) 
開發者ID:ScottAI,項目名稱:-Odoo---,代碼行數:26,代碼來源:course_sale.py

示例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) 
開發者ID:ScottAI,項目名稱:-Odoo---,代碼行數:22,代碼來源:user.py

示例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) 
開發者ID:ScottAI,項目名稱:-Odoo---,代碼行數:18,代碼來源:timetable.py

示例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 
開發者ID:ScottAI,項目名稱:-Odoo---,代碼行數:27,代碼來源:base.py

示例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 
開發者ID:PacktPublishing,項目名稱:Odoo-11-Development-Coobook-Second-Edition,代碼行數:19,代碼來源:main.py

示例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 
開發者ID:PacktPublishing,項目名稱:Odoo-11-Development-Coobook-Second-Edition,代碼行數:23,代碼來源:main.py

示例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})) 
開發者ID:elfgzp,項目名稱:wechat_mall,代碼行數:24,代碼來源:wechat_user.py

示例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}) 
開發者ID:ScottAI,項目名稱:Odoo-Python-ERP-,代碼行數:8,代碼來源:main.py

示例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}) 
開發者ID:ScottAI,項目名稱:Odoo-Python-ERP-,代碼行數:6,代碼來源:main.py

示例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),
            }) 
開發者ID:PacktPublishing,項目名稱:Odoo-12-Development-Cookbook-Third-Edition,代碼行數:14,代碼來源:main.py

示例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} 
開發者ID:PacktPublishing,項目名稱:Odoo-12-Development-Cookbook-Third-Edition,代碼行數:9,代碼來源:main.py

示例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)
        }) 
開發者ID:PacktPublishing,項目名稱:Odoo-12-Development-Cookbook-Third-Edition,代碼行數:17,代碼來源:main.py

示例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([]),
            }) 
開發者ID:PacktPublishing,項目名稱:Odoo-12-Development-Cookbook-Third-Edition,代碼行數:7,代碼來源:main.py

示例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 
開發者ID:PacktPublishing,項目名稱:Odoo-12-Development-Cookbook-Third-Edition,代碼行數:9,代碼來源:main.py

示例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',
        ) 
開發者ID:PacktPublishing,項目名稱:Odoo-12-Development-Cookbook-Third-Edition,代碼行數:8,代碼來源:main.py


注:本文中的odoo.http.request.env方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。