[FIX] account_check_printing: write payment not journal

When we make a payment, we need the write access on account.journal
because check_manual_sequencing on account.payment is a related field
of account.journal and was used to decide on numbering the check or not.

With this change, the write access is not required.

opw-1834343
opw-1835888
closes #24281
This commit is contained in:
Nicolas Lempereur
2018-04-17 17:26:19 +02:00
parent 5d13a2f431
commit 91ca846447
@@ -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