Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2759 Переглядів

Hello,


i'm looking for something since many weeks but impossible to find the solution;


For example, in the sale.order.line view :


if i'm doing a ctrl+v in a field and save the line, the value pasted is saved; ok no problem


if i use javascript code to recover clipboard content and display this content in the field, the value is displayed but when i save the line, the value is not saved!!!


Do you know how to indicate to Odoo that the field is modified therefore that it must save it?

Is there a flag or something to change or something else?

Why Odoo detect modification when you fill it manually or paste with CTRL+V but not when you add value vith js code?

Аватар
Відмінити

Hello JJB,

Just to clarify when you say JS code is this using the Javascript Module System or are you doing it in plane JS, JQuery for example?

Thanks,

Автор

Hi Jack Dane,

Thank you for your answer

Sorry i could not answer directly in your comment!!!

Here is my js code in statis/js/clipboard.js

odoo.define('safar_module.Recupclipboard', function(require) {

"use strict";

var Widget = require('web.Widget');

var registry = require('web.widget_registry');

var core = require('web.core');

var QWeb = core.qweb;

var PasteConfig = Widget.extend({

init: function (parent, params) {

this._super.apply(this, arguments);

this.id = params.res_id

},

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;

document.getElementsByName("s_configuration")[0].value = clipText;

this._rpc({

model: 'sale.order.line',

method: 'paste_config',

args: [[this.id], clipText],

})

.then(function (p) {

console.log(p)

})

});

},

})

registry.add('paste-config', PasteConfig);

return PasteConfig;

});

And python code :

def paste_config(self, config):

self.s_configuration = config

return self.s_configuration

These code works when the sale.order.line is created at first and when i refresh after. But i would like it works without created sale.order.line first and withou refresh in order to be more ergonomic.

I just want to indicate Odoo that the field is modified and so, it must save its value

Thanks