Skip to content

[16.0][FIX] l10n_it_split_payment: multi-taxes#4947

Merged
OCA-git-bot merged 2 commits into
OCA:16.0from
mktsrl:16.0-fix-l10n_it_split_payment-update_writeoff
Jun 12, 2026
Merged

[16.0][FIX] l10n_it_split_payment: multi-taxes#4947
OCA-git-bot merged 2 commits into
OCA:16.0from
mktsrl:16.0-fix-l10n_it_split_payment-update_writeoff

Conversation

@TennyMkt

Copy link
Copy Markdown
Contributor

risolve #4945
(e sostituisce #4783)

La principale novità consiste nel modificare la funzione _build_writeoff_line in modo che non calcoli lo storno di una sola linea tax ma costruisca lo storno di tutte le imposte dell'account.move. Per questo viene spostata da account.move.line a account.move (e si modificano le traduzioni delle stringhe della funzione).
Inoltre per gestire la casistica di una fattura Split Payment di cui viene modificato il regime fiscale, sarebbe necessario eliminare la riga di "Split Payment Write Off" ma, avendo display_type = tax, non è possibile quindi viene azzerata in modo da sistemare i conteggi delle linee.

and line.move_id.is_sale_document(include_receipts=True)
è stato tolto in modo che vengano gestite anche le fatture fornitore.

@francesco-ooops

Copy link
Copy Markdown
Contributor

@micheledic che ne pensi?

@TennyMkt TennyMkt force-pushed the 16.0-fix-l10n_it_split_payment-update_writeoff branch from 1c10c38 to 234427e Compare October 10, 2025 14:01
@TennyMkt

Copy link
Copy Markdown
Contributor Author

Ho aggiornato la PR aggiungendo anche il test che ha proposto @micheledic in #4783

@micheledic micheledic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fatto un giro su runbot, funziona!

@micheledic

Copy link
Copy Markdown
Contributor

@micheledic che ne pensi?

continuiamo con questa, mi sembra più completa!

@TennyMkt

Copy link
Copy Markdown
Contributor Author

Ho aggiornato la PR per aggiungere nella write della account.move :

        if "fiscal_position_id" in vals:
            self._compute_amount()

perchè altrimenti nella casistica in cui una fattura in un regime fiscale "non split payment" viene modificato il regime fiscale impostandolo come "Split Payment" non verrebbe aggiunta la riga di storno se amount_sp non è aggiornato

@eLBati

eLBati commented Oct 15, 2025

Copy link
Copy Markdown
Member

Grazie @TennyMkt
.po files non dovrebbero essere modificati in PR, se ne occupa poi weblate.

Per il resto 👍

@TennyMkt

Copy link
Copy Markdown
Contributor Author

Grazie @TennyMkt .po files non dovrebbero essere modificati in PR, se ne occupa poi weblate.

Per il resto 👍

Aggiorno la PR togliendo le modifiche ai file .po o posso lasciarla così?

@francesco-ooops

Copy link
Copy Markdown
Contributor

@TennyMkt la cartella non dovrebbe essere inclusa nella PR

@TennyMkt TennyMkt force-pushed the 16.0-fix-l10n_it_split_payment-update_writeoff branch from 1188731 to 3411297 Compare October 15, 2025 12:42
@TennyMkt

Copy link
Copy Markdown
Contributor Author

PR Aggiornata togliendo modifiche in i18n

@francesco-ooops

Copy link
Copy Markdown
Contributor

@eLBati merge?

@TennyMkt

Copy link
Copy Markdown
Contributor Author

Facendo ulteriori test è emerso che utilizzando l'Azione Trasforma in fattura/nota di credito da una fattura Split Payment, la riga di storno si duplica.

La problematica sembra causata dalla funzione write aggiunta in account.move.line.py:

def write(self, vals):
    res = super().write(vals)
    move_to_compute_sp = []
    for line in self:
        if (
            (line.move_id not in move_to_compute_sp)
            and line.move_id.split_payment
            and line.display_type == "tax"
            and not line.is_split_payment
        ):
            move_to_compute_sp.append(line.move_id)
    for move in move_to_compute_sp:
        move.compute_split_payment()
    return res

Facendo test anche senza questa fare compute_split_payment() ogni volta che viene modificata una riga della fattura, lo storno viene aggiornato ugualmente.

Stiamo facendo ulteriori test prima di aggiornare la PR

@TennyMkt TennyMkt force-pushed the 16.0-fix-l10n_it_split_payment-update_writeoff branch from 3411297 to 1dccb7f Compare October 20, 2025 07:08
@TennyMkt

Copy link
Copy Markdown
Contributor Author

Facendo ulteriori test è emerso che utilizzando l'Azione Trasforma in fattura/nota di credito da una fattura Split Payment, la riga di storno si duplica.

La problematica sembra causata dalla funzione write aggiunta in account.move.line.py:

def write(self, vals):
    res = super().write(vals)
    move_to_compute_sp = []
    for line in self:
        if (
            (line.move_id not in move_to_compute_sp)
            and line.move_id.split_payment
            and line.display_type == "tax"
            and not line.is_split_payment
        ):
            move_to_compute_sp.append(line.move_id)
    for move in move_to_compute_sp:
        move.compute_split_payment()
    return res

Facendo test anche senza questa fare compute_split_payment() ogni volta che viene modificata una riga della fattura, lo storno viene aggiornato ugualmente.

Stiamo facendo ulteriori test prima di aggiornare la PR

Aggiornata la PR togliendo l'estensione della write di account.move.line.py perchè da ulteriori test risulta inutile anzi dannosa nel caso di utilizzo di "Trasforma in fattura/nota di credito"

@danall59 danall59 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il modulo è funzionante ed è un grosso passo aventi rispetto alla situzione attuale che non gestisce la fatture con più imposte, non gestisce correttamente la trasformazione in note credito, la generazione fattura da ordine e altro.
Abbiamo fatto numerosi test e Il modulo è ora in produzione su alcuni nostri clienti con situazioni complesse.

@MaurizioPellegrinet MaurizioPellegrinet left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test funzionale: OK

@TennyMkt TennyMkt force-pushed the 16.0-fix-l10n_it_split_payment-update_writeoff branch from 1dccb7f to b84d509 Compare October 27, 2025 11:40
@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

skip_split_payment_computation=True,
check_move_validity=False,
).write({"line_ids": [Command.update(line_sp.id, neutralize_vals)]})
move._sync_dynamic_lines(container={"records": move, "self": move})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR aggiornata inserendo gli aggiornamenti in righe
with move._sync_dynamic_lines(container={"records": move}):
però ho dovuto anche aggiungere dei
with_context(skip_split_payment_computation=True)
Perchè la _sync_dynamic_lines fa delle write e quindi farebbe dei loop infiniti

