Yes, Odoo allows creation of custom field type. Conceptually, you will need to do the steps below:
- Implement a subclass of Odoo AbstractField in your javascript.
odoo.define('my_module.fields', function(require) {
"use strict"
var registry = require('web.field_registry');
var AbstractField = require('web.AbstractField');
var CustomField = AbstractField.extend({
/**
* @override
*/
_renderReadonly: function () {
//...
}
});
// add the custom widget to Odoo's widget registry
registry.add('my_custom_field', CustomField);
})
You may not need to extend AbstractField directly since there are already a number of built-in field widgets that can be closer to your need. I suggest that you get Odoo's source code and look through different field widget implementation under addons/web/static/src/js/fields/basic_fields.js
to find what best suits your need. And then extend from there.
- Let Odoo knows that it should use the custom widget in the xml
<field name="content" widget="my_custom_field" />
You can look for more information in this example blog post I found.