Merge pull request #1533 from expsa/pla-55154-fix-ensan-sec

fix issue in ensan payment sec
This commit is contained in:
Mostafa 2024-10-13 15:54:23 -07:00 committed by GitHub
commit 00eacbdd68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 3 deletions

View File

@ -1,6 +1,19 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api, _
from odoo.exceptions import AccessError
from odoo.exceptions import AccessError, ValidationError
class AccountMove(models.Model):
_inherit = 'account.move'
def action_post(self):
res = super(AccountMove, self).action_post()
for rec in self:
payment = self.env['account.payment'].search([('move_id', '=', rec.id),
('payment_type', '=', 'outbound')], limit=1)
if payment and payment.state != 'posted':
raise ValidationError(_("You can't post this journal entry because the payment is not posted yet."))
return res
class AccountPayment(models.Model):
@ -49,7 +62,7 @@ class AccountPayment(models.Model):
payment_state = self.state
res = super(AccountPayment, self).action_cancel()
for payment in self:
if self.payment_type == 'outbound' and payment.state!='draft':
if self.payment_type == 'outbound' and payment.state != 'draft':
self._check_permission(f'odex25_account_payment_fix.group_{payment.state}')
if payment_state == 'draft':
payment.state = 'cancel'
@ -63,7 +76,7 @@ class AccountPayment(models.Model):
if line.account_id.id == payment.destination_account_id.id:
line.analytic_account_id = payment.analytic_account_id.id
return res
def action_draft(self):
res = super(AccountPayment, self).action_draft()
for payment in self: