From 9f4c66107ed9dc1c475c50cb16eccd6c079d5bc5 Mon Sep 17 00:00:00 2001 From: "Nicolas (vin)" Date: Wed, 16 Mar 2022 08:40:50 +0000 Subject: [PATCH] [IMP] account: allow trying to upload the same file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since https://github.com/odoo/odoo/commit/cb6c6224be4eaa80091f51f957059de889332e68 we are now raising possible errors when uploading an invoice. In 14.0+ we are allowing via a redirect warning to change the status of the currency without changing the page but the upload only starts when you change the uploaded file. So the following flow does not work: - Try to upload a bill with MXN currency - With MXN being inactive, it raises an error. Using the redirect warning action we activate the currency, clos the modale window and try to upload again. - The upload won't work until we refresh the page, because the value of the input file does not change (or we need to select another one, then the first one again) This change reset the file input if there is an error raised during the upload allowing to select the same file more than once without reloading. closes odoo/odoo#86539 X-original-commit: 4bfc75075217adc32de8df008128bbaa8c6c158d Signed-off-by: William André (wan) --- addons/account/static/src/js/bills_upload.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/account/static/src/js/bills_upload.js b/addons/account/static/src/js/bills_upload.js index 2e0e254e4ff..2a325760781 100644 --- a/addons/account/static/src/js/bills_upload.js +++ b/addons/account/static/src/js/bills_upload.js @@ -41,6 +41,9 @@ odoo.define('account.upload.bill.mixin', function (require) { context: this.initialState.context, }).then(function(result) { self.do_action(result); + }).catch(function () { + // Reset the file input, allowing to select again the same file if needed + self.$('.o_vendor_bill_upload .o_input_file').val(''); }); },