Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
2816 Zobrazení

Hello all ,
How can i filter customer in POS if i add boolean field like is_pos in res.partner model
I want to show only customer have TRUE in  field is_pos in point of sale customers

Avatar
Zrušit
Autor

that is work for me:-

odoo.define('pos_show_customer.models', function(require) {
var PosDB = require('point_of_sale.DB');
var PosModel = require('point_of_sale.models');
models.load_fields('res.partner','is_pos');
var models = require('point_of_sale.models');

models.load_models([
{
model: 'res.partner',
condition: function(self) {
return true;
},
fields: ['is_pos'],
domain: function(self) {
return [['is_pos', '=', true]];
},
loaded: function(self, result) {
if (result.length) {
console.log("LLLLLLLLLLLLLLLLLOad")
}
},
}
], {
'after': 'res.partner'
});

PosDB.include({
add_partners: function (partners) {
var filteredPartners = _.filter(partners, function (partner) {
return partner.is_pos === true;
});
this._super(filteredPartners);
},
});

PosModel.load_new_partners = function () {
var self = this;
if (!self.config.iface_preload) {
return self._super();
}
var fields = _.find(self.models, function (model) {
return model.model === 'res.partner';
}).fields;
var domain = [['is_pos', '=', true]];
var params = {
model: 'res.partner',
method: 'search_read',
args: [domain, fields],
};
return self._load_data(params).then(function (partners) {
self.db.add_partners(partners);
});
};
});

Nejlepší odpověď

Hi,

Using this code you can load the customer when the is_pos field is True

var models = require('point_of_sale.models');
var PosDB = require('point_of_sale.DB');
var PosModel = require('point_of_sale.models');
 
PosDB.include({
add_partners: function (partners) {
var filteredPartners = _.filter(partners, function (partner) {
return partner.is_pos === true;
});
this._super(filteredPartners);
},
});

PosModel.load_new_partners = function () {
var self = this;
if (!self.config.iface_preload) {
return self._super();
}
var fields = _.find(self.models, function (model) {
return model.model === 'res.partner';
}).fields;
var domain = [['is_pos', '=', true]];
var params = {
model: 'res.partner',
method: 'search_read',
args: [domain, fields],
};
return self._load_data(params).then(function (partners) {
self.db.add_partners(partners);
});
};

Regards

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
bře 24
4037
0
lis 24
2440
0
lis 23
2345
0
úno 25
2846
0
pro 24
2400