Skip to content

Comments

[IMP] l10n_latam_check_ux: Added restriction on checks delete#659

Open
feg-adhoc wants to merge 1 commit intoingadhoc:18.0from
adhoc-dev:18.0-t-42765-feg
Open

[IMP] l10n_latam_check_ux: Added restriction on checks delete#659
feg-adhoc wants to merge 1 commit intoingadhoc:18.0from
adhoc-dev:18.0-t-42765-feg

Conversation

@feg-adhoc
Copy link
Contributor

No description provided.

@roboadhoc
Copy link
Contributor

@feg-adhoc feg-adhoc changed the title [ADD] l10n_latam_check: Added restriction on checks delete [ADD] l10n_latam_check_ux: Added restriction on checks delete Apr 11, 2025
@feg-adhoc feg-adhoc changed the title [ADD] l10n_latam_check_ux: Added restriction on checks delete [IMP] l10n_latam_check_ux: Added restriction on checks delete May 29, 2025
@feg-adhoc feg-adhoc force-pushed the 18.0-t-42765-feg branch 4 times, most recently from 25186b2 to 480ab5a Compare June 27, 2025 23:04
@roboadhoc
Copy link
Contributor

Pull request status dashboard

@roboadhoc
Copy link
Contributor

@feg-adhoc I didn't know about this PR and had to retrieve its information, you may have to re-approve it as I didn't see previous commands.

@feg-adhoc feg-adhoc force-pushed the 18.0-t-42765-feg branch 4 times, most recently from 534c7f7 to d3cf885 Compare September 8, 2025 12:58
Esto es necesario porque ahora en pagos de clientes el onchage de withholdings no computa amount
Además, sin l10n_Ar_tax no estamos mandaando el amount

Quedaría una mejora "linda" que sería evaluar si el default journal que se va a usar es en otra moneda, tal vez deberíamos convertir el importe que se manda a esa otra moenda (pero la verdad no parece ser un caso necesario por el momento)

closes ingadhoc#765

Related: ingadhoc/odoo-argentina#1189
Signed-off-by: Camila Vives <cav@adhoc.inc>
Copilot AI review requested due to automatic review settings December 1, 2025 13:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Este PR añade restricciones para prevenir la eliminación y modificación de cheques que están siendo utilizados en transacciones procesadas o pagadas. La implementación incluye validaciones tanto en el modelo de cheques como en el modelo de pagos para mantener la integridad de datos.

  • Se añade _check_unlink_restriction() para prevenir la eliminación de cheques con transacciones activas
  • Se añade _onchange_check_data() para prevenir modificaciones en datos críticos de cheques en uso
  • Se implementa _checks_state() en account.payment para validar en cascada al eliminar pagos

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
l10n_latam_check_ux/models/l10n_latam_check.py Añade métodos de validación @api.ondelete y @api.onchange para proteger cheques contra eliminación y modificación cuando están en transacciones activas
l10n_latam_check_ux/models/account_payment.py Implementa validación @api.ondelete para invocar restricciones de cheques cuando se elimina un pago, asegurando validación en cascada

def _check_unlink_restriction(self):
for check in self:
if any(payment.state in ["in_process", "paid"] for payment in check.operation_ids):
raise UserError("You must unlink all transactions related to this check before deleting it.")
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

Los mensajes de error deben estar envueltos con la función _() para permitir su traducción. Según la convención del módulo (ver account_check_action_wizard.py), todos los mensajes de error para el usuario deberían ser traducibles.

Sugerencia:

raise UserError(_("You must unlink all transactions related to this check before deleting it."))
Suggested change
raise UserError("You must unlink all transactions related to this check before deleting it.")
raise UserError(_("You must unlink all transactions related to this check before deleting it."))

Copilot uses AI. Check for mistakes.
def _onchange_check_data(self):
for check in self:
if any(payment.state in ["in_process", "paid"] for payment in check.operation_ids):
raise UserError("You cannot change the check data because it is already used in a transaction.")
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

Los mensajes de error deben estar envueltos con la función _() para permitir su traducción. Según la convención del módulo (ver account_check_action_wizard.py), todos los mensajes de error para el usuario deberían ser traducibles.

Sugerencia:

raise UserError(_("You cannot change the check data because it is already used in a transaction."))
Suggested change
raise UserError("You cannot change the check data because it is already used in a transaction.")
raise UserError(_("You cannot change the check data because it is already used in a transaction."))

Copilot uses AI. Check for mistakes.
Comment on lines +73 to +79
if any(payment.state in ["in_process", "paid"] for payment in check.operation_ids):
raise UserError("You must unlink all transactions related to this check before deleting it.")

