[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:
@@ -45,7 +45,7 @@ class AccountPayment(models.Model):
|
|||||||
_inherit = "account.payment"
|
_inherit = "account.payment"
|
||||||
|
|
||||||
check_amount_in_words = fields.Char(string="Amount in Words")
|
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,
|
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 "
|
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.")
|
"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
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
if vals['payment_method_id'] == self.env.ref('account_check_printing.account_payment_method_check').id\
|
if vals['payment_method_id'] == self.env.ref('account_check_printing.account_payment_method_check').id:
|
||||||
and vals.get('check_manual_sequencing'):
|
journal = self.env['account.journal'].browse(vals['journal_id'])
|
||||||
sequence = self.env['account.journal'].browse(vals['journal_id']).check_sequence_id
|
if journal.check_manual_sequencing:
|
||||||
vals.update({'check_number': sequence.next_by_id()})
|
vals.update({'check_number': journal.check_sequence_id.next_by_id()})
|
||||||
return super(AccountPayment, self).create(vals)
|
return super(AccountPayment, self).create(vals)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
|
|||||||
Reference in New Issue
Block a user