Hello,
I wrote some javascript code to grab the contents of the clipboard and place it in a field of my form.
Everything works fine, except that when I save my form, the pasted value is not saved.
I manually modify this field (adding a blank) so that its value is saved!
Do you know what to do to tell the server to save the contents of this field?
I hope that someone could help me
My JS code :
odoo.define('my_module.Recupclipboard', function(require) {
"use strict";
var Widget = require('web.Widget');
var registry = require('web.widget_registry');
var Model = require('web.Model');
var core = require('web.core');
var QWeb = core.qweb;
var PasteConfig = Widget.extend({
start: function () {
this.$widget = $(QWeb.render('copy_btn_template'));
this.$copyLink = this.$widget.find('.copy_btn');
this.$widget.appendTo(this.$el);
this.$copyLink.click(this.coller_config.bind(this));
},
coller_config: function () {
navigator.clipboard.readText()
.then(clipText => {
const el = document.activeElement;
console.log(clipText)
document.getElementsByName("s_configuration")[0].val(clipText).change().focus();
})
},
})
registry.add('paste-config', PasteConfig);
return PasteConfig;
});