Skip to content
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

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

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
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
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

When editing invoice lines, move lines are not correctly computed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants