From acd61f8f0efe0c1da2a0640ec65bfc48d6714645 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 13 May 2015 11:36:04 +0200 Subject: [PATCH 1/2] [FIX] purchase: deletion of PO lines in states other than approved/done This is related to revision 65d7cc524d9f3a5dc833cb483ccaaf86fab4819d The `order_line` field of `purchase.order` is readonly within states aprroved, done. See the field definition. This means it should be possible to remove lines of a `purchase.order` when the PO is in any other state than approved or done. Therefore, the deletion of lines shouldn't be prevented when the PO is not in state approved or done opw-634538 --- addons/purchase/purchase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 7c327139a2d..98365546c60 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -934,7 +934,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) From c435b8438eb17dfc1b3807974b4e906a54ffed0e Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 13 May 2015 11:20:41 +0200 Subject: [PATCH 2/2] [FIX] web: With safari, UnicodeDecodeError The headers returned by content_disposition must be either in Unicode or in ASCII. The encode function expects a Unicode or ASCII string. The quote function from urllib2 expects a UTF-8 string and retruns a ASCII string. opw:634205 Fixes #6160, #6557 --- addons/web/controllers/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 7d3862c3091..5270cad731d 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -32,7 +32,7 @@ except ImportError: import openerp import openerp.modules.registry from openerp.tools.translate import _ -from openerp.tools import config +from openerp.tools import config, ustr from .. import http openerpweb = http @@ -520,14 +520,14 @@ def xml2json_from_elementtree(el, preserve_whitespaces=False): return res def content_disposition(filename, req): - filename = filename.encode('utf8') - escaped = urllib2.quote(filename) + filename = ustr(filename) + escaped = urllib2.quote(filename.encode('utf8')) browser = req.httprequest.user_agent.browser version = int((req.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