Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0] [IMP] Show paid amount on move lines for the selected statement line #709

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions account_reconcile_oca/models/account_bank_statement_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class AccountBankStatementLine(models.Model):
_inherit = ["account.bank.statement.line", "account.reconcile.abstract"]

reconcile_data_info = fields.Serialized(inverse="_inverse_reconcile_data_info")
reconciled_move_line_ids = fields.Many2many(
"account.move.line", compute="_compute_reconciled_move_line_ids"
)
reconcile_mode = fields.Selection(
selection=lambda self: self.env["account.journal"]
._fields["reconcile_mode"]
Expand Down Expand Up @@ -128,6 +131,13 @@ class AccountBankStatementLine(models.Model):
aggregate_id = fields.Integer(compute="_compute_reconcile_aggregate")
aggregate_name = fields.Char(compute="_compute_reconcile_aggregate")

@api.depends("reconcile_data_info")
def _compute_reconciled_move_line_ids(self):
for rec in self:
rec.reconciled_move_line_ids = rec.reconcile_data_info.get(
"counterparts", []
)

@api.model
def _reconcile_aggregate_map(self):
lang = self.env["res.lang"]._lang_get(self.env.user.lang)
Expand Down
33 changes: 32 additions & 1 deletion account_reconcile_oca/models/account_move_line.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,45 @@
# Copyright 2023 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, models
from odoo import _, fields, models
from odoo.exceptions import ValidationError


class AccountMoveLine(models.Model):

_inherit = "account.move.line"

paid_amount = fields.Monetary(
compute="_compute_paid_amount",
currency_field="company_currency_id",
)

def _compute_paid_amount(self):
account_bank_statement_line_obj = self.env["account.bank.statement.line"]
for rec in self:
paid_amount = 0.0
st_line = account_bank_statement_line_obj.browse(
self._context.get("bank_statement_line_id")
)
if st_line.is_reconciled:
(

Check warning on line 25 in account_reconcile_oca/models/account_move_line.py

View check run for this annotation

Codecov / codecov/patch

account_reconcile_oca/models/account_move_line.py#L25

Added line #L25 was not covered by tests
_liquidity_lines,
suspense_lines,
_other_lines,
) = st_line._seek_for_lines()
if _other_lines:
paid_amount += sum(
_other_lines.mapped("matched_debit_ids")
.filtered(lambda mdi: mdi.debit_move_id == rec)
.mapped("amount")
)
paid_amount += sum(
_other_lines.mapped("matched_credit_ids")
.filtered(lambda mdi: mdi.credit_move_id == rec)
.mapped("amount")
)
rec.paid_amount = paid_amount

def action_reconcile_manually(self):
if not self:
return {}
Expand Down
10 changes: 10 additions & 0 deletions account_reconcile_oca/views/account_bank_statement_line.xml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,16 @@
context="{'search_default_partner_id': partner_id, 'tree_view_ref': 'account_reconcile_oca.account_move_line_tree_reconcile_view', 'search_view_ref': 'account_reconcile_oca.account_move_line_search_reconcile_view'}"
/>
</page>
<page
name="reconciled_line"
string="Reconciled"
attrs="{'invisible': [('is_reconciled', '=', False)]}"
>
<field
name="reconciled_move_line_ids"
context="{'bank_statement_line_id':id,'search_default_partner_id': partner_id, 'search_default_trade_payable': 1, 'search_default_trade_receivable': 1, 'tree_view_ref': 'account_reconcile_oca.account_move_line_tree_reconcile_view', 'search_view_ref': 'account_reconcile_oca.account_move_line_search_reconcile_view'}"
/>
</page>
<page name="manual" string="Manual operation">
<group>
<group>
Expand Down
1 change: 1 addition & 0 deletions account_reconcile_oca/views/account_move_line.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<field name="name" optional="show" />
<field name="amount_residual_currency" optional="hide" />
<field name="amount_residual" optional="show" />
<field name="paid_amount" />
<field name="debit" optional="hide" />
<field name="credit" optional="hide" />
<button
Expand Down
Loading