From 32fc5e49d4c24311a038ce5953abf3b88f25b977 Mon Sep 17 00:00:00 2001 From: qdp-odoo <qdp@odoo.com> Date: Thu, 29 Sep 2016 21:47:27 +0200 Subject: [PATCH] [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'. --- addons/account_check_printing/models/account_payment.py | 5 ++--- .../wizard/print_prenumbered_checks.py | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/account_check_printing/models/account_payment.py b/addons/account_check_printing/models/account_payment.py index 30019379029b..fc3e200840e6 100644 --- a/addons/account_check_printing/models/account_payment.py +++ b/addons/account_check_printing/models/account_payment.py @@ -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 diff --git a/addons/account_check_printing/wizard/print_prenumbered_checks.py b/addons/account_check_printing/wizard/print_prenumbered_checks.py index 79af6f69dd0d..9f5ebcacaf79 100644 --- a/addons/account_check_printing/wizard/print_prenumbered_checks.py +++ b/addons/account_check_printing/wizard/print_prenumbered_checks.py @@ -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 -- GitLab