如何在odoo11中选择具有one2many字段的小部件?

时间:2018-06-22 07:38:48

标签: javascript odoo-11

执行以下代码时出现错误:

widget.js

odoo.define('web_one2many_selectable_10.form_widgets', function (require) {
"use strict";

var core = require('web.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({
    // my custom template for unique char field
    template: 'One2ManySelectable', 

    multi_selection: true,
    //button click
    events: {
        "click .cf_button_confirm": "action_selected_lines",
    },
    init: function () {
        console.log("Excuting Inited");
        this._super.apply(this, arguments);

        // boolean used to prevent concurrent record creation
        this.creatingRecord = false;
    },

    start: function() 
    {   
        this._super.apply(this, arguments);
        var self=this;          
       },
    //passing ids to function
    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){
        });
    },
    //collecting the selected IDS from one2manay list
    get_selected_ids_one2many: function ()
    {
        var ids =[];
        debugger
        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;
    },


});
// register unique widget, because Odoo does not know anything about it
//you can use <field name="One2many_ids" widget="x2many_selectable"> for call this widget
core.form_widget_registry.add('one2many_selectable', One2ManySelectable);
});

样式错误

样式编译失败,请参见以下错误。您最近的操作可能是原因,请尝试还原所做的更改。

  

无法获取捆绑包'web.assets_backend'中定义的/helpdesk/static/src/less/helpdesk.less的内容。

以及控制台中的此错误:

  

缺少小部件:one2many_selectable用于类型one2many的字段result_line

我想使用odoo 11中的小部件通过复选框选择 one2many 。 谁能帮我解决这个问题?

0 个答案:

没有答案