[MERGE] Forward-port of saas-5 up to 9ce08b7

This commit is contained in:
Olivier Dony 2014-09-08 16:53:11 +02:00
commit d32d120a0a
5 changed files with 22 additions and 19 deletions

View File

@ -97,7 +97,6 @@
<th>Description</th> <th>Description</th>
<th>Reference</th> <th>Reference</th>
<th>Partner</th> <th>Partner</th>
<th>Type</th>
<th>Account</th> <th>Account</th>
<th class="text-right">Amount</th> <th class="text-right">Amount</th>
</tr> </tr>
@ -108,7 +107,6 @@
<td><span t-field="line.name"/></td> <td><span t-field="line.name"/></td>
<td><span t-field="line.ref"/></td> <td><span t-field="line.ref"/></td>
<td><span t-field="line.partner_id"/></td> <td><span t-field="line.partner_id"/></td>
<td><span t-field="line.type"/></td>
<td><span t-field="line.account_id"/></td> <td><span t-field="line.account_id"/></td>
<td class="text-right"> <td class="text-right">
<span t-field="line.amount" <span t-field="line.amount"

View File

@ -260,8 +260,9 @@ class stock_move(osv.osv):
def action_done(self, cr, uid, ids, context=None): def action_done(self, cr, uid, ids, context=None):
self.product_price_update_before_done(cr, uid, ids, context=context) self.product_price_update_before_done(cr, uid, ids, context=context)
super(stock_move, self).action_done(cr, uid, ids, context=context) res = super(stock_move, self).action_done(cr, uid, ids, context=context)
self.product_price_update_after_done(cr, uid, ids, context=context) self.product_price_update_after_done(cr, uid, ids, context=context)
return res
def _store_average_cost_price(self, cr, uid, move, context=None): def _store_average_cost_price(self, cr, uid, move, context=None):
''' move is a browe record ''' ''' move is a browe record '''

View File

@ -78,10 +78,14 @@ class ir_http(orm.AbstractModel):
request.session['geoip'] = record request.session['geoip'] = record
if request.website_enabled: if request.website_enabled:
if func: try:
self._authenticate(func.routing['auth']) if func:
else: self._authenticate(func.routing['auth'])
self._auth_method_public() else:
self._auth_method_public()
except Exception as e:
return self._handle_exception(e)
request.redirect = lambda url, code=302: werkzeug.utils.redirect(url_for(url), code) request.redirect = lambda url, code=302: werkzeug.utils.redirect(url_for(url), code)
request.website = request.registry['website'].get_current_website(request.cr, request.uid, context=request.context) request.website = request.registry['website'].get_current_website(request.cr, request.uid, context=request.context)
langs = [lg[0] for lg in request.website.get_languages()] langs = [lg[0] for lg in request.website.get_languages()]

View File

@ -63,12 +63,6 @@ class ir_http(osv.AbstractModel):
def _auth_method_user(self): def _auth_method_user(self):
request.uid = request.session.uid request.uid = request.session.uid
if not request.uid: if not request.uid:
if not request.params.get('noredirect'):
query = werkzeug.urls.url_encode({
'redirect': request.httprequest.url,
})
response = werkzeug.utils.redirect('/web/login?%s' % query)
werkzeug.exceptions.abort(response)
raise http.SessionExpiredException("Session expired") raise http.SessionExpiredException("Session expired")
def _auth_method_none(self): def _auth_method_none(self):
@ -102,7 +96,10 @@ class ir_http(osv.AbstractModel):
def _handle_exception(self, exception): def _handle_exception(self, exception):
# If handle_exception returns something different than None, it will be used as a response # If handle_exception returns something different than None, it will be used as a response
return request._handle_exception(exception) try:
return request._handle_exception(exception)
except openerp.exceptions.AccessDenied:
return werkzeug.exceptions.Forbidden()
def _dispatch(self): def _dispatch(self):
# locate the controller method # locate the controller method
@ -115,11 +112,8 @@ class ir_http(osv.AbstractModel):
# check authentication level # check authentication level
try: try:
auth_method = self._authenticate(func.routing["auth"]) auth_method = self._authenticate(func.routing["auth"])
except Exception: except Exception as e:
# force a Forbidden exception with the original traceback return self._handle_exception(e)
return self._handle_exception(
convert_exception_to(
werkzeug.exceptions.Forbidden))
processing = self._postprocess_args(arguments, rule) processing = self._postprocess_args(arguments, rule)
if processing: if processing:

View File

@ -590,6 +590,12 @@ class HttpRequest(WebRequest):
be used as response.""" be used as response."""
try: try:
return super(HttpRequest, self)._handle_exception(exception) return super(HttpRequest, self)._handle_exception(exception)
except SessionExpiredException:
if not request.params.get('noredirect'):
query = werkzeug.urls.url_encode({
'redirect': request.httprequest.url,
})
return werkzeug.utils.redirect('/web/login?%s' % query)
except werkzeug.exceptions.HTTPException, e: except werkzeug.exceptions.HTTPException, e:
return e return e