From c99eb1b8fb48eef80300aae90c08b54d28e093a7 Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Tue, 14 Aug 2018 14:55:51 +0200 Subject: [ADD] account: import vendor bills files from dashboard This adds a button to import several bills from the accounting dashboard: will create a new vendor bill for each, with the file attached to it. That file will be visible in the chatter (in enterprise) and allow easilly completion/encoding of it. This task also comes along with the import/export of xml files attached to the PDF files created from the invoice report. Was task 1859277 Was PR #26339 --- addons/web/static/src/js/fields/relational_fields.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js/fields/relational_fields.js') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index b8eb106caab..692d27e0ca8 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -1475,6 +1475,7 @@ var FieldMany2Many = FieldX2Many.extend({ */ var FieldMany2ManyBinaryMultiFiles = AbstractField.extend({ template: "FieldBinaryFileUploader", + template_files: "FieldBinaryFileUploader.files", supportedFieldTypes: ['many2many'], fieldsToFetch: { name: {type: 'char'}, @@ -1549,7 +1550,7 @@ var FieldMany2ManyBinaryMultiFiles = AbstractField.extend({ // _setValue, we put the rendering here to ensure they will be updated this._generatedMetadata(); this.$('.oe_placeholder_files, .oe_attachments') - .replaceWith($(qweb.render('FieldBinaryFileUploader.files', { + .replaceWith($(qweb.render(this.template_files, { widget: this, }))); this.$('.oe_fileupload').show(); @@ -1611,6 +1612,10 @@ var FieldMany2ManyBinaryMultiFiles = AbstractField.extend({ var files = ev.target.files; var attachment_ids = this.value.res_ids; + // Don't create an attachment if the upload window is cancelled. + if(files.length == 0) + return; + _.each(files, function (file) { var record = _.find(self.value.data, function (attachment) { return attachment.data.name === file.name; -- cgit v1.2.3