[MERGE] forward port of branch 7.0 up to c435b84

This commit is contained in:
Christophe Simonis 2015-05-18 17:13:18 +02:00
commit 0f5b6cf60b
2 changed files with 5 additions and 4 deletions

View File

@ -941,7 +941,7 @@ class purchase_order_line(osv.osv):
def unlink(self, cr, uid, ids, context=None):
procurement_ids_to_cancel = []
for line in self.browse(cr, uid, ids, context=context):
if line.state not in ['draft', 'cancel']:
if line.order_id.state in ['approved', 'done'] and line.state not in ['draft', 'cancel']:
raise osv.except_osv(_('Invalid Action!'), _('Cannot delete a purchase order line which is in state \'%s\'.') %(line.state,))
if line.move_dest_id:
procurement_ids_to_cancel.extend(procurement.id for procurement in line.move_dest_id.procurements)

View File

@ -31,6 +31,7 @@ except ImportError:
import openerp
import openerp.modules.registry
from openerp.tools.translate import _
from openerp.tools import ustr
from openerp import http
from openerp.http import request, serialize_exception as _serialize_exception, LazyResponse
@ -567,14 +568,14 @@ def xml2json_from_elementtree(el, preserve_whitespaces=False):
return res
def content_disposition(filename):
filename = filename.encode('utf8')
escaped = urllib2.quote(filename)
filename = ustr(filename)
escaped = urllib2.quote(filename.encode('utf8'))
browser = request.httprequest.user_agent.browser
version = int((request.httprequest.user_agent.version or '0').split('.')[0])
if browser == 'msie' and version < 9:
return "attachment; filename=%s" % escaped
elif browser == 'safari':
return "attachment; filename=\"%s\"" % filename
return u"attachment; filename=%s" % filename
else:
return "attachment; filename*=UTF-8''%s" % escaped