[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'.
This commit is contained in:
qdp-odoo
2016-09-29 21:47:27 +02:00
parent 45e2a6abdc
commit 32fc5e49d4
2 changed files with 4 additions and 3 deletions
@@ -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