[FIX] point_of_sale: new session should open with user as cashier
Open a new session with user A, the cashier is A. Close the session and post the entries. The responsible for the session is user A and the salesman on the sale order is A. Then log in to the database with user B. Open a new session on the same pos. Before this commit, the cashier on the second session was A After this commit, the cashier on the second session is B OPW 1864207 closes #25628
This commit is contained in:
@@ -221,7 +221,7 @@ exports.PosModel = Backbone.Model.extend({
|
||||
fields: ['id', 'journal_ids','name','user_id','config_id','start_at','stop_at','sequence_number','login_number'],
|
||||
domain: function(self){ return [['state','=','opened'],['user_id','=',session.uid]]; },
|
||||
loaded: function(self,pos_sessions){
|
||||
self.pos_session = pos_sessions[0];
|
||||
self.pos_session = pos_sessions[0];
|
||||
},
|
||||
},{
|
||||
model: 'pos.config',
|
||||
@@ -241,6 +241,8 @@ exports.PosModel = Backbone.Model.extend({
|
||||
|
||||
self.db.set_uuid(self.config.uuid);
|
||||
self.cashier = self.get_cashier();
|
||||
// We need to do it here, since only then the local storage has the correct uuid
|
||||
self.db.save('pos_session_id', self.pos_session.id);
|
||||
|
||||
var orders = self.db.get_orders();
|
||||
for (var i = 0; i < orders.length; i++) {
|
||||
@@ -577,6 +579,10 @@ exports.PosModel = Backbone.Model.extend({
|
||||
|
||||
// returns the user who is currently the cashier for this point of sale
|
||||
get_cashier: function(){
|
||||
// reset the cashier to the current user if session is new
|
||||
if (this.db.load('pos_session_id') !== this.pos_session.id) {
|
||||
this.set_cashier(this.user);
|
||||
}
|
||||
return this.db.get_cashier() || this.cashier || this.user;
|
||||
},
|
||||
// changes the current cashier
|
||||
|
||||
Reference in New Issue
Block a user