-
Notifications
You must be signed in to change notification settings - Fork 132
[FIX] account_ux: send invoice email for posted invoices ready to be sent #862
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
base: 19.0
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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()ystate == 'posted'para determinar qué facturas son elegibles
account_ux/models/account_move.py
Outdated
| """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') |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
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.
| 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()) |
account_ux/models/account_move.py
Outdated
| 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() |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
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
72a258f to
a6904e5
Compare

No description provided.