-
-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] account_check_report: payment amount should consider current pa…
…yment only not other payments [IMP] account_check_report: show amount residual at the payment date, not on todays date [IMP] account_check_report: show direct refund applied on invoices paid by the check e.g. 2 invoices and a refund for those 2 invoices should appear, even if the refund includes separate invoices [IMP]account_check_report: button invoices show all related invoices + direct refunds [IMP] account_check_report: add test coverage [IMP] account_check_report: do not print more than one line by invoice. Currently, if there are several receivable/payable lines, for example, due to payment terms the invoice appears multiple times
- Loading branch information
1 parent
1f43470
commit fbd26bc
Showing
7 changed files
with
521 additions
and
39 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import report | ||
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 @@ | ||
from . import account_payment |
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,92 @@ | ||
# 2016-2024 ForgeFlow S.L. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from odoo import api, models | ||
from odoo.osv import expression | ||
|
||
|
||
class AccountPayment(models.Model): | ||
_inherit = "account.payment" | ||
|
||
@api.depends( | ||
"move_id.line_ids.matched_debit_ids", "move_id.line_ids.matched_credit_ids" | ||
) | ||
def _compute_stat_buttons_from_reconciliation(self): | ||
res = super()._compute_stat_buttons_from_reconciliation() | ||
for rec in self: | ||
if rec.payment_type == "outbound": | ||
open_action = rec.button_open_bills() | ||
result_domain = open_action.get("domain", False) | ||
if not result_domain: | ||
return res | ||
rec.reconciled_bills_count = len( | ||
self.env["account.move"].search(result_domain) | ||
) | ||
else: | ||
open_action = rec.button_open_invoices() | ||
result_domain = open_action.get("domain", False) | ||
if not result_domain: | ||
return res | ||
rec.reconciled_invoices_count = len( | ||
self.env["account.move"].search(result_domain) | ||
) | ||
return res | ||
|
||
def get_direct_refunds(self): | ||
if self.payment_type == "outbound": | ||
move_lines = self.reconciled_bill_ids.mapped("line_ids") | ||
else: | ||
move_lines = self.reconciled_invoice_ids.mapped("line_ids") | ||
rec_lines = move_lines.filtered( | ||
lambda x: x.account_id.reconcile | ||
and x.account_id == self.destination_account_id | ||
and x.partner_id == self.partner_id | ||
) | ||
# include direct refunds | ||
if self.partner_type == "customer": | ||
invoice_ids = rec_lines.mapped( | ||
"matched_credit_ids.credit_move_id.full_reconcile_id." | ||
"reconciled_line_ids.move_id" | ||
).filtered(lambda i: i.date <= self.date) | ||
elif self.partner_type == "supplier": | ||
invoice_ids = rec_lines.mapped( | ||
"matched_debit_ids.debit_move_id.full_reconcile_id." | ||
"reconciled_line_ids.move_id" | ||
).filtered(lambda i: i.date <= self.date) | ||
# include other invoices where the payment was applied | ||
invoice_ids += rec_lines.mapped( | ||
"matched_credit_ids.credit_move_id.move_id" | ||
) + rec_lines.mapped("matched_debit_ids.debit_move_id.move_id") | ||
if not invoice_ids: | ||
return False | ||
invoice_ids -= self.move_id | ||
return invoice_ids | ||
|
||
def get_direct_refunds_domain(self): | ||
invoices = self.get_direct_refunds() | ||
if invoices: | ||
return [("id", "in", invoices.ids)] | ||
return [] | ||
|
||
def button_open_invoices(self): | ||
res = super(AccountPayment, self).button_open_invoices() | ||
if not res.get("domain", False): | ||
return res | ||
result_domain = res.get("domain", False) | ||
direct_refunds_domain = self.get_direct_refunds_domain() | ||
if direct_refunds_domain: | ||
res["domain"] = expression.OR([result_domain, direct_refunds_domain]) | ||
return res | ||
|
||
def button_open_bills(self): | ||
""" | ||
Include direct refunds, those are not linked to the payments | ||
directly | ||
""" | ||
res = super(AccountPayment, self).button_open_bills() | ||
if not res.get("domain", False): | ||
return res | ||
result_domain = res.get("domain", False) | ||
direct_refunds_domain = self.get_direct_refunds_domain() | ||
if direct_refunds_domain: | ||
res["domain"] = expression.OR([result_domain, direct_refunds_domain]) | ||
return res |
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
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
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 test_account_check_report |
Oops, something went wrong.