diff --git a/addons/account_check_printing/models/account_payment.py b/addons/account_check_printing/models/account_payment.py index ab6623b3068..d4ab83da890 100644 --- a/addons/account_check_printing/models/account_payment.py +++ b/addons/account_check_printing/models/account_payment.py @@ -45,7 +45,7 @@ class AccountPayment(models.Model): _inherit = "account.payment" check_amount_in_words = fields.Char(string="Amount in Words") - check_manual_sequencing = fields.Boolean(related='journal_id.check_manual_sequencing') + check_manual_sequencing = fields.Boolean(related='journal_id.check_manual_sequencing', readonly=1) check_number = fields.Integer(string="Check Number", readonly=True, copy=False, help="The selected journal is configured to print check numbers. If your pre-printed check paper already has numbers " "or if the current numbering is wrong, you can change it in the journal configuration page.") @@ -82,10 +82,10 @@ class AccountPayment(models.Model): @api.model def create(self, vals): - if vals['payment_method_id'] == self.env.ref('account_check_printing.account_payment_method_check').id\ - and vals.get('check_manual_sequencing'): - sequence = self.env['account.journal'].browse(vals['journal_id']).check_sequence_id - vals.update({'check_number': sequence.next_by_id()}) + if vals['payment_method_id'] == self.env.ref('account_check_printing.account_payment_method_check').id: + journal = self.env['account.journal'].browse(vals['journal_id']) + if journal.check_manual_sequencing: + vals.update({'check_number': journal.check_sequence_id.next_by_id()}) return super(AccountPayment, self).create(vals) @api.multi