Skip to content

Commit

Permalink
[FIX] account_payment_invoice: Add sudo for call method create electo…
Browse files Browse the repository at this point in the history
…rnic transaction.

closes #443

X-original-commit: 1ccf21c
Signed-off-by: Juan José Scarafía <jjs@adhoc.com.ar>
  • Loading branch information
maq-adhoc committed Jan 24, 2024
1 parent cb07958 commit a63851e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions account_payment_invoice/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ class AccountMove(models.Model):
@api.depends('transaction_ids.state')
def _compute_payment_state(self):
super()._compute_payment_state()
for rec in self.filtered(lambda x: x.payment_state=='not_paid' and {'done','pending','authorized'}.intersection(set(x.transaction_ids.mapped('state')))):
for rec in self.filtered(lambda x: x.payment_state=='not_paid' and {'pending','authorized'}.intersection(set(x.transaction_ids.mapped('state')))):
rec.payment_state = 'electronic_pending'

def _post(self, soft=True):
res = super()._post(soft=soft)
to_pay_moves = self.filtered(
lambda x: x.payment_token_id and x.state == 'posted' and
x.payment_state in ['not_paid', 'electronic_pending'] and x.move_type == 'out_invoice')
to_pay_moves.create_electronic_payment()
to_pay_moves.sudo().create_electronic_payment()
return res

def create_electronic_payment(self):
Expand Down

0 comments on commit a63851e

Please sign in to comment.