本文整理匯總了Python中openerp.http.request.env方法的典型用法代碼示例。如果您正苦於以下問題:Python request.env方法的具體用法?Python request.env怎麽用?Python request.env使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類openerp.http.request
的用法示例。
在下文中一共展示了request.env方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: verify_data
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import env [as 別名]
def verify_data(self, **post):
if not post:
return False
else:
isSign = self.getSignVeryfy(**post)
responseTxt = 'false'
if post['notify_id']:
responseTxt = self.getResponse(post['notify_id'])
#??
#$responsetTxt?????true???????????????ID?notify_id???????
#isSign?????true??????????????????????????????????
if responseTxt== 'true' and isSign:
res = request.env['payment.transaction'].sudo().form_feedback(post,'alipay')
return True
else:
return False
示例2: all_books_mark_mine
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.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
示例3: website_info
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import env [as 別名]
def website_info(self):
try:
request.website.get_template('website.info').name
except Exception, e:
return request.registry['ir.http']._handle_exception(e, 404)
irm = request.env()['ir.module.module'].sudo()
apps = irm.search([('state','=','installed'),('application','=',True)])
modules = irm.search([('state','=','installed'),('application','=',False)])
values = {
'apps': apps,
'modules': modules,
'version': openerp.service.common.exp_version()
}
return request.render('website.info', values)
#------------------------------------------------------
# Edit
#------------------------------------------------------
示例4: icalendar_public
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import env [as 別名]
def icalendar_public(self, partner=None, **post):
if partner:
#~ raise Warning("Public successfull %s" % partner.get_ics_calendar(type='public').to_ical())
#~ return partner.sudo().get_ics_calendar(type='public')
document = request.env['res.partner'].sudo().browse(partner).get_ics_calendar(type='public')
return request.make_response(
document,
headers=[
('Content-Disposition', 'attachment; filename="public.ics"'),
('Content-Type', 'text/calendar'),
('Content-Length', len(document)),
]
)
else:
raise Warning("Public failed")
pass # Some error page
示例5: get_ics_events
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import env [as 別名]
def get_ics_events(self):
if (self.ics_url):
try:
res = urllib2.urlopen(self.ics_url).read()
except urllib2.HTTPError as e:
_logger.error('ICS a %s %s' % (e.code, e.reason))
return False
except urllib2.URLError as e:
_logger.error('ICS c %s %s' % (e.code, e.reason))
return False
_logger.debug('ICS %s' % res)
self.env['calendar.event'].search(['&',('partner_ids','in',self.id),('ics_subscription','=',True)]).unlink()
#~ for event in self.env['calendar.event'].search([('ics_id','=',self.id)]):
#~ event.unlink()
self.env['calendar.event'].set_ics_event(res, self)
示例6: get_pricelist
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import env [as 別名]
def get_pricelist():
sale_order = request.env.context.get('sale_order')
if sale_order:
pricelist = sale_order.pricelist_id
else:
partner = request.env.user.partner_id
pricelist = partner.property_product_pricelist
return pricelist
示例7: get_cfg_session
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import env [as 別名]
def get_cfg_session(self, product_tmpl, force_create=False):
"""Retrieve the product.config.session from backend holding all the
configuration data stored so far by this user for the designated
product template object"""
public_user_id = request.env.ref('base.public_user').id
cfg_session_obj = request.env['product.config.session']
domain = [
('product_tmpl_id', '=', product_tmpl.id),
('user_id', '=', request.env.user.id),
('website', '=', True),
('state', '=', 'draft')
]
if request.env.uid == public_user_id:
domain.append(('session_id', '=', request.session.sid))
cfg_session = cfg_session_obj.search(domain)
if not cfg_session and force_create:
vals = {
'product_tmpl_id': product_tmpl.id,
'user_id': request.env.user.id,
'website': True
}
if request.env.uid == public_user_id:
vals.update(session_id=request.session.sid)
cfg_session = cfg_session_obj.sudo().create(vals)
return cfg_session
示例8: getResponse
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import env [as 別名]
def getResponse(self,notify_id):
# provider = request.env['payment.acquirer'].search([('provider','=','alipay')])
# partner = provider.alipay_partner
# transport = provider.alipay_transport
# veryfy_url = ''
# if transport == 'https':
# veryfy_url = self.https_verify_url
# else:
# veryfy_url = self.http_verify_url
# partner = request.env['payment.acquirer'].search([('provider','=','alipay')],limit=1).alipay_partner
veryfy_url = self.https_verify_url
partner = '2088211834350245'
veryfy_url += 'partner='+partner+'¬ify_id='+notify_id
resp = urllib2.urlopen(veryfy_url)
data = resp.read()
resp.close()
return data
示例9: all_books
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import env [as 別名]
def all_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 result
示例10: all_books_mine
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import env [as 別名]
def all_books_mine(self):
records = request.env['library.book'].search([
('author_ids', 'in', request.env.user.partner_id.ids),
])
result = '<html><body><table><tr><td>'
result += '</td></tr><tr><td>'.join(records.mapped('name'))
result += '</td></tr></table></body></html>'
return result
示例11: to_python
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import env [as 別名]
def to_python(self, value):
result = request.env[self.model].browse(
map(lambda x: x[0], request.env[self.model].sudo().name_search(
value.replace('+', ' '), operator='=ilike', limit=1)))
if not result:
raise werkzeug.exceptions.NotFound()
return result
示例12: book_details
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import env [as 別名]
def book_details(self, book_id):
record = request.env['library.book'].sudo().browse(int(book_id))
return '<html><body><h1>%s</h1>Authors: %s' % (
record.name,
', '.join(record.author_ids.mapped('name')) or 'none',
)
示例13: books_json
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import env [as 別名]
def books_json(self):
records = request.env['library.book'].sudo().search([])
return records.read(['name'])
示例14: route
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import env [as 別名]
def route(self):
return request.render(
'ch14_r02_creating_or_modifying_templates.books',
{
'books': request.env['library.book'].search([]),
})
示例15: send
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import env [as 別名]
def send(self, channel, message):
if not isinstance(channel, basestring):
raise Exception("bus.Bus only string channels are allowed.")
return request.env['bus.bus'].sendone(channel, message)
# override to add channels