Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
8054 มุมมอง

I have tried to bring multi selection for one2many field in the form view, Version 12.0. But didn't find any helpful thread. And later i have tried with a custom module for the same purpose which was in version 10.0. I have made a few changes in the js file and after installing it. I can find that everything else in that module works fine but not the multi selection checkbox.

odoo.define('web_one2many_selectable_10.form_widgets', function (require) {

"use strict";

var core = require('web.core');

console.log(core)
var _t = core._t;
var QWeb = core.qweb;
var field_registry = require('web.field_registry');

var FieldOne2Many = field_registry.get('one2many');


var One2ManySelectable = FieldOne2Many.extend({

template: 'One2ManySelectable',
multi_selection: true,
supportedFieldTypes: ['one2many'],

events: {
"click .cf_button_confirm": "action_selected_lines",
},
start: function()
{
this._super.apply(this, arguments);
var self=this;
},

action_selected_lines: function()
{
var self=this;
var selected_ids = self.get_selected_ids_one2many();
if (selected_ids.length === 0)
{
this.do_warn(_t("You must choose at least one record."));
return false;
}
var model_obj=new Model(this.dataset.model);
model_obj.call('bulk_verify',[selected_ids],{context:self.dataset.context})
.then(function(result){
});
},

get_selected_ids_one2many: function ()
{
var ids =[];
this.$el.find('td.o_list_record_selector input:checked')
.closest('tr').each(function () {

ids.push(parseInt($(this).context.dataset.id));
console.log(ids);
});
return ids;
},


});
field_registry.add('one2many_selectable', One2ManySelectable);
});

This is the file in which i have made changes. Is there any way to solve the issue.

Thanks in advance

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

In odoo 13.0 you have to use the flag hasSelectors instead of multi_selection

however you need to apply the following patch, otherwise it won't work: https://github.com/odoo/odoo/pull/33946


checkout this related question: \https://www.odoo.com/fr_FR/forum/aide-1/question/reload-one2many-field-from-widget-odoo13-160709

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
พ.ค. 23
7187
2
เม.ย. 20
9945
1
ก.ค. 16
4038
2
ก.ค. 24
1469
1
มิ.ย. 23
2973