Merge pull request #3689 from expsa/fix-bug-accounting

change in action post
This commit is contained in:
ahmed-nouri051 2025-06-29 15:37:03 +02:00 committed by GitHub
commit 914f3867cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 34 additions and 12 deletions

View File

@ -48,23 +48,45 @@ class AccountPayment(models.Model):
group_name = self.env.ref(group_xml_id).name
raise AccessError(_("You do not have the necessary permissions (%s) to perform this action.") % group_name)
def action_post(self):
if self.payment_type == 'outbound':
self._check_permission('odex25_account_payment_fix.group_posted')
res = super(AccountPayment, self).action_post()
# def action_post(self):
# if self.payment_type == 'outbound':
# self._check_permission('odex25_account_payment_fix.group_posted')
# res = super(AccountPayment, self).action_post()
for payment in self:
payment.invalidate_cache()
payment.state = 'posted'
if payment.analytic_account_id and payment.move_id:
# for payment in self:
# payment.invalidate_cache()
# payment.state = 'posted'
# if payment.analytic_account_id and payment.move_id:
for line in payment.move_id.line_ids:
if line.account_id.id == payment.destination_account_id.id:
line.analytic_account_id = payment.analytic_account_id.id
return res
# for line in payment.move_id.line_ids:
# if line.account_id.id == payment.destination_account_id.id:
# line.analytic_account_id = payment.analytic_account_id.id
# return res
def action_post(self):
if self.payment_type == 'outbound':
self._check_permission('odex25_account_payment_fix.group_posted')
res = super(AccountPayment, self).action_post()
for payment in self:
payment.state = 'posted'
if payment.analytic_account_id and payment.move_id:
target_lines = payment.move_id.line_ids.filtered(
lambda line: line.account_id.id == payment.destination_account_id.id
)
target_lines.write({'analytic_account_id': payment.analytic_account_id.id})
target_lines.invalidate_cache()
target_lines.read(['analytic_account_id'])
return res
def action_cancel(self):
payment_state = self.state