From 67b97d324e8c5a5d8560f1f7b164d829e957e7a3 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Sat, 20 Apr 2024 23:48:56 +0200 Subject: [PATCH 1/8] [FIX] account_reconcile_oca: Fix kanban record division --- account_reconcile_oca/static/src/scss/reconcile.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/account_reconcile_oca/static/src/scss/reconcile.scss b/account_reconcile_oca/static/src/scss/reconcile.scss index bd33d4c2..d9e56f37 100644 --- a/account_reconcile_oca/static/src/scss/reconcile.scss +++ b/account_reconcile_oca/static/src/scss/reconcile.scss @@ -7,6 +7,8 @@ height: 100%; .o_kanban_renderer.o_kanban_ungrouped .o_kanban_record { margin: 0 0 0; + min-width: fit-content; + width: 100%; > div { border-right: thick solid rgba(0, 0, 0, 0); } From 8f983803b034fe57afc6f97b47e6c5e941fbe496 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Sun, 21 Apr 2024 02:09:20 +0200 Subject: [PATCH 2/8] [IMP] account_reconcile_oca: Add balance --- .../models/account_journal.py | 1 + .../js/reconcile/reconcile_controller.esm.js | 43 ++++++++++++++++++- .../js/reconcile/reconcile_renderer.esm.js | 6 ++- .../reconcile_form_controller.esm.js | 3 ++ .../js/widgets/reconcile_data_widget.esm.js | 2 - .../static/src/xml/reconcile.xml | 11 +++++ .../views/account_bank_statement_line.xml | 2 +- 7 files changed, 63 insertions(+), 5 deletions(-) diff --git a/account_reconcile_oca/models/account_journal.py b/account_reconcile_oca/models/account_journal.py index 613ab41a..cc46d5ad 100644 --- a/account_reconcile_oca/models/account_journal.py +++ b/account_reconcile_oca/models/account_journal.py @@ -12,6 +12,7 @@ class AccountJournal(models.Model): default="edit", required=True, ) + company_currency_id = fields.Many2one(related="company_id.currency_id") def get_rainbowman_message(self): self.ensure_one() diff --git a/account_reconcile_oca/static/src/js/reconcile/reconcile_controller.esm.js b/account_reconcile_oca/static/src/js/reconcile/reconcile_controller.esm.js index 801f233f..2f0774c7 100644 --- a/account_reconcile_oca/static/src/js/reconcile/reconcile_controller.esm.js +++ b/account_reconcile_oca/static/src/js/reconcile/reconcile_controller.esm.js @@ -1,7 +1,8 @@ /** @odoo-module */ -const {useState, useSubEnv} = owl; +const {onMounted, onWillStart, useState, useSubEnv} = owl; import {KanbanController} from "@web/views/kanban/kanban_controller"; import {View} from "@web/views/view"; +import {formatMonetary} from "@web/views/fields/formatters"; import {useService} from "@web/core/utils/hooks"; export class ReconcileController extends KanbanController { @@ -9,6 +10,8 @@ export class ReconcileController extends KanbanController { super.setup(); this.state = useState({ selectedRecordId: null, + journalBalance: 0, + currency: false, }); useSubEnv({ parentController: this, @@ -20,6 +23,43 @@ export class ReconcileController extends KanbanController { this.router = useService("router"); this.activeActions = this.props.archInfo.activeActions; this.model.addEventListener("update", () => this.selectRecord(), {once: true}); + onWillStart(() => { + this.updateJournalInfo(); + }); + onMounted(() => { + this.selectRecord(); + }); + } + get journalId() { + if (this.props.resModel === "account.bank.statement.line") { + return this.props.context.active_id; + } + return false; + } + async updateJournalInfo() { + var journalId = this.journalId; + if (!journalId) { + return; + } + var result = await this.orm.call("account.journal", "read", [ + [journalId], + ["current_statement_balance", "currency_id", "company_currency_id"], + ]); + this.state.journalBalance = result[0].current_statement_balance; + this.state.currency = (result[0].currency_id || + result[0].company_currency_id)[0]; + } + get journalBalanceStr() { + if (!this.state.journalBalance) { + return ""; + } + console.log(this.state, { + currencyId: this.state.currency, + humanReadable: true, + }); + return formatMonetary(this.state.journalBalance, { + currencyId: this.state.currency, + }); } exposeController(controller) { this.form_controller = controller; @@ -45,6 +85,7 @@ export class ReconcileController extends KanbanController { return { resId: this.state.selectedRecordId, type: "form", + noBreadcrumbs: true, context: { ...(this.props.context || {}), form_view_ref: this.props.context.view_ref, diff --git a/account_reconcile_oca/static/src/js/reconcile/reconcile_renderer.esm.js b/account_reconcile_oca/static/src/js/reconcile/reconcile_renderer.esm.js index d031e2bc..3dafa4ec 100644 --- a/account_reconcile_oca/static/src/js/reconcile/reconcile_renderer.esm.js +++ b/account_reconcile_oca/static/src/js/reconcile/reconcile_renderer.esm.js @@ -2,7 +2,11 @@ import {KanbanRenderer} from "@web/views/kanban/kanban_renderer"; import {ReconcileKanbanRecord} from "./reconcile_kanban_record.esm.js"; -export class ReconcileRenderer extends KanbanRenderer {} +export class ReconcileRenderer extends KanbanRenderer { + get journalBalanceStr() { + console.log(this); + } +} ReconcileRenderer.components = { ...KanbanRenderer.components, diff --git a/account_reconcile_oca/static/src/js/reconcile_form/reconcile_form_controller.esm.js b/account_reconcile_oca/static/src/js/reconcile_form/reconcile_form_controller.esm.js index 571b4673..d91b4bda 100644 --- a/account_reconcile_oca/static/src/js/reconcile_form/reconcile_form_controller.esm.js +++ b/account_reconcile_oca/static/src/js/reconcile_form/reconcile_form_controller.esm.js @@ -17,6 +17,9 @@ export class ReconcileFormController extends FormController { afterExecuteAction: this.afterExecuteActionButton.bind(this), }); } + displayName() { + return this.env.config.getDisplayName(); + } async reloadFormController() { var is_reconciled = this.model.root.data.is_reconciled; await this.model.root.load(); diff --git a/account_reconcile_oca/static/src/js/widgets/reconcile_data_widget.esm.js b/account_reconcile_oca/static/src/js/widgets/reconcile_data_widget.esm.js index 0f64280b..66adf0e4 100644 --- a/account_reconcile_oca/static/src/js/widgets/reconcile_data_widget.esm.js +++ b/account_reconcile_oca/static/src/js/widgets/reconcile_data_widget.esm.js @@ -45,7 +45,6 @@ export class AccountReconcileDataWidget extends Component { ); data[line].amount_currency_format = fieldUtils.format.monetary( data[line].currency_amount, - undefined, { currency: session.get_currency(data[line].line_currency_id), } @@ -53,7 +52,6 @@ export class AccountReconcileDataWidget extends Component { if (data[line].original_amount) { data[line].original_amount_format = fieldUtils.format.monetary( data[line].original_amount, - undefined, { currency: session.get_currency(data[line].currency_id), } diff --git a/account_reconcile_oca/static/src/xml/reconcile.xml b/account_reconcile_oca/static/src/xml/reconcile.xml index 574678e1..77c585ab 100644 --- a/account_reconcile_oca/static/src/xml/reconcile.xml +++ b/account_reconcile_oca/static/src/xml/reconcile.xml @@ -6,6 +6,17 @@ t-inherit-mode="primary" owl="1" > + +
+ Balance + +
+
- Reconcile bank statement lines + Statement lines account.bank.statement.line [('journal_id', '=', active_id)] Date: Sun, 21 Apr 2024 15:05:15 +0200 Subject: [PATCH 3/8] [IMP] account_reconcile_oca: show balances --- .../js/reconcile/reconcile_controller.esm.js | 4 --- .../js/reconcile/reconcile_renderer.esm.js | 31 +++++++++++++++++-- .../static/src/xml/reconcile.xml | 18 +++++++++++ .../views/account_bank_statement_line.xml | 3 ++ 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/account_reconcile_oca/static/src/js/reconcile/reconcile_controller.esm.js b/account_reconcile_oca/static/src/js/reconcile/reconcile_controller.esm.js index 2f0774c7..9c83aa86 100644 --- a/account_reconcile_oca/static/src/js/reconcile/reconcile_controller.esm.js +++ b/account_reconcile_oca/static/src/js/reconcile/reconcile_controller.esm.js @@ -53,10 +53,6 @@ export class ReconcileController extends KanbanController { if (!this.state.journalBalance) { return ""; } - console.log(this.state, { - currencyId: this.state.currency, - humanReadable: true, - }); return formatMonetary(this.state.journalBalance, { currencyId: this.state.currency, }); diff --git a/account_reconcile_oca/static/src/js/reconcile/reconcile_renderer.esm.js b/account_reconcile_oca/static/src/js/reconcile/reconcile_renderer.esm.js index 3dafa4ec..7bf47166 100644 --- a/account_reconcile_oca/static/src/js/reconcile/reconcile_renderer.esm.js +++ b/account_reconcile_oca/static/src/js/reconcile/reconcile_renderer.esm.js @@ -2,9 +2,36 @@ import {KanbanRenderer} from "@web/views/kanban/kanban_renderer"; import {ReconcileKanbanRecord} from "./reconcile_kanban_record.esm.js"; +import {formatMonetary} from "@web/views/fields/formatters"; + export class ReconcileRenderer extends KanbanRenderer { - get journalBalanceStr() { - console.log(this); + getStatements() { + console.log(this.props); + if ( + this.env.parentController.props.resModel !== "account.bank.statement.line" + ) { + return []; + } + const {list} = this.props; + const statements = []; + for (const record of list.records) { + const statementId = record.data.statement_id && record.data.statement_id[0]; + if ( + statementId && + (!statements.length || statements[0].id !== statementId) + ) { + statements.push({ + id: statementId, + name: record.data.statement_name, + balance: record.data.statement_balance_end_real, + balanceStr: formatMonetary(record.data.statement_balance_end_real, { + currencyId: record.data.currency_id[0], + }), + }); + } + } + console.log(statements); + return statements; } } diff --git a/account_reconcile_oca/static/src/xml/reconcile.xml b/account_reconcile_oca/static/src/xml/reconcile.xml index 77c585ab..9ef6a4a7 100644 --- a/account_reconcile_oca/static/src/xml/reconcile.xml +++ b/account_reconcile_oca/static/src/xml/reconcile.xml @@ -16,6 +16,24 @@ t-esc="env.parentController.journalBalanceStr" /> + + + + + +
+ + +
+
+ + + From 4221bc74447528f1057319422209f30933c0ad26 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Sun, 21 Apr 2024 23:22:31 +0200 Subject: [PATCH 4/8] [IMP] account_reconcile_oca: Add statements information --- account_reconcile_oca/__manifest__.py | 1 + account_reconcile_oca/models/__init__.py | 1 + .../models/account_bank_statement.py | 16 +++++++ .../js/reconcile/reconcile_renderer.esm.js | 24 +++++++++- .../static/src/xml/reconcile.xml | 3 +- .../views/account_bank_statement.xml | 45 +++++++++++++++++++ 6 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 account_reconcile_oca/models/account_bank_statement.py create mode 100644 account_reconcile_oca/views/account_bank_statement.xml diff --git a/account_reconcile_oca/__manifest__.py b/account_reconcile_oca/__manifest__.py index 678edcf9..fe80e84f 100644 --- a/account_reconcile_oca/__manifest__.py +++ b/account_reconcile_oca/__manifest__.py @@ -22,6 +22,7 @@ "views/account_journal.xml", "views/account_move.xml", "views/account_account.xml", + "views/account_bank_statement.xml", ], "demo": ["demo/demo.xml"], "post_init_hook": "post_init_hook", diff --git a/account_reconcile_oca/models/__init__.py b/account_reconcile_oca/models/__init__.py index 5be31a27..7845dccd 100644 --- a/account_reconcile_oca/models/__init__.py +++ b/account_reconcile_oca/models/__init__.py @@ -1,5 +1,6 @@ from . import account_reconcile_abstract from . import account_journal from . import account_bank_statement_line +from . import account_bank_statement from . import account_account_reconcile from . import account_move_line diff --git a/account_reconcile_oca/models/account_bank_statement.py b/account_reconcile_oca/models/account_bank_statement.py new file mode 100644 index 00000000..52a64a2f --- /dev/null +++ b/account_reconcile_oca/models/account_bank_statement.py @@ -0,0 +1,16 @@ +# Copyright 2024 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import models + + +class AccountBankStatement(models.Model): + _inherit = "account.bank.statement" + + def action_open_statement(self): + self.ensure_one() + action = self.env["ir.actions.act_window"]._for_xml_id( + "account_reconcile_oca.account_bank_statement_action_edit" + ) + print(action) + action["res_id"] = self.id + return action diff --git a/account_reconcile_oca/static/src/js/reconcile/reconcile_renderer.esm.js b/account_reconcile_oca/static/src/js/reconcile/reconcile_renderer.esm.js index 7bf47166..552de9ba 100644 --- a/account_reconcile_oca/static/src/js/reconcile/reconcile_renderer.esm.js +++ b/account_reconcile_oca/static/src/js/reconcile/reconcile_renderer.esm.js @@ -3,10 +3,15 @@ import {KanbanRenderer} from "@web/views/kanban/kanban_renderer"; import {ReconcileKanbanRecord} from "./reconcile_kanban_record.esm.js"; import {formatMonetary} from "@web/views/fields/formatters"; +import {useService} from "@web/core/utils/hooks"; export class ReconcileRenderer extends KanbanRenderer { + setup() { + super.setup(); + this.action = useService("action"); + this.orm = useService("orm"); + } getStatements() { - console.log(this.props); if ( this.env.parentController.props.resModel !== "account.bank.statement.line" ) { @@ -30,9 +35,24 @@ export class ReconcileRenderer extends KanbanRenderer { }); } } - console.log(statements); return statements; } + async onClickStatement(statementId) { + const action = await this.orm.call( + "account.bank.statement", + "action_open_statement", + [[statementId]], + { + context: this.props.context, + } + ); + const model = this.props.list.model; + this.action.doAction(action, { + async onClose() { + model.root.load(); + }, + }); + } } ReconcileRenderer.components = { diff --git a/account_reconcile_oca/static/src/xml/reconcile.xml b/account_reconcile_oca/static/src/xml/reconcile.xml index 9ef6a4a7..8e9043f6 100644 --- a/account_reconcile_oca/static/src/xml/reconcile.xml +++ b/account_reconcile_oca/static/src/xml/reconcile.xml @@ -29,7 +29,8 @@ t-esc="statement.name" /> diff --git a/account_reconcile_oca/views/account_bank_statement.xml b/account_reconcile_oca/views/account_bank_statement.xml new file mode 100644 index 00000000..d081b50b --- /dev/null +++ b/account_reconcile_oca/views/account_bank_statement.xml @@ -0,0 +1,45 @@ + + + + + + Edit Bank statement + account.bank.statement + 99 + +
+ + + + + + + + + + +
+
+
+ + + Edit Bank Statement + account.bank.statement + form + + new + +
From 84bab61b6f2e5e802ffb02661a378d7071c568d8 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Wed, 29 May 2024 12:03:04 +0200 Subject: [PATCH 5/8] [IMP] account_reconcile_oca: Add missing fields necessary --- .../models/account_bank_statement_line.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/account_reconcile_oca/models/account_bank_statement_line.py b/account_reconcile_oca/models/account_bank_statement_line.py index f3584b35..1d855e65 100644 --- a/account_reconcile_oca/models/account_bank_statement_line.py +++ b/account_reconcile_oca/models/account_bank_statement_line.py @@ -86,6 +86,19 @@ class AccountBankStatementLine(models.Model): "account.move", default=False, store=False, prefetch=False, readonly=True ) can_reconcile = fields.Boolean(sparse="reconcile_data_info") + statement_complete = fields.Boolean( + related="statement_id.is_complete", + ) + 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", + ) def save(self): return {"type": "ir.actions.act_window_close"} From 04fea1e2c42ec847967361060213cff63f4d3d74 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Sun, 21 Apr 2024 23:55:05 +0200 Subject: [PATCH 6/8] [IMP] account_reconcile_oca: Allow to define the statement directly --- .../models/account_bank_statement.py | 1 - .../models/account_bank_statement_line.py | 22 +++++++++++++++++++ .../static/src/scss/reconcile.scss | 14 ++++++++++++ .../views/account_bank_statement.xml | 1 + .../views/account_bank_statement_line.xml | 14 ++++++++++++ 5 files changed, 51 insertions(+), 1 deletion(-) diff --git a/account_reconcile_oca/models/account_bank_statement.py b/account_reconcile_oca/models/account_bank_statement.py index 52a64a2f..19b9bec1 100644 --- a/account_reconcile_oca/models/account_bank_statement.py +++ b/account_reconcile_oca/models/account_bank_statement.py @@ -11,6 +11,5 @@ class AccountBankStatement(models.Model): action = self.env["ir.actions.act_window"]._for_xml_id( "account_reconcile_oca.account_bank_statement_action_edit" ) - print(action) action["res_id"] = self.id return action diff --git a/account_reconcile_oca/models/account_bank_statement_line.py b/account_reconcile_oca/models/account_bank_statement_line.py index 1d855e65..e8bb36e2 100644 --- a/account_reconcile_oca/models/account_bank_statement_line.py +++ b/account_reconcile_oca/models/account_bank_statement_line.py @@ -765,3 +765,25 @@ class AccountBankStatementLine(models.Model): if vals["partner_id"] is False: vals["partner_id"] = (False, self.partner_name) return vals + + def add_statement(self): + self.ensure_one() + action = self.env["ir.actions.act_window"]._for_xml_id( + "account_reconcile_oca.account_bank_statement_action_edit" + ) + previous_line_with_statement = self.env["account.bank.statement.line"].search( + [ + ("internal_index", "<", self.internal_index), + ("journal_id", "=", self.journal_id.id), + ("state", "=", "posted"), + ("statement_id", "!=", self.statement_id.id), + ("statement_id", "!=", False), + ], + limit=1, + ) + action["context"] = { + "default_journal_id": self.journal_id.id, + "default_balance_start": previous_line_with_statement.statement_id.balance_end_real, + "split_line_id": self.id, + } + return action diff --git a/account_reconcile_oca/static/src/scss/reconcile.scss b/account_reconcile_oca/static/src/scss/reconcile.scss index d9e56f37..c7186814 100644 --- a/account_reconcile_oca/static/src/scss/reconcile.scss +++ b/account_reconcile_oca/static/src/scss/reconcile.scss @@ -6,9 +6,23 @@ flex-flow: row wrap; height: 100%; .o_kanban_renderer.o_kanban_ungrouped .o_kanban_record { + &:hover { + .o_reconcile_create_statement { + opacity: 100; + } + } margin: 0 0 0; min-width: fit-content; width: 100%; + .o_reconcile_create_statement { + position: absolute; + height: 4px; + margin: 0; + padding: 2px 0 0 0; + border: 0; + top: -14px; + opacity: 0; + } > div { border-right: thick solid rgba(0, 0, 0, 0); } diff --git a/account_reconcile_oca/views/account_bank_statement.xml b/account_reconcile_oca/views/account_bank_statement.xml index d081b50b..ac615d7f 100644 --- a/account_reconcile_oca/views/account_bank_statement.xml +++ b/account_reconcile_oca/views/account_bank_statement.xml @@ -24,6 +24,7 @@ + diff --git a/account_reconcile_oca/views/account_bank_statement_line.xml b/account_reconcile_oca/views/account_bank_statement_line.xml index 2000f8c2..382c22e7 100644 --- a/account_reconcile_oca/views/account_bank_statement_line.xml +++ b/account_reconcile_oca/views/account_bank_statement_line.xml @@ -17,6 +17,20 @@ +
Date: Wed, 29 May 2024 12:15:30 +0200 Subject: [PATCH 7/8] [FIX] account_reconcile_oca: orser of statements on list --- .../static/src/js/reconcile/reconcile_renderer.esm.js | 6 ++++-- account_reconcile_oca/views/account_bank_statement.xml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/account_reconcile_oca/static/src/js/reconcile/reconcile_renderer.esm.js b/account_reconcile_oca/static/src/js/reconcile/reconcile_renderer.esm.js index 552de9ba..b3c0cfe6 100644 --- a/account_reconcile_oca/static/src/js/reconcile/reconcile_renderer.esm.js +++ b/account_reconcile_oca/static/src/js/reconcile/reconcile_renderer.esm.js @@ -20,10 +20,11 @@ export class ReconcileRenderer extends KanbanRenderer { const {list} = this.props; const statements = []; for (const record of list.records) { - const statementId = record.data.statement_id && record.data.statement_id[0]; + var statementId = record.data.statement_id && record.data.statement_id[0]; if ( statementId && - (!statements.length || statements[0].id !== statementId) + (!statements.length || + statements[statements.length - 1].id !== statementId) ) { statements.push({ id: statementId, @@ -35,6 +36,7 @@ export class ReconcileRenderer extends KanbanRenderer { }); } } + console.log(statements); return statements; } async onClickStatement(statementId) { diff --git a/account_reconcile_oca/views/account_bank_statement.xml b/account_reconcile_oca/views/account_bank_statement.xml index ac615d7f..c3e1e0d0 100644 --- a/account_reconcile_oca/views/account_bank_statement.xml +++ b/account_reconcile_oca/views/account_bank_statement.xml @@ -12,7 +12,7 @@