Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] Add new module accout_payment_ux Fix the behavior of pending tr…
…ansacition realated with a account.payment What is happening now: - when i'm create a electronic payment from backend and the transaction remains in pending status the payment status is changed to canceled what happens after installing this module - When the transaction is pending the payment remains in draft status. After done this transaction the payment change its state ans reconcilie with the invoices
- Loading branch information
Showing
5 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# © 2023 ADHOC SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Account Payment UX", | ||
"version": "16.0.1.0.0", | ||
"category": "Payment", | ||
"website": "www.adhoc.com.ar", | ||
"author": "ADHOC SA", | ||
"license": "AGPL-3", | ||
"application": False, | ||
'installable': True, | ||
'auto_install': True, | ||
"external_dependencies": { | ||
"python": [], | ||
"bin": [], | ||
}, | ||
"depends": [ | ||
"account_payment", | ||
], | ||
"data": [ | ||
], | ||
"demo": [ | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import account_payment | ||
from . import payment_transaction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from odoo import models | ||
|
||
|
||
class AccountPayment(models.Model): | ||
_inherit = 'account.payment' | ||
|
||
def action_post(self): | ||
""" Odoo a partir de 16, cuando se valida un pago con token, si la transaccion no queda en done cancela el pago | ||
por ahora nosotros revertimos este cambio para el caso de tu cuota""" | ||
return super(AccountPayment, self.with_context(from_action_post=True)).action_post() | ||
|
||
def action_cancel(self): | ||
if self._context.get('from_action_post'): | ||
self = self - self.filtered(lambda x: x.payment_transaction_id.state in ['draft', 'pending', 'authorized']) | ||
return super(AccountPayment, self).action_cancel() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from odoo import models | ||
|
||
|
||
class PaymentTransaction(models.Model): | ||
_inherit = 'payment.transaction' | ||
|
||
def _reconcile_after_done(self): | ||
super()._reconcile_after_done() | ||
|
||
# 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 \ | ||
self.payment_id.currency_id == self.currency_id and \ | ||
self.payment_id.amount == abs(self.amount): | ||
|
||
self.payment_id.action_post() | ||
if self.invoice_ids: | ||
self.invoice_ids.filtered(lambda inv: inv.state == 'draft').action_post() | ||
|
||
(self.payment_id.line_ids + self.invoice_ids.line_ids).filtered( | ||
lambda line: line.account_id == self.payment_id.destination_account_id | ||
and not line.reconciled | ||
).reconcile() |