From 92badf048f4eb343a41ee099c3e2bc7588c00f98 Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Thu, 18 Feb 2016 13:16:14 +0100 Subject: [PATCH] [IMP] point_of_sale: automatically set customer fiscal position This makes it so that when you set a customer in the POS frontend it will automatically apply the fiscal position associated to the customer on the order. If the customer has no set fiscal position or if the fiscal position is not available in the POS nothing will happen. opw-668155 --- addons/point_of_sale/static/src/js/models.js | 2 +- addons/point_of_sale/static/src/js/screens.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 22c3b662867..e74c2611828 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -182,7 +182,7 @@ exports.PosModel = Backbone.Model.extend({ } },{ model: 'res.partner', - fields: ['name','street','city','state_id','country_id','vat','phone','zip','mobile','email','barcode','write_date'], + fields: ['name','street','city','state_id','country_id','vat','phone','zip','mobile','email','barcode','write_date','property_account_position_id'], domain: [['customer','=',true]], loaded: function(self,partners){ self.partners = partners; diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index aad479fa146..71c8ff6105d 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -1070,8 +1070,18 @@ var ClientListScreenWidget = ScreenWidget.extend({ } }, save_changes: function(){ + var self = this; + var order = this.pos.get_order(); if( this.has_client_changed() ){ - this.pos.get_order().set_client(this.new_client); + if ( this.new_client ) { + order.fiscal_position = _.find(this.pos.fiscal_positions, function (fp) { + return fp.id === self.new_client.property_account_position_id[0]; + }); + } else { + order.fiscal_position = undefined; + } + + order.set_client(this.new_client); } }, has_client_changed: function(){