Hello, I made this JS to add a functionality on a form (backend) that computes a field when the event click is triggered. So far the code recomputes when I use .include but the whole js in all views fails since I'm using .include. When i try to use extend, looks like Odoo doesn't add the extended code to the js engine so my question is, what am I doing wrong here? Is there something else i need to add so my code as extended works?
PD. Somehow I can't add tags to this question
odoo.define('med_care.TestRenderer', function (require) {
"use strict";
var viewRegistry = require('web.view_registry');
var FormRenderer = require('web.FormRenderer');
var FormView = require('web.FormView');
var TestFormRenderer = FormRenderer.extend({
events: _.extend({}, FormRenderer.prototype.events, {
'click .selector_simbolo': '_onSelectorSimboloClicked',
}),
init: function (parent, state, params) {
this._super.apply(this, arguments);
this.fields = state.fields;
this._onSelectorSimboloClicked = _.debounce(this._onSelectorSimboloClicked, 300, true);
},
confirmChange: function (state, id, fields, e) {
var self = this;
if (state.model == 'med.test') {
return this._super.apply(this, arguments).then(function () {
self.canBeSaved(self.state.id);
});
}
},
_onSelectorSimboloClicked: function (event) {
this.state.data.telefono = '333';
if (this.state.model == 'med.test') {
var info_test = {
dataPointID: this.state.id,
changes: {telefono: '333'},
viewType: "form",
notifyChange: true
};
var odoo_event = this.trigger_up('field_changed', info_test);
this.confirmChange(this.state, this.state.id, "telefono",
odoo_event)
}
},
});
var TestFormView = FormView.extend({
config: _.extend({}, FormView.prototype.config, {
Renderer: TestFormRenderer,
}),
});
viewRegistry.add('test_form', TestFormView);
return TestFormView;
});