From 57b8d11d229c70c734da746b642d766ebfeb8c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 18 Apr 2025 12:30:59 +0200 Subject: [PATCH] Always fill debit and credit of grouped account move line The inherited MoveLineMixin is expecting those fields to be always filled. Closes #13976 --- modules/account_move_line_grouping/account.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/account_move_line_grouping/account.py b/modules/account_move_line_grouping/account.py index 206b56fa2f..9465a4c853 100644 --- a/modules/account_move_line_grouping/account.py +++ b/modules/account_move_line_grouping/account.py @@ -2,6 +2,7 @@ # this repository contains the full copyright notices and license terms. from sql import As, Null, Select, Window from sql.aggregate import BoolAnd, BoolOr, Min, Sum +from sql.conditionals import Coalesce from sql.functions import FirstValue from trytond.model import ModelSQL, ModelView, fields @@ -170,8 +171,8 @@ class MoveLineGroup(MoveLineMixin, ModelSQL, ModelView): else: filter_ = None return [ - Sum(line.debit, filter_=filter_).as_('debit'), - Sum(line.credit, filter_=filter_).as_('credit'), + Coalesce(Sum(line.debit, filter_=filter_), 0).as_('debit'), + Coalesce(Sum(line.credit, filter_=filter_), 0).as_('credit'), Sum(line.amount_second_currency, filter_=filter_).as_( 'amount_second_currency'), BoolOr(line.reconciliation != Null).as_('partially_reconciled'),