Skip to content Skip to sidebar Skip to footer

Add Another Element To Models List [odoo-8] Pos Javascript

in pos javascript there this code: module.PosModel = Backbone.Model.extend({ ..... ..... models: [ { model: 'res.users',

Solution 1:

The good thing that we have access to all attribute in initialize method:

    // in needed to save prototype here
    // so it will not cause a recursive loop
    var _super = module.PosModel.prototype;
    module.PosModel = module.PosModel.extend({
     initialize: function (session, attributes) {
        // call super to set all properties
        _super.initialize.apply(this, arguments);
        // here i can access the models list like this and add an element.
        this.models.push({
        // load allowed users
            model:  'res.users',
            fields: ['name'],
            domain: function(self){ return [['id','in',self.config.user_ids]]; },
            loaded: function(self,users){
                console.log(users);
                self.allowed_users = users;
            },
        })
        return this;
     },

    });

Post a Comment for "Add Another Element To Models List [odoo-8] Pos Javascript"