@TennyMkt TennyMkt force-pushed the 16.0-fix-l10n_it_split_payment-update_writeoff branch 2 times, most recently from 0b238c0 to c3eea4f Compare January 30, 2026 16:46
@TennyMkt TennyMkt force-pushed the 16.0-fix-l10n_it_split_payment-update_writeoff branch from c3eea4f to 54336a2 Compare February 2, 2026 15:02
@TennyMkt TennyMkt force-pushed the 16.0-fix-l10n_it_split_payment-update_writeoff branch from 5cfe918 to 4a22089 Compare March 30, 2026 10:58
@TennyMkt

Copy link
Copy Markdown
Contributor Author

Ho aggiornato la PR per risolvere un altro problema dovuto da questo modulo:
siccome anche la funzione _check_balanced è un @contextmanager e viene chiamata senza with, non viene controllato lo sbilanciamento delle registrazioni (nemmeno quelle senza split payment)

@TennyMkt TennyMkt changed the title [FIX] l10n_it_split_payment: multi-taxes [16.0][FIX] l10n_it_split_payment: multi-taxes Apr 3, 2026
@TennyMkt TennyMkt force-pushed the 16.0-fix-l10n_it_split_payment-update_writeoff branch from 4a22089 to 3b41e03 Compare April 8, 2026 13:47
@TheMule71 TheMule71 self-requested a review April 9, 2026 09:18

@TheMule71 TheMule71 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tafaRU

tafaRU commented Jun 12, 2026

Copy link
Copy Markdown
Member

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

On my way to merge this fine PR!
Prepared branch 16.0-ocabot-merge-pr-4947-by-tafaRU-bump-patch, awaiting test results.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

It looks like something changed on 16.0 in the meantime.
Let me try again (no action is required from you).
Prepared branch 16.0-ocabot-merge-pr-4947-by-tafaRU-bump-patch, awaiting test results.

3 similar comments
@OCA-git-bot

Copy link
Copy Markdown
Contributor

It looks like something changed on 16.0 in the meantime.
Let me try again (no action is required from you).
Prepared branch 16.0-ocabot-merge-pr-4947-by-tafaRU-bump-patch, awaiting test results.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

It looks like something changed on 16.0 in the meantime.
Let me try again (no action is required from you).
Prepared branch 16.0-ocabot-merge-pr-4947-by-tafaRU-bump-patch, awaiting test results.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

It looks like something changed on 16.0 in the meantime.
Let me try again (no action is required from you).
Prepared branch 16.0-ocabot-merge-pr-4947-by-tafaRU-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 151dde5 into OCA:16.0 Jun 12, 2026
6 of 7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 8506e3e. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FIX][16.0] l10n_it_split_payment: gestione fatture multi aliquote [16.0] l10n_it_split_payment calcolo errato in caso di aliquote diverse

9 participants