Skip to content
Snippets Groups Projects
Commit 32fc5e49 authored by Quentin De Paoli's avatar Quentin De Paoli
Browse files

[FIX] account_check_printing: fix flow of check.

Use case fixed: create a draft supplier payment, tick it in list view and launch the action 'print check'. Then, on the pop up window cancel the operation => the state was badly set to 'sent'.
parent 45e2a6ab
No related branches found
No related tags found
No related merge requests found
......@@ -102,9 +102,6 @@ class AccountPayment(models.Model):
if any(payment.journal_id != self[0].journal_id for payment in self):
raise UserError(_("In order to print multiple checks at once, they must belong to the same bank journal."))
self.filtered(lambda r: r.state == 'draft').post()
self.write({'state': 'sent'})
if not self[0].journal_id.check_manual_sequencing:
# The wizard asks for the number printed on the first pre-printed check
# so payments are attributed the number of the check the'll be printed on.
......@@ -125,6 +122,8 @@ class AccountPayment(models.Model):
}
}
else:
self.filtered(lambda r: r.state == 'draft').post()
self.write({'state': 'sent'})
return self.do_print_checks()
@api.multi
......
......@@ -14,6 +14,8 @@ class PrintPreNumberedChecks(models.TransientModel):
def print_checks(self):
check_number = self.next_check_number
payments = self.env['account.payment'].browse(self.env.context['payment_ids'])
payments.filtered(lambda r: r.state == 'draft').post()
payments.filtered(lambda r: r.state != 'sent').write({'state': 'sent'})
for payment in payments:
payment.check_number = check_number
check_number += 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment