Skip to content

Commit

Permalink
[FIX] account_validate_account_move: send mail on validated invoices.
Browse files Browse the repository at this point in the history
ticket 36113

closes #343

Signed-off-by: Katherine Zaoral <[email protected]>
  • Loading branch information
zaoral committed Jun 28, 2022
1 parent 9a98c2d commit bb2e161
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions account_ux/wizards/account_validate_account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ def validate_move(self):
raise UserError(_("Missing 'active_model' in context."))

moves = self.env['account.move'].search(domain).filtered('line_ids')
res = super().validate_move()
# we try to send by email the invoices recently validated
moves.action_send_invoice_mail()
try:
res = super().validate_move()
moves.with_context(mail_notify_force_send=False).action_send_invoice_mail()
except Exception as exp:
# we try to send by email the invoices recently validated
posted_moves = self.filter_posted_moves(moves)
posted_moves.with_context(mail_notify_force_send=False).action_send_invoice_mail()
raise exp
return res

def filter_posted_moves(self, moves):
return moves.filtered(lambda x: x.state == 'posted')

0 comments on commit bb2e161

Please sign in to comment.