Skip to content

Conversation

@rov-adhoc
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings January 2, 2026 19:21
@roboadhoc
Copy link

Pull request status dashboard

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 corrige el comportamiento del envío automático de emails de factura después de su publicación. En lugar de enviar emails a todas las facturas, ahora se filtran solo aquellas que están listas para ser enviadas, no han sido enviadas previamente, y están en estado "posted".

  • Agrega un filtro antes de enviar emails para evitar envíos duplicados o a facturas no preparadas
  • Utiliza las condiciones is_move_sent, _is_ready_to_be_sent() y state == 'posted' para determinar qué facturas son elegibles

"""After validate invoice will sent an email to the partner if the related journal has mail_template_id set"""
res = super()._post(soft=soft)
self.action_send_invoice_mail()
invoices_ready_to_send = self.filtered(lambda x: not x.is_move_sent and x._is_ready_to_be_sent() and x.state == 'posted')
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

La condición x.state == 'posted' en el filtro puede ser redundante, ya que el método _post() solo se ejecuta después de que el invoice ha sido publicado exitosamente. Después de la llamada a super()._post(soft=soft), todos los registros en self deberían tener state == 'posted'. Considera verificar si esta condición es necesaria o si puede simplificarse el filtro.

Suggested change
invoices_ready_to_send = self.filtered(lambda x: not x.is_move_sent and x._is_ready_to_be_sent() and x.state == 'posted')
invoices_ready_to_send = self.filtered(lambda x: not x.is_move_sent and x._is_ready_to_be_sent())

Copilot uses AI. Check for mistakes.
Comment on lines 26 to 27
invoices_ready_to_send = self.filtered(lambda x: not x.is_move_sent and x._is_ready_to_be_sent() and x.state == 'posted')
invoices_ready_to_send.action_send_invoice_mail()
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

Se agregó nueva lógica de filtrado para el envío de emails después de publicar facturas, pero no hay cobertura de tests para este comportamiento. Considera agregar tests que verifiquen que:

  • Solo se envían emails a facturas que no fueron enviadas previamente (is_move_sent=False)
  • Se respeta la condición _is_ready_to_be_sent()
  • No se envían emails a facturas que ya tienen is_move_sent=True

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.

2 participants