Skip to content

[16.0] [FIX] l10n_it_split_payment: when editing invoice lines, move lines are not correctly computed #4233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

eLBati
Copy link
Member

@eLBati eLBati commented Jun 25, 2024

Copy link
Contributor

@odooNextev odooNextev left a comment

Choose a reason for hiding this comment

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

Test funzionale OK

Copy link
Contributor

@SirAionTech SirAionTech left a comment

Choose a reason for hiding this comment

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

Grazie della PR!
Puoi modificare il messaggio del commit in modo che segua le linee guida in https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#71commit-message?
In particolare:

please check if the commit message is cut with ellipsis

Puoi aggiungere un test? Così si evitano regressioni.

return res
for move in self:
if move.split_payment:
split_payment_total = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Questo viene dichiarato qui e sommato poco sotto, ma non trovo dove viene usato: a cosa serve?

Copy link
Member Author

Choose a reason for hiding this comment

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

Rimosso

write_off_line_vals = line._build_writeoff_line()
split_payment_total += write_off_line_vals["debit"]
line_sp = fields.first(
line.move_id.line_ids.filtered(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
line.move_id.line_ids.filtered(
move.line_ids.filtered(

Copy link
Member Author

Choose a reason for hiding this comment

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

Fatto

float_compare(
line_sp.price_unit,
write_off_line_vals["price_unit"],
precision_rounding=line.move_id.currency_id.rounding,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
precision_rounding=line.move_id.currency_id.rounding,
precision_rounding=move.currency_id.rounding,

Copy link
Member Author

Choose a reason for hiding this comment

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

Fatto

):
line_sp.write(write_off_line_vals)
else:
if line.move_id.amount_sp:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if line.move_id.amount_sp:
if move.amount_sp:

Copy link
Member Author

Choose a reason for hiding this comment

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

Fatto

if line.display_type == "tax" and not line.is_split_payment:
write_off_line_vals = line._build_writeoff_line()
split_payment_total += write_off_line_vals["debit"]
line_sp = fields.first(
Copy link
Contributor

Choose a reason for hiding this comment

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

Per ogni riga cerca tra tutte le righe della move e troverà sempre la stessa line_sp, non sarebbe meglio salvarla? Così almeno evitiamo di rifare la ricerca e il filtered che tra l'altro ora è anche su un campo calcolato.

Se poi riuscissimo anche a fare la scrittura fuori dal loop non sarebbe male.

In pratica, ora che siamo nella move si potrebbe riscrivere un po' questo loop per evitare di rifare le stesse operazioni per ogni riga: ad esempio ottenere in un colpo solo l'importo da mettere nel writeoff da tutte le righe che non sono is_split_payment, visto che _build_writeoff_line prende quasi tutti i dati dalla move; cosa ne pensi?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ho tirato fuori line_sp ma non mi è chiara l'altra proposta

if line.move_id.amount_sp:
line.move_id.with_context(
skip_split_payment_computation=True
).line_ids = [(0, 0, write_off_line_vals)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Rispetto al codice rimosso sotto non c'è più _sync_dynamic_lines, sai mica come mai non serve più?

Copy link
Member Author

Choose a reason for hiding this comment

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

Dovrebbe essere lui a scrivere le move lines indesiderate



class AccountMoveLine(models.Model):
_inherit = "account.move.line"

is_split_payment = fields.Boolean()
is_split_payment = fields.Boolean(compute="_compute_is_split_payment")
Copy link
Contributor

Choose a reason for hiding this comment

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

Si potrebbe rendere storato e dipendente da account_id, che ne dici?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fatto

if line.move_id.amount_sp:
line.move_id.with_context(
skip_split_payment_computation=True
).line_ids = [(0, 0, write_off_line_vals)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
).line_ids = [(0, 0, write_off_line_vals)]
).line_ids = [Command.create(write_off_line_vals)]

Copy link
Member Author

Choose a reason for hiding this comment

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

Fatto

@eLBati eLBati force-pushed the 16.0-fix-split_payment branch from f6b5fe7 to 0e6a669 Compare July 12, 2024 13:42
@eLBati
Copy link
Member Author

eLBati commented Jul 12, 2024

please check if the commit message is cut with ellipsis

Fatto

Puoi aggiungere un test?

Al momento non riesco

@eLBati eLBati force-pushed the 16.0-fix-split_payment branch 2 times, most recently from c34606a to 1b72988 Compare July 12, 2024 13:47
@eLBati eLBati force-pushed the 16.0-fix-split_payment branch from 1b72988 to 5cabb0a Compare July 31, 2024 14:08
Copy link

@MaurizioPellegrinet MaurizioPellegrinet left a comment

Choose a reason for hiding this comment

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

Funzionale OK

@matteoopenf
Copy link
Contributor

per caso verrà mergiata a breve?

@francesco-ooops
Copy link
Contributor

@matteoopenf stando alla review, mancava l'aggiunta di un test

se @eLBati non riesce potreste aggiungerlo voi

@francesco-ooops
Copy link
Contributor

/ocabot rebase

When editing invoice lines, move lines are not correctly computed
@OCA-git-bot
Copy link
Contributor

Congratulations, PR rebased to 16.0.

@masimassimo
Copy link

@francesco-ooops col codice della #4233, continuo ad avere il problema. Ho fatto un test, aggiungendo al context check_move_validity=False, quando la write di account.move chiama la super e richiamando _check_balanced prima della return.
In questo modo, succede che la fattura viene scritta correttamente ed è bilanciata, anche se il sistema diceva il contrario.
Forse, quando Odoo esegue il controllo con la funzione _check_balanced di account.move, la scrittura delle righe non è ancora completa.

image

image

image

@CiroBoxHub
Copy link
Contributor

Buongiorno, ho testato la PR con le modifiche suggerite anche da @masimassimo relativamente al problema segnalato nella #4432 ma il risultato è il medesimo. L'errore di creazione fattura per scritture sbilanciate rimane.
Ci sono altri aggiornamenti utili?

@CiroBoxHub
Copy link
Contributor

Ho anche verificato che il problema ora si presenta anche senza la presenza del DDT

@masimassimo
Copy link

@CiroBoxHub se vuoi possiamo vedere di fare qualche test insieme

@CiroBoxHub
Copy link
Contributor

CiroBoxHub commented Nov 19, 2024

@CiroBoxHub se vuoi possiamo vedere di fare qualche test insieme

Ciao @masimassimo ho fatto un test a partire dalla runbot della PR è ho il problema anche li

http://oca-l10n-italy-16-0-pr4233-f003442ef656.runboat.odoo-community.org/web?debug=1#cids=1&menu_id=160&action=274&model=account.move&view_type=form&id=16 questa la fattura creata che non fa salvare.

C'è qualcosa di configurato male?

@patrickt-oforce
Copy link
Contributor

@francesco-ooops col codice della #4233, continuo ad avere il problema. Ho fatto un test, aggiungendo al context check_move_validity=False, quando la write di account.move chiama la super e richiamando _check_balanced prima della return. In questo modo, succede che la fattura viene scritta correttamente ed è bilanciata, anche se il sistema diceva il contrario. Forse, quando Odoo esegue il controllo con la funzione _check_balanced di account.move, la scrittura delle righe non è ancora completa.

image

image ![image](https://private-user-images.githubusercontent.com/33621723/384909571-02891ee8-c555-43f4-b6b0-797fc74b996e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzIyNzAyOTYsIm5iZiI6MTczMjI2OTk5NiwicGF0aCI6Ii8zMzYyMTcyMy8zODQ5MDk1NzEtMDI4OTFlZTgtYzU1NS00M2Y0LWI2YjAtNzk3ZmM3NGI5OTZlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDExMjIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQxMTIyVDEwMDYzNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTFjNzliYTg2M2Q4MzAyMzQwMTZhZWIzOTc0MGJkOWE2OTIzNjBmOTY4NzY1Mjg0ZTU2MDZiMTNkMDljZmIyZTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.a5EIyImSkyXRsWjlsD2gyjoSce1mE82FRxWB8WyVfv0)

Ciao @masimassimo, il secondo screen del messaggio fa riferimento a una fattura o una nota di credito? Perché per un nostro cliente ci siamo accorti che generando la nota di credito dalla fattura si perde il giroconto dello split payment; da una veloce analisi sembra che il metodo _sync_dynamic_line a riga 2107 identifichi la riga dello split payment come da rimuovere, andando poi ad accorpare l'iva al totale della fattura

@masimassimo
Copy link

masimassimo commented Nov 27, 2024

@patrickt-oforce è una fattura

@masimassimo
Copy link

@CiroBoxHub lo screenshot col codice che ho riportato nel precedente commento, è diverso da quello della PR.
Infatti, si tratta di una modifica apportata alla PR, realizzata in un ambiente di staging su sh.

@CiroBoxHub
Copy link
Contributor

@CiroBoxHub lo screenshot col codice che ho riportato nel precedente commento, è diverso da quello della PR. Infatti, si tratta di una modifica apportata alla PR, realizzata in un ambiente di staging su sh.

Ciao @masimassimo si infatti l'ho riportato manualmente nel mio ambiente ma continuo ad avere il problema

@matteoopenf
Copy link
Contributor

qualcuno ha poi trovato qualche soluzione?

@matteoopenf
Copy link
Contributor

@francesco-ooops col codice della #4233, continuo ad avere il problema. Ho fatto un test, aggiungendo al context check_move_validity=False, quando la write di account.move chiama la super e richiamando _check_balanced prima della return. In questo modo, succede che la fattura viene scritta correttamente ed è bilanciata, anche se il sistema diceva il contrario. Forse, quando Odoo esegue il controllo con la funzione _check_balanced di account.move, la scrittura delle righe non è ancora completa.

image

image ![image](https://private-user-images.githubusercontent.com/33621723/384909571-02891ee8-c555-43f4-b6b0-797fc74b996e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk5ODczMzIsIm5iZiI6MTczOTk4NzAzMiwicGF0aCI6Ii8zMzYyMTcyMy8zODQ5MDk1NzEtMDI4OTFlZTgtYzU1NS00M2Y0LWI2YjAtNzk3ZmM3NGI5OTZlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE5VDE3NDM1MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJlZjhmMmY5NTZjMWNlM2Q1MmVjMGU1MTIwNjRlNmUzOTM3ZThjMDIzNzI4Nzk2NmI0ZTUxZDMzMDY5ZmIyNzkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.a9HK_c91TfIpBHPZMlur1KQfbmjTc-7p8gg3ZHqZqT8)

quindi a te con il fix nello screen sta funzionando in produzione?

@matteoopenf
Copy link
Contributor

@masimassimo abbiamo aperto questa che comprende il tuo fix e ora sembra funzionare tutto correttamente.
Se ci dici la mail ti aggiungiamo anche a te come coautore della modifica perche' giustamente abbiamo usato un tuo pezzo di codice
#4630

@masimassimo
Copy link

@matteoopenf [email protected]

@eLBati
Copy link
Member Author

eLBati commented Mar 26, 2025

Quindi chiudo in favore di #4630

@eLBati eLBati closed this Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

l10n_it_split_payment: registrazioni contabili sbagliate dopo modifica riga fattura
10 participants