Skip to content

Commit

Permalink
[FIX] Only reconcile tx in done state
Browse files Browse the repository at this point in the history
[IMP] Ignore write post processed TX flag in draft and pendding transaction
  • Loading branch information
maq-adhoc authored and nicomacr committed Aug 17, 2023
1 parent 5d50cf2 commit b26b70b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion account_payment_ux/models/payment_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def _reconcile_after_done(self):

# Si el pago relacionado a la trasaccion esta en draft y coinciden los datos
# lo publico y concilio
if self.payment_id and self.payment_id.state == 'draft' and \
if self.state == 'done' and self.payment_id and self.payment_id.state == 'draft' and \
self.payment_id.currency_id == self.currency_id and \
self.payment_id.amount == abs(self.amount):

Expand All @@ -21,3 +21,21 @@ def _reconcile_after_done(self):
lambda line: line.account_id == self.payment_id.destination_account_id
and not line.reconciled
).reconcile()

def write(self, vals):
# Este hack es para evitar que las transacciones se marquen como post processed = True
# Cuando las genero pendientes desde el back end
# 1) Llama a _finalize_post_processing
# https://github.com/odoo/odoo/blob/16.0/addons/account_payment/models/account_payment.py#L143
# 2) _finalize_post_processing siempre marca la transaccion como is_post_processed
# aunque su estado no sea DONE...
# https://github.com/odoo/odoo/blob/16.0/addons/payment/models/payment_transaction.py#L890

ignoned_post_processed_tx = self.env['payment.transaction']
if vals.get('is_post_processed') and vals.get('state', 'draft') in ['draft', 'pending']:
altered_vals = vals.copy()
del altered_vals['is_post_processed']
ignoned_post_processed_tx = self.filtered(lambda x: x.state in ['draft', 'pending'])
ignoned_post_processed_tx.write(altered_vals)

return super(PaymentTransaction, self - ignoned_post_processed_tx).write(vals)

0 comments on commit b26b70b

Please sign in to comment.