From 818ff8c406717ecaa81596775c43242f0cb593cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deiber=20Rinc=C3=B3n?= Date: Wed, 3 Apr 2019 00:14:41 +0000 Subject: [PATCH] [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) --- addons/point_of_sale/static/src/js/models.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 93a024a940c..37fd3621ce2 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -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',