Hello, I need some help with a custom plugin for Odoo 16.
I want to create a feature that when I drag a card to a certain column in kanban, it will show a confirmation window and if I agree, it will move the card to the desired column and open a new form from another custom plugin with filled fields that match the fields of the card in kanban.
The main problem is that I don’t understand how to properly extend the setup in the extended component and get and pass the data to the new form (as I understand, the standard approach is to use default_)
My current code is something like this:
** @odoo-module **/
import { KanbanDynamicGroupList, KanbanModel } from “@web/views/kanban/kanban_model”;
export class LeadKanbanModel extends KanbanModel {}
class LeadKanbanDynamicGroupList extends KanbanDynamicGroupList {
/**
* @param {string} dataRecordId
* @param {string} dataGroupId
* @param {string} refId
* @param {string} targetGroupId
*/
async moveRecord(dataRecordId, dataGroupId, refId, targetGroupId) {
const targetGroup = this.groups.find((g) => g.id === targetGroupId);
const sourceGroup = this.groups.find((g) => g.id === dataGroupId);
if (!sourceGroup || !targetGroup) {
return; // Groups have been re-rendered, old ids are ignored
}
if (targetGroup.displayName == "Завершён") {
const record = sourceGroup.list.records.find((r) => r.id === dataRecordId);
if (!record) return;
let that = this;
const superMoveRecord = super.moveRecord.bind(this);
var Dialog = require('web.Dialog');
var myDialog = new Dialog(this, {
title: 'Do you want to complete the lead?',
size: 'medium',
$content: $('').css({
display: 'flex',
alignItems: 'center',
flexWrap: 'nowrap',
})
.append($('').text('Close the lead and open the work order')).css({ whiteSpace: 'nowrap' }),
buttons: [
{text: 'Yes', classes: 'btn-primary', close: true, click: function() {
// here
superMoveRecord(dataRecordId, dataGroupId, refId, targetGroupId);
},
{text: 'No', classes: 'btn-primary', close: true, click: () => {
}}
]
});
myDialog.open();
return true;
} return await super.moveRecord(dataRecordId, dataGroupId, refId, targetGroupId);
}
}
LeadKanbanModel.DynamicGroupList = LeadKanbanDynamicGroupList;