The idea is simple, I want to show all the data in one2many in an ordered list:
So simple. Should be so easy, but I have wasted 10 hours on it, still without a sign of success 🙁
Here is my js:
odoo.define('obki.accordion_widget', function (require) {
'use strict';
var core = require('web.core');
var AbstractField = require('web.AbstractField');
var field_registry = require('web.field_registry');
var QWeb = core.qweb;
var AccordionWidget = AbstractField.extend({
// The template for the widget
template: 'AccordionWidget',
supportedFieldTypes: ['one2many'],
// Render the widget
_render: function () {
var info = this.value;
console.log('######### info: ', info);
debugger; //it's not even executed
this.$el.text('Accordion Widget Content'); // Display the Accordion name
},
});
// Register the widget
field_registry.add('accordion_widget', AccordionWidget);
// return AccordionWidget;
return {
AccordionWidget: AccordionWidget,
};
});
Here my XML:
<t t-name="AccordionWidget">
<ol>
<t t-foreach="record.tac_ids" t-as="line">
<li>
<div><t t-esc="line.name"/></div>
</li>
</t>
</ol>
</t>
The result is always: “Missing widget: accordion_widget for field of type text”
I have tried to copy another code from another 3rd_party plugin like this:
/** @odoo-module **/
import { registry } from '@web/core/registry';
import { X2ManyField } from '@web/views/fields/x2many/x2many_field';
export class Accordion extends X2ManyField {
}
Accordion.template = 'AccordionWidget';
registry.category('fields').add('accordion_widget', Accordion);
It seems working, the widget is registered and shown on the form. But unfortunately, I don’t know how to access the data. how to read the field_ids data? I have tried this.field_ids, props.field_ids, props.record, props.everything, nothing works.
Help please…. :’)