[IMP] point_of_sale: use more unique identifier

When custom modules load a different partner field set for a completely
unrelated purpose AND this loading takes place prior to the stock odoo
one, then the load_new_partners method will infer the wrong field set
as the first in row hit is returned by _.find.

It is not optimal code quality to use `res.partner` as if it was a
unique identifier, while not inhibiting multiple loads of on a single
model.

Adding a (more) unique label and refer it in the find solves this
problem and makes the code more robust.

closes odoo/odoo#32351

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
This commit is contained in:
Deiber Rincón
2019-05-28 09:54:56 +00:00
committed by Martin Trigaux
parent 9bd647ac88
commit 818ff8c406
+2 -1
View File
@@ -207,6 +207,7 @@ exports.PosModel = Backbone.Model.extend({
}
},{
model: 'res.partner',
label: 'load_partners',
fields: ['name','street','city','state_id','country_id','vat',
'phone','zip','mobile','email','barcode','write_date',
'property_account_position_id','property_product_pricelist'],
@@ -594,7 +595,7 @@ exports.PosModel = Backbone.Model.extend({
load_new_partners: function(){
var self = this;
return new Promise(function (resolve, reject) {
var fields = _.find(self.models, function(model){ return model.model === 'res.partner'; }).fields;
var fields = _.find(self.models, function(model){ return model.label === 'load_partners'; }).fields;
var domain = [['customer','=',true],['write_date','>',self.db.get_partner_write_date()]];
rpc.query({
model: 'res.partner',