Skip to content

Commit

Permalink
[FIX]account_statement_base: add form view for bank statement to pass…
Browse files Browse the repository at this point in the history
… default journal id for bank statement lines and fix compute of internal index for bank statement lines

Removed unwanted field from view
  • Loading branch information
ByteMeAsap committed Apr 9, 2024
1 parent 24e08fb commit 9754d03
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 0 deletions.
1 change: 1 addition & 0 deletions account_statement_base/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
1 change: 1 addition & 0 deletions account_statement_base/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_bank_statement
17 changes: 17 additions & 0 deletions account_statement_base/models/account_bank_statement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 Onestein
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, models


class AccountBankStatement(models.Model):
_inherit = "account.bank.statement"

@api.depends("line_ids.internal_index", "line_ids.state")
def _compute_date_index(self):
for stmt in self:
sorted_lines = stmt.line_ids.filtered(lambda l: l.internal_index).sorted(
"internal_index"
)
stmt.first_line_index = sorted_lines[:1].internal_index
stmt.date = sorted_lines.filtered(lambda l: l.state == "posted")[-1:].date
97 changes: 97 additions & 0 deletions account_statement_base/views/account_bank_statement.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" ?>
<!--
Copyright 2023 Therp BV
Copyright 2024 Onestein
Licence LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0).
-->
<odoo>
Expand All @@ -11,4 +12,100 @@
<field name="view_mode">tree,form,pivot,graph</field>
</record>

<record id="account_bank_statement_form" model="ir.ui.view">
<field name="name">account.bank.statement</field>
<field name="model">account.bank.statement</field>
<field name="arch" type="xml">
<form>
<sheet string="Bank Statement">
<group>
<group>
<field name="name" />
<field name="date" />
<field name="balance_start" />
<field name="balance_end_real" />
<field name="currency_id" />
</group>
<group>
<field name="reference" />
<field name="balance_end" />
<field name="company_id" />
<field name="journal_id" />
</group>
</group>
<notebook>
<page string="Statements">
<field
name="line_ids"
context="{'default_journal_id':journal_id}"
nolabel="1"
>
<tree
decoration-muted="is_reconciled"
editable="top"
multi_edit="1"
>
<field name="sequence" widget="handle" />
<field
name="date"
attrs="{'readonly': [['is_reconciled', '=', True], ['amount', '!=', 0]], 'required': True}"
/>
<field
name="payment_ref"
attrs="{'readonly': [['is_reconciled', '=', True], ['amount', '!=', 0]]}"
/>
<field
name="ref"
optional="hide"
attrs="{'readonly': [['is_reconciled', '=', True], ['amount', '!=', 0]]}"
/>
<field
name="partner_id"
attrs="{'readonly': [['is_reconciled', '=', True], ['amount', '!=', 0]]}"
/>
<field
name="amount"
attrs="{'readonly': [['is_reconciled', '=', True], ['amount', '!=', 0]]}"
/>
<field
name="narration"
optional="hide"
string="Notes"
attrs="{'readonly': [['is_reconciled', '=', True], ['amount', '!=', 0]]}"
/>
<field name="suitable_journal_ids" invisible="1" />
<field name="is_reconciled" invisible="1" />
<field name="statement_id" invisible="1" />
<field name="state" invisible="1" />
<field
name="journal_id"
optional="hide"
attrs="{'readonly': ['|', ['statement_id', '!=', False], ['is_reconciled', '=', True], ['amount', '!=', 0]], 'required': True}"
/>
<field
name="partner_bank_id"
optional="hide"
attrs="{'readonly': [['is_reconciled', '=', True], ['amount', '!=', 0]]}"
/>
<button
name="action_undo_reconciliation"
type="object"
string="Revert reconciliation"
icon="fa-undo"
attrs="{'invisible': [('is_reconciled', '=', False)]}"
/>
<field name="company_id" invisible="1" />
<field name="is_reconciled" invisible="1" />
<field name="currency_id" invisible="1" />
<field name="country_code" invisible="1" />
<field name="state" invisible="1" />
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>

</odoo>

0 comments on commit 9754d03

Please sign in to comment.