We’ll add a JavaScript file that contains our widget’s logic, and a CSS file to do some styling. Then, we also choose one field on the partner form to use our new widget. Follow the given steps:
- Add a static/src/js/r1_widgets.js file. For the syntax used here, refer to the Extending CSS and JavaScript for the website recipe from Chapter 16, CMS Website Development:
odoo.define('r1_widgets', function(require) { var registry = require('web.field_registry'), AbstractField = require('web.AbstractField');
- Create your widget by subclassing AbstractField:
var FieldMany2OneButtons = AbstractField.extend({
- Set the CSS class for the widget’s root div element:
className: 'oe_form_field_many2one_buttons',
- Override init to do ...