本文整理汇总了Python中openerp.http.request.cr方法的典型用法代码示例。如果您正苦于以下问题:Python request.cr方法的具体用法?Python request.cr怎么用?Python request.cr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openerp.http.request
的用法示例。
在下文中一共展示了request.cr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate
# 需要导入模块: from openerp.http import request [as 别名]
# 或者: from openerp.http.request import cr [as 别名]
def generate(self, cr, uid, query=None, args={}, context=None):
View = request.registry['ir.ui.view']
views = View.search_read(cr, uid, [['page', '=', True]],
fields=['xml_id','priority','write_date'], order='name', context=context)
for view in views:
xid = view['xml_id'].startswith('website.') and view['xml_id'][8:] or view['xml_id']
# the 'page/homepage' url is indexed as '/', avoid aving the same page referenced twice
# when we will have an url mapping mechanism, replace this by a rule: page/homepage --> /
if xid=='homepage': continue
if query and query.lower() not in xid.lower():
continue
record = {'loc': xid}
if view['priority'] <> 16:
record['__priority'] = min(round(view['priority'] / 32.0,1), 1)
if view['write_date']:
record['__lastmod'] = view['write_date'][:10]
yield record
示例2: theme_change
# 需要导入模块: from openerp.http import request [as 别名]
# 或者: from openerp.http.request import cr [as 别名]
def theme_change(self, theme_id=False, **kwargs):
imd = request.registry['ir.model.data']
Views = request.registry['ir.ui.view']
_, theme_template_id = imd.get_object_reference(
request.cr, request.uid, 'website', 'theme')
views = Views.search(request.cr, request.uid, [
('inherit_id', '=', theme_template_id),
], context=request.context)
Views.write(request.cr, request.uid, views, {
'active': False,
}, context=dict(request.context or {}, active_test=True))
if theme_id:
module, xml_id = theme_id.split('.')
_, view_id = imd.get_object_reference(
request.cr, request.uid, module, xml_id)
Views.write(request.cr, request.uid, [view_id], {
'active': True
}, context=dict(request.context or {}, active_test=True))
return request.render('website.themes', {'theme_changed': True})
示例3: get_country_events
# 需要导入模块: from openerp.http import request [as 别名]
# 或者: from openerp.http.request import cr [as 别名]
def get_country_events(self ,**post):
cr, uid, context, event_ids = request.cr, request.uid, request.context,[]
country_obj = request.registry['res.country']
event_obj = request.registry['event.event']
country_code = request.session['geoip'].get('country_code')
result = {'events':[],'country':False}
if country_code:
country_ids = country_obj.search(cr, uid, [('code', '=', country_code)], context=context)
event_ids = event_obj.search(cr, uid, ['|', ('address_id', '=', None),('country_id.code', '=', country_code),('date_begin','>=', time.strftime('%Y-%m-%d 00:00:00')),('state', '=', 'confirm')], order="date_begin", context=context)
if not event_ids:
event_ids = event_obj.search(cr, uid, [('date_begin','>=', time.strftime('%Y-%m-%d 00:00:00')),('state', '=', 'confirm')], order="date_begin", context=context)
for event in event_obj.browse(cr, uid, event_ids, context=context)[:6]:
if country_code and event.country_id.code == country_code:
result['country'] = country_obj.browse(cr, uid, country_ids[0], context=context)
result['events'].append({
"date": self.get_formated_date(event),
"event": event,
"url": event.website_url})
return request.website.render("website_event.country_events_list",result)
示例4: toc
# 需要导入模块: from openerp.http import request [as 别名]
# 或者: from openerp.http.request import cr [as 别名]
def toc(self, toc=None, **kwargs):
cr, uid, context, toc_id = request.cr, request.uid, request.context, False
if toc:
sections = toc.child_ids
forum = toc.forum_id
else:
toc_obj = request.registry['forum.documentation.toc']
obj_ids = toc_obj.search(cr, uid, [('parent_id', '=', False)], context=context)
sections = toc_obj.browse(cr, uid, obj_ids, context=context)
forum = sections and sections[0].forum_id or False
value = {
'toc': toc,
'main_object': toc or forum,
'forum': forum,
'sections': sections,
}
return request.website.render("website_forum_doc.documentation", value)
示例5: get_attribute_value_ids
# 需要导入模块: from openerp.http import request [as 别名]
# 或者: from openerp.http.request import cr [as 别名]
def get_attribute_value_ids(self, product):
cr, uid, context, pool = request.cr, request.uid, request.context, request.registry
currency_obj = pool['res.currency']
attribute_value_ids = []
visible_attrs = set(l.attribute_id.id
for l in product.attribute_line_ids
if len(l.value_ids) > 1)
if request.website.pricelist_id.id != context['pricelist']:
website_currency_id = request.website.currency_id.id
currency_id = self.get_pricelist().currency_id.id
for p in product.product_variant_ids:
price = currency_obj.compute(cr, uid, website_currency_id, currency_id, p.lst_price)
attribute_value_ids.append([p.id, [v.id for v in p.attribute_value_ids if v.attribute_id.id in visible_attrs], p.price, price])
else:
attribute_value_ids = [[p.id, [v.id for v in p.attribute_value_ids if v.attribute_id.id in visible_attrs], p.price, p.lst_price]
for p in product.product_variant_ids]
return attribute_value_ids
示例6: _get_default_image
# 需要导入模块: from openerp.http import request [as 别名]
# 或者: from openerp.http.request import cr [as 别名]
def _get_default_image(self, cr, uid, context=None):
image_path = openerp.modules.get_module_resource('im_livechat', 'static/src/img', 'default.png')
return tools.image_resize_image_big(open(image_path, 'rb').read().encode('base64'))
示例7: _get_image
# 需要导入模块: from openerp.http import request [as 别名]
# 或者: from openerp.http.request import cr [as 别名]
def _get_image(self, cr, uid, ids, name, args, context=None):
result = dict.fromkeys(ids, False)
for obj in self.browse(cr, uid, ids, context=context):
result[obj.id] = tools.image_get_resized_images(obj.image)
return result
示例8: _set_image
# 需要导入模块: from openerp.http import request [as 别名]
# 或者: from openerp.http.request import cr [as 别名]
def _set_image(self, cr, uid, id, name, value, args, context=None):
return self.write(cr, uid, [id], {'image': tools.image_resize_image_big(value)}, context=context)
示例9: _are_you_inside
# 需要导入模块: from openerp.http import request [as 别名]
# 或者: from openerp.http.request import cr [as 别名]
def _are_you_inside(self, cr, uid, ids, name, arg, context=None):
res = {}
for record in self.browse(cr, uid, ids, context=context):
res[record.id] = False
for user in record.user_ids:
if user.id == uid:
res[record.id] = True
break
return res
示例10: _script_external
# 需要导入模块: from openerp.http import request [as 别名]
# 或者: from openerp.http.request import cr [as 别名]
def _script_external(self, cr, uid, ids, name, arg, context=None):
values = {
"url": self.pool.get('ir.config_parameter').get_param(cr, openerp.SUPERUSER_ID, 'web.base.url'),
"dbname":cr.dbname
}
res = {}
for record in self.browse(cr, uid, ids, context=context):
values["channel"] = record.id
res[record.id] = self.pool['ir.ui.view'].render(cr, uid, 'im_livechat.external_loader', values, context=context)
return res
示例11: _web_page
# 需要导入模块: from openerp.http import request [as 别名]
# 或者: from openerp.http.request import cr [as 别名]
def _web_page(self, cr, uid, ids, name, arg, context=None):
res = {}
for record in self.browse(cr, uid, ids, context=context):
res[record.id] = self.pool.get('ir.config_parameter').get_param(cr, openerp.SUPERUSER_ID, 'web.base.url') + \
"/im_livechat/support/%s/%i" % (cr.dbname, record.id)
return res
示例12: _default_user_ids
# 需要导入模块: from openerp.http import request [as 别名]
# 或者: from openerp.http.request import cr [as 别名]
def _default_user_ids(self, cr, uid, context=None):
return [(6, 0, [uid])]
示例13: get_available_users
# 需要导入模块: from openerp.http import request [as 别名]
# 或者: from openerp.http.request import cr [as 别名]
def get_available_users(self, cr, uid, channel_id, context=None):
""" get available user of a given channel """
channel = self.browse(cr, uid, channel_id, context=context)
users = []
for user_id in channel.user_ids:
if (user_id.im_status == 'online'):
users.append(user_id)
return users
示例14: get_channel_session
# 需要导入模块: from openerp.http import request [as 别名]
# 或者: from openerp.http.request import cr [as 别名]
def get_channel_session(self, cr, uid, channel_id, anonymous_name, context=None):
""" return a session given a channel : create on with a registered user, or return false otherwise """
# get the avalable user of the channel
users = self.get_available_users(cr, uid, channel_id, context=context)
if len(users) == 0:
return False
user_id = random.choice(users).id
# create the session, and add the link with the given channel
Session = self.pool["im_chat.session"]
newid = Session.create(cr, uid, {'user_ids': [(4, user_id)], 'channel_id': channel_id, 'anonymous_name' : anonymous_name}, context=context)
return Session.session_info(cr, uid, [newid], context=context)
示例15: test_channel
# 需要导入模块: from openerp.http import request [as 别名]
# 或者: from openerp.http.request import cr [as 别名]
def test_channel(self, cr, uid, channel, context=None):
if not channel:
return {}
return {
'url': self.browse(cr, uid, channel[0], context=context or {}).web_page,
'type': 'ir.actions.act_url'
}