@api.onchange("amount", "payment_date", "name")
def _onchange_check_data(self):
for check in self:
if any(payment.state in ["in_process", "paid"] for payment in check.operation_ids):
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

La validación solo verifica operation_ids pero no incluye payment_id. Según el código existente (líneas 30, 36, 45, 65), un cheque puede tener transacciones tanto en payment_id como en operation_ids. Si payment_id tiene estado "in_process" o "paid", el cheque también debería estar protegido contra eliminación.

Sugerencia:

if check.payment_id.state in ["in_process", "paid"] or any(payment.state in ["in_process", "paid"] for payment in check.operation_ids):
Suggested change
if any(payment.state in ["in_process", "paid"] for payment in check.operation_ids):
raise UserError("You must unlink all transactions related to this check before deleting it.")
@api.onchange("amount", "payment_date", "name")
def _onchange_check_data(self):
for check in self:
if any(payment.state in ["in_process", "paid"] for payment in check.operation_ids):
if check.payment_id.state in ["in_process", "paid"] or any(payment.state in ["in_process", "paid"] for payment in check.operation_ids):
raise UserError("You must unlink all transactions related to this check before deleting it.")
@api.onchange("amount", "payment_date", "name")
def _onchange_check_data(self):
for check in self:
if check.payment_id.state in ["in_process", "paid"] or any(payment.state in ["in_process", "paid"] for payment in check.operation_ids):

Copilot uses AI. Check for mistakes.
Comment on lines +73 to +79
if any(payment.state in ["in_process", "paid"] for payment in check.operation_ids):
raise UserError("You must unlink all transactions related to this check before deleting it.")

@api.onchange("amount", "payment_date", "name")
def _onchange_check_data(self):
for check in self:
if any(payment.state in ["in_process", "paid"] for payment in check.operation_ids):
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

La validación solo verifica operation_ids pero no incluye payment_id. Según el código existente (líneas 30, 36, 45, 65), un cheque puede tener transacciones tanto en payment_id como en operation_ids. Si payment_id tiene estado "in_process" o "paid", los datos del cheque también deberían estar protegidos contra modificación.

Sugerencia:

if check.payment_id.state in ["in_process", "paid"] or any(payment.state in ["in_process", "paid"] for payment in check.operation_ids):
Suggested change
if any(payment.state in ["in_process", "paid"] for payment in check.operation_ids):
raise UserError("You must unlink all transactions related to this check before deleting it.")
@api.onchange("amount", "payment_date", "name")
def _onchange_check_data(self):
for check in self:
if any(payment.state in ["in_process", "paid"] for payment in check.operation_ids):
if (check.payment_id.state in ["in_process", "paid"] or
any(payment.state in ["in_process", "paid"] for payment in check.operation_ids)):
raise UserError("You must unlink all transactions related to this check before deleting it.")
@api.onchange("amount", "payment_date", "name")
def _onchange_check_data(self):
for check in self:
if (check.payment_id.state in ["in_process", "paid"] or
any(payment.state in ["in_process", "paid"] for payment in check.operation_ids)):

Copilot uses AI. Check for mistakes.
super().action_draft()

@api.ondelete(at_uninstall=False)
def _checks_state(self):
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

El nombre del método _checks_state es poco descriptivo y no sigue la convención de Odoo para métodos @api.ondelete. Debería indicar claramente que valida restricciones de eliminación.

Sugerencia: renombrar a _check_new_checks_unlink_restriction para mayor claridad y consistencia con _check_unlink_restriction en el modelo de cheques.

Suggested change
def _checks_state(self):
def _check_new_checks_unlink_restriction(self):

Copilot uses AI. Check for mistakes.
Comment on lines +100 to +101
if rec.l10n_latam_new_check_ids:
rec.l10n_latam_new_check_ids._check_unlink_restriction()
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

La validación solo verifica l10n_latam_new_check_ids, pero según la línea 88, los pagos también pueden tener cheques en l10n_latam_move_check_ids. Estos cheques también deberían validarse antes de eliminar un pago.

Sugerencia:

all_checks = rec.l10n_latam_new_check_ids + rec.l10n_latam_move_check_ids
if all_checks:
    all_checks._check_unlink_restriction()
Suggested change
if rec.l10n_latam_new_check_ids:
rec.l10n_latam_new_check_ids._check_unlink_restriction()
all_checks = rec.l10n_latam_new_check_ids + rec.l10n_latam_move_check_ids
if all_checks:
all_checks._check_unlink_restriction()

Copilot uses AI. Check for mistakes.
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.

3 participants