Skip to content

Commit

Permalink
[FIX] pos_loyalty: underterministic error
Browse files Browse the repository at this point in the history
An indeterministic error was present in the pos_loyalty module. This was
due to the fact that when the user changed the partner a request to
retrieve the loyaltyCards already existing for this partner was made by
a different series of function calls.

In fine, the call was not awaited, so when another method wanted to
retrieve the loyaltyCards for the same partner, a new card was created
and then overridden to null by the result of the call to the server.

To correct this error, the call to the server to retrieve the cards
is made when the partner is changed. At this point the request is
awaited.

Runbot Error: 57047

closes odoo#171226

Signed-off-by: Adrien Guilliams (adgu) <[email protected]>
  • Loading branch information
davidmonnom committed Jul 2, 2024
1 parent d61c950 commit 7aa0ebe
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion addons/pos_loyalty/static/src/overrides/models/loyalty.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ patch(Order.prototype, {
*/
async _couponForProgram(program) {
if (program.is_nominative) {
return this.pos.fetchLoyaltyCard(program.id, this.get_partner().id);
return await this.pos.fetchLoyaltyCard(program.id, this.get_partner().id);
}
// This type of coupons don't need to really exist up until validating the order, so no need to cache
return new PosLoyaltyCard(null, null, program.id, (this.get_partner() || { id: -1 }).id, 0);
Expand Down

0 comments on commit 7aa0ebe

Please sign in to comment.