From 3107746e4e971b8119d40d4af09a78fd9e92b5da Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Thu, 30 Apr 2026 17:10:20 +0200 Subject: [PATCH] =?UTF-8?q?[IMP]=20pos=5Fpayment=5Fdescription:=20simplify?= =?UTF-8?q?=20description=20computation=20+=20only=20write=20a=20single=20?= =?UTF-8?q?line,=20if=20there=20is=20multiple=20payment=20with=20the=20sam?= =?UTF-8?q?e=20payment.=20Ex=20:=20before=20:=20cash=20+50=20-10=20>=20'Ca?= =?UTF-8?q?sh=20:=2050=E2=82=AC=20/=20Cash=20-10=E2=82=AC'.=20Now=20:=20'C?= =?UTF-8?q?ash=20:=2040=E2=82=AC'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pos_payment_description/models/pos_order.py | 31 ++++++++------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/pos_payment_description/models/pos_order.py b/pos_payment_description/models/pos_order.py index 6fb9a20e1c..80ccf9c6ba 100644 --- a/pos_payment_description/models/pos_order.py +++ b/pos_payment_description/models/pos_order.py @@ -19,28 +19,21 @@ class PosOrder(models.Model): def _compute_payment_description(self): for order in self: details = [] - for payment in order.payment_ids.filtered( - lambda x: x.payment_method_id.journal_id - ): - details.append( - "%s: %s" - % ( - payment.payment_method_id.journal_id.code, - formatLang( - self.env, payment.amount, currency_obj=payment.currency_id - ), - ) - ) - for payment in order.payment_ids.filtered( - lambda x: not x.payment_method_id.journal_id - ): + payment_dict = {} + for payment in order.payment_ids: + key = (payment.payment_method_id, payment.currency_id) + if key not in payment_dict: + payment_dict[key] = payment.amount + else: + payment_dict[key] += payment.amount + + for (payment_method, currency), amount in payment_dict.items(): details.append( "%s: %s" % ( - payment.payment_method_id.name, - formatLang( - self.env, payment.amount, currency_obj=payment.currency_id - ), + payment_method.name, + formatLang(self.env, amount, currency_obj=currency), ) ) + order.payment_description = " - ".join(sorted(details))