This question has been flagged

The module from github.com/leblanc-simon/odoo-attachment-dragdrop works great for attachments.

I cannot make it work for a binary type field though. It shouldn't be very different.

the module just includes a js file having ondrop function:

ondrop: function (event) {
             var form_upload = document.querySelector(internal.form_selector);

             if (null === form_upload) {
                 return;
             }

             var form_data = new FormData(form_upload);
             for (var iterator = 0, file; file = event.dataTransfer.files[iterator]; iterator++) {
                 form_data.set('ufile', file);
                 $.ajax({
                     url: form_upload.getAttribute('action'),
                     method: form_upload.getAttribute('method'),
                     type: form_upload.getAttribute('method'),
                     processData: false,
                     contentType: false,
                     data: form_data,
                     success: function (data) {
                         $('body').append(data);
                     },
                     error: function (jqXHR, textStatus, errorThrown) {
                         console.error(jqXHR, textStatus, errorThrown);
                     }
                 });
             }
        }


The internal.form_selector is  '.o_sidebar_add_attachment form.o_form_binary_form', which I changed to '.o_form_field_binary_file form.o_form_binary_form' to mach a binary field form but no success. No errors.  The logs only report: "POST /web/binary/upload HTTP/1.1" 200 -

Avatar
Discard