To reproduce:
- Create a cash basis tax
- Make an invoice with two lines, a positive and a negative one (the positive having a higher value), both using this tax
- Post the invoice and register a payment for it
===> It crashes when registering the payment. The SQL constraint ensuring debit/credit consistency fails when creating the cash basis entry.
This is because we were not grouping debit and credit values together on the lines sharing the same taxes; we were summing them separately. The cash basis entry then received line values with both credit and debit set, which is forbidden by the SQL constraint. We now compute the balance first, and set either debit or credit depending on its sign.
closesodoo/odoo#72383
X-original-commit: 896496d84413e7bb5e5df582e2b67eae2583671b
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>