[FIX] public_budget: ajustar amount neto en alta masiva de OP con retenciones#611
Open
iga-adhoc wants to merge 1 commit into
Open
[FIX] public_budget: ajustar amount neto en alta masiva de OP con retenciones#611iga-adhoc wants to merge 1 commit into
iga-adhoc wants to merge 1 commit into
Conversation
…enciones En la creación masiva de órdenes de pago (mass_payment_group_create), amount se setea al bruto de la factura. l10n_ar_tax suma las retenciones a payment_total (sign=+1 para proveedor outbound), por lo que payment_total > to_pay_amount y la validación de to_signature_process falla. En el flujo manual, _onchange_withholdings ajusta amount al neto, pero ese onchange no dispara en creación programática. Se aplica el mismo ajuste post-create: amount = amount + payment_difference, dejando amount en neto y payment_total == to_pay_amount. closes ingadhoc/odoo-public-administration#???
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adjusts supplier outbound payment creation in mass_payment_group_create to account for Argentine withholding behavior where programmatic creation doesn’t trigger the same onchange logic as the manual flow.
Changes:
- Captures the created
account.paymentrecord to post-process it. - Applies a netting adjustment to
payment.amountbased onpayment.payment_differenceto match the manual withholding onchange behavior. - Uses a context flag to bypass move synchronization when updating the amount.
Comment on lines
+441
to
+445
| if payment.payment_difference: | ||
| new_amount = payment.amount + payment.payment_difference | ||
| payment.with_context( | ||
| skip_account_move_synchronization=True | ||
| ).amount = new_amount if new_amount > 0 else 0 |
Comment on lines
+441
to
+445
| if payment.payment_difference: | ||
| new_amount = payment.amount + payment.payment_difference | ||
| payment.with_context( | ||
| skip_account_move_synchronization=True | ||
| ).amount = new_amount if new_amount > 0 else 0 |
Comment on lines
+443
to
+445
| payment.with_context( | ||
| skip_account_move_synchronization=True | ||
| ).amount = new_amount if new_amount > 0 else 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problema
En
mass_payment_group_create, el campoamountse setea al bruto de la factura (-sum(amount_residual)). El módulol10n_ar_taxaplica las retenciones sumándolas apayment_total(sign=+1 para proveedor outbound), lo que dejapayment_total > to_pay_amount.Consecuencias:
to_signature_processfalla ("Importe a pagar distinto a Importe de los Pagos").En el flujo manual el onchange
_onchange_withholdingsdescuenta las retenciones deamount, dejandoamount = neto. En la creación programática ese onchange nunca dispara.Solución
Después de crear el payment, se aplica el mismo ajuste que haría
_onchange_withholdings:payment_difference = to_pay_amount - payment_total = -withholdings_amount, por lo queamountqueda en neto ypayment_total == to_pay_amount.Test plan
payment_total == to_pay_amount(sin diferencia).