From 33b59fd616acf3a0998e374d94de06e128537e19 Mon Sep 17 00:00:00 2001 From: Eleftherios Kritsotakis Date: Mon, 25 Apr 2022 09:25:46 +0000 Subject: [PATCH] [IMP] point_of_sale: automatically refresh amount due Before, when the amount due of a customer changed, the user had to press the "rotating arrows" icon at the client list screen in order for the the updated quantity to be displayed properly. This icon was confusing for the user and was burdening the UI with not frequently used behaviour. Instead, in this commit, we incorporate the `refreshTotalDue` logic in the payment workflow so that it is updated automatically when the total due of a client changes. task-2669747 Part-of: odoo/odoo#81226 --- addons/point_of_sale/static/src/js/models.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 1fe7ad90e17..ea264e44832 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -980,6 +980,16 @@ class PosGlobalState extends PosModel { }); this._loadProductProduct(product); } + async refreshTotalDueOfPartner(partner) { + const partnerWithUpdatedTotalDue = await this.env.services.rpc({ + model: 'res.partner', + method: 'search_read', + fields: ['total_due'], + domain: [['id', '=', partner.id]], + }); + this.db.update_partners(partnerWithUpdatedTotalDue); + return partnerWithUpdatedTotalDue; + } } PosGlobalState.prototype.electronic_payment_interfaces = {}; Registries.Model.add(PosGlobalState);