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)]