Hello,
Create a javascript module like below for your custom field
Create a qweb template for the custom field
You can access all fields on the form like shown below.
Then you can pass the value to the template
Finally add the field to the form like <widget type="customwidget"/>
The Script
odoo.define('module.module_title', function (require) {
"use strict";
var core = require('web.core');
var common = require('web.form_common');
var CustomWidget = common.FormWidget.extend({
template: 'CustomWidget',
events: {
},
start: function() {
var self=this;
// You can get the values of all fields on the form like this
var field_value=self.field_manager.get_field_value('field_name');
self.color_class=field_value;
this._super();
},
})
core.form_custom_registry.add('customwidget', CustomWidget);
return {
CustomWidget:CustomWidget,
};
});
The Template
<t t-name="CustomWidget">
<td t-att-style="" t-att-class="widget.color_class">Some Thig</td>
</t>
To display the widget on the form view
<widget type="customwidget"/>
Thank You