From b7e30f2f56ceafd49e3eecbacddba041fce07cc1 Mon Sep 17 00:00:00 2001 From: Danny de Jong Date: Thu, 6 Jun 2024 14:39:10 +0200 Subject: [PATCH] [FIX] Convert tax tags based on move type instead of amount. --- openupgradelib/openupgrade_130.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openupgradelib/openupgrade_130.py b/openupgradelib/openupgrade_130.py index cf641388..8793c91a 100644 --- a/openupgradelib/openupgrade_130.py +++ b/openupgradelib/openupgrade_130.py @@ -101,9 +101,10 @@ def convert_old_style_tax_tag_to_new( UPDATE account_account_tag_account_move_line_rel r SET account_account_tag_id = %s FROM account_move_line aml + LEFT JOIN account_move am ON am.id = aml.account_id WHERE r.account_move_line_id = aml.id AND - aml.debit >= 0 AND + am.type IN ('out_invoice', 'in_invoice') AND r.account_account_tag_id = %s """, (new_debit_tag_id, old_tag_id), @@ -114,9 +115,10 @@ def convert_old_style_tax_tag_to_new( UPDATE account_account_tag_account_move_line_rel r SET account_account_tag_id = %s FROM account_move_line aml + LEFT JOIN account_move am ON am.id = aml.account_id WHERE r.account_move_line_id = aml.id AND - aml.credit > 0 AND + am.type IN ('out_refund', 'in_refund') AND r.account_account_tag_id = %s """, (new_credit_tag_id, old_tag_id),