[FIX] point_of_sale: repair cashier from localStorage on refresh page
open a pos, change cashier hit F5 Before this commit, the previous user was set as cashier, forgetting about the change we made This was because of two things: - The original fix to do just this use case was pushed in v9.0 ase14ab69772- In v11.0 the commitf5f60599bfintroduced full usage of Backbone's set and get which meant that self.cashier was no longer relevant - In v10.0 the commit475027b988(For v11.0:a9caef0ebb) Was intended to update the res.users objects at their loading to ensure that their access rights were loaded too But it did this using the wrong condition After this commit, it reworks fine OPW1844006closes #24762
This commit is contained in:
@@ -259,6 +259,7 @@ exports.PosModel = Backbone.Model.extend({
|
||||
// we attribute a role to the user, 'cashier' or 'manager', depending
|
||||
// on the group the user belongs.
|
||||
var pos_users = [];
|
||||
var current_cashier = self.get_cashier();
|
||||
for (var i = 0; i < users.length; i++) {
|
||||
var user = users[i];
|
||||
for (var j = 0; j < user.groups_id.length; j++) {
|
||||
@@ -276,6 +277,8 @@ exports.PosModel = Backbone.Model.extend({
|
||||
// replace the current user with its updated version
|
||||
if (user.id === self.user.id) {
|
||||
self.user = user;
|
||||
}
|
||||
if (user.id === current_cashier.id) {
|
||||
self.set_cashier(user);
|
||||
}
|
||||
}
|
||||
@@ -629,7 +632,7 @@ exports.PosModel = Backbone.Model.extend({
|
||||
// changes the current cashier
|
||||
set_cashier: function(user){
|
||||
this.set('cashier', user);
|
||||
this.db.set_cashier(this.cashier);
|
||||
this.db.set_cashier(this.get('cashier'));
|
||||
},
|
||||
//creates a new empty order and sets it as the current order
|
||||
add_new_order: function(){
|
||||
|
||||
Reference in New Issue
Block a user