[IMP] account: statement management 2.1

In the process of making bank statements optional, the usability of bank statement was reduced.
This PR aims improve that, by providing the ability to view and manage bank statements on the bank reconciliation widget.
See the Enterprise PR.

Task-3270046

Part-of: odoo/odoo#127630
This commit is contained in:
Habib (ayh)
2023-07-12 16:52:58 +02:00
parent 42e5e247bf
commit 9299f81f19
5 changed files with 37 additions and 15 deletions
@@ -13,6 +13,7 @@ class AccountBankStatement(models.Model):
name = fields.Char(
string='Reference',
compute='_compute_name', store=True, readonly=False,
copy=False,
)
@@ -104,6 +105,12 @@ class AccountBankStatement(models.Model):
# -------------------------------------------------------------------------
# COMPUTE METHODS
# -------------------------------------------------------------------------
@api.depends('create_date')
def _compute_name(self):
for stmt in self:
stmt.name = _("%s Statement %s", stmt.journal_id.code, stmt.date)
@api.depends('line_ids.internal_index', 'line_ids.state')
def _compute_date_index(self):
for stmt in self:
@@ -140,6 +140,13 @@ class AccountBankStatementLine(models.Model):
statement_valid = fields.Boolean(
related='statement_id.is_valid',
)
statement_balance_end_real = fields.Monetary(
related='statement_id.balance_end_real',
)
statement_name = fields.Char(
string="Statement Name",
related='statement_id.name',
)
# Technical field to store details about the bank statement line
transaction_details = fields.Json(readonly=True)
@@ -378,6 +378,7 @@ class account_journal(models.Model):
'outstanding_pay_account_balance': currency.format(outstanding_pay_account_balance),
'nb_lines_outstanding_pay_account_balance': has_outstanding,
'last_balance': currency.format(last_statement.balance_end_real),
'last_statement_id': last_statement.id,
'bank_statements_source': journal.bank_statements_source,
'is_sample_data': journal.has_statement_lines,
})
@@ -241,7 +241,7 @@
<!-- On the left, display :
- A button corresponding to the bank_statements_source, if it wasn't configured, a button for each of them
- If there are statements to reconcile, a link to reconcile them -->
<div id="dashboard_bank_cash_left" class="col-12 col-sm-6 mb-3 mb-sm-0 o_kanban_primary_left">
<div id="dashboard_bank_cash_left" class="col-12 col-sm-5 mb-3 mb-sm-0 o_kanban_primary_left">
<t t-if="journal_type == 'bank'">
<t t-if="dashboard.bank_statements_source == 'undefined' or dashboard.bank_statements_source == 'online_sync'">
<button name="action_configure_bank_journal" type="object" class="btn btn-primary" groups="account.group_account_invoice">Connect</button>
@@ -249,44 +249,44 @@
<div id="transactions" class="d-flex mt-3 mt-sm-0" style="gap: 5px;">
<div name="bank_journal_cta" class="w-100">
<div name="bank_journal_transactions" class="w-100 d-flex" style="gap: 5px;">
<a id="create_transaction" name="action_new_transaction" type="object" groups="account.group_account_invoice">Create</a>
<a id="create_transaction" name="action_new_transaction" type="object" groups="account.group_account_invoice">New Transaction</a>
</div>
</div>
</div>
</t>
<t t-if="journal_type == 'cash'">
<a t-if="dashboard.number_to_reconcile > 0" type="object" name="create_cash_statement" class="oe_inline" groups="account.group_account_invoice">New Transaction</a>
<button t-if="dashboard.number_to_reconcile == 0" type="object" name="create_cash_statement" class="btn btn-primary" groups="account.group_account_invoice">New Transaction</button>
<button t-if="dashboard.number_to_reconcile == 0" type="object" name="action_new_transaction" class="btn btn-primary" groups="account.group_account_invoice">New Transaction</button>
<a t-if="dashboard.number_to_reconcile > 0" type="object" name="action_new_transaction" class="oe_inline" groups="account.group_account_invoice">New Transaction</a>
</t>
</div>
<!-- On the right, show other common informations/actions -->
<div id="dashboard_bank_cash_right" class="col-12 col-sm-6 o_kanban_primary_right">
<div id="dashboard_bank_cash_right" class="col-12 col-sm-7 o_kanban_primary_right">
<div class="row" t-if="dashboard.nb_lines_bank_account_balance > 0">
<div id="dashboard_bank_cash_balance" class="col overflow-hidden text-start">
<span>Running Balance</span>
<span>Balance</span>
</div>
<div class="col-auto text-end">
<span><t t-out="dashboard.account_balance"/></span>
</div>
</div>
<div class="row" t-if="dashboard.nb_lines_outstanding_pay_account_balance > 0">
<div id="dashboard_bank_cash_outstanding_balance" class="col overflow-hidden text-start">
<span title="Outstanding Payments/Receipts">Outstanding Payments/Receipts</span>
</div>
<div class="col-auto text-end">
<span><t t-out="dashboard.outstanding_pay_account_balance"/></span>
</div>
</div>
<t t-if="dashboard.has_at_least_one_statement and dashboard.account_balance != dashboard.last_balance">
<div class="row" name="latest_statement">
<div class="col overflow-hidden text-start">
<span title="Latest Statement">Latest Statement</span>
<span title="Latest Statement">Last Statement</span>
</div>
<div class="col-auto text-end">
<span><t t-out="dashboard.last_balance"/></span>
</div>
</div>
</t>
<div class="row" t-if="dashboard.nb_lines_outstanding_pay_account_balance > 0">
<div id="dashboard_bank_cash_outstanding_balance" class="col overflow-hidden text-start">
<span title="Outstanding Payments/Receipts">Payments</span>
</div>
<div class="col-auto text-end">
<span><t t-out="dashboard.outstanding_pay_account_balance"/></span>
</div>
</div>
</div>
</t>
<t t-name="JournalBodySalePurchase" id="account.JournalBodySalePurchase">
@@ -351,6 +351,13 @@
<!-- ACTIONS -->
<record id="action_account_all_payments" model="ir.actions.act_window">
<field name="name">Payments</field>
<field name="res_model">account.payment</field>
<field name="view_mode">tree,kanban,form,graph,activity</field>
<field name="view_id" ref="view_account_payment_tree"/>
</record>
<record id="action_account_payments" model="ir.actions.act_window">
<field name="name">Customer Payments</field>
<field name="res_model">account.payment</field>