Skip to Content
Menu
This question has been flagged

Hi,

I have this code running on odoo 10 and I want to change it to odoo 11. 

odoo.define('dynamic_column_listview.SearchView', function (require) {
"use strict";
var Model = require('web.DataModel');
var core = require('web.core');
var SearchView = require('web.SearchView');
var FavoriteMenu = require('web.FavoriteMenu');
var FilterMenu = require('web.FilterMenu');
var GroupByMenu = require('web.GroupByMenu');
var DynamicColumnMenu = require('web.DynamicColumnMenu');
var QWeb = core.qweb;
var SearchView = core.form_custom_registry.get('SearchView');
SearchView.include({
    defaults: _.extend({}, SearchView.prototype.defaults, {
       disable_dynamic_column_listview: false
    }),
    init: function() {
        this._super.apply(this, arguments);
        this.dynamic_column_menu = undefined;
    },
    start: function () {
        return $.when(this._super.apply(this, arguments)).then(this.proxy('show_dynamic_columns_menu'));
    },
    show_dynamic_columns_menu: function() {
        var menu_defs = []
        if (this.$buttons && !this.options.disable_dynamic_column_listview) {
            this.dynamic_column_menu = new DynamicColumnMenu(this);
            menu_defs.push(this.dynamic_column_menu.appendTo(this.$buttons));
        }
        return $.when.apply($, menu_defs);
    }
});
return SearchView;
});

When I run it it appears this js error:
`missing dependencies array (1) web.DataModel`

Avatar
Discard
Best Answer

Web.DataModel is deprecated in odoo 11. so you can use RPC queries instead .

var rpc = require('web.rpc')

rpc.query(

     model: //your model,

     method: //your method,

      args: [{

          'arg1': value1,

      }]

 }).then(function (result) { 

            // your code 

  });

Avatar
Discard
Author

How can I implement this in my code? Can you explain please?

just remove the var Model = require('web.DataModel'); and use rpc calls instead of using model.call()

Related Posts Replies Views Activity
0
Oct 18
1541
1
May 21
2239
0
May 21
1913
2
May 20
8531
1
Jan 20
4028