本文整理匯總了Python中openerp.http.request.uid方法的典型用法代碼示例。如果您正苦於以下問題:Python request.uid方法的具體用法?Python request.uid怎麽用?Python request.uid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類openerp.http.request
的用法示例。
在下文中一共展示了request.uid方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _postprocess_args
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import uid [as 別名]
def _postprocess_args(self, arguments, rule):
super(ir_http, self)._postprocess_args(arguments, rule)
for key, val in arguments.items():
# Replace uid placeholder by the current request.uid
if isinstance(val, orm.BaseModel) and isinstance(val._uid, RequestUID):
arguments[key] = val.sudo(request.uid)
try:
_, path = rule.build(arguments)
assert path is not None
except Exception, e:
return self._handle_exception(e, code=404)
if getattr(request, 'website_multilang', False) and request.httprequest.method in ('GET', 'HEAD'):
generated_path = werkzeug.url_unquote_plus(path)
current_path = werkzeug.url_unquote_plus(request.httprequest.path)
if generated_path != current_path:
if request.lang != request.website.default_lang_code:
path = '/' + request.lang + path
if request.httprequest.query_string:
path += '?' + request.httprequest.query_string
return werkzeug.utils.redirect(path, code=301)
示例2: generate
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import uid [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
示例3: theme_change
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import uid [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})
示例4: get_country_events
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import uid [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)
示例5: toc
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import uid [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)
示例6: get_attribute_value_ids
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import uid [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
示例7: _get_default_image
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import uid [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'))
示例8: _get_image
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import uid [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
示例9: _set_image
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import uid [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)
示例10: _are_you_inside
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import uid [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
示例11: _script_external
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import uid [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
示例12: _web_page
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import uid [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
示例13: _default_user_ids
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import uid [as 別名]
def _default_user_ids(self, cr, uid, context=None):
return [(6, 0, [uid])]
示例14: get_available_users
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import uid [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
示例15: get_channel_session
# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import uid [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)