[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
This commit is contained in:
Joren Van Onder
2016-02-18 15:48:16 +01:00
parent d5dfeb9dac
commit 92badf048f
2 changed files with 12 additions and 2 deletions
+1 -1
View File
@@ -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;
+11 -1
View File
@@ -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(){