From 103a4c506b294e3d8d2dabab40229f42da6d28db Mon Sep 17 00:00:00 2001 From: Henrik Norlin Date: Sat, 3 Feb 2024 22:53:35 +0100 Subject: [PATCH] [MIG] account_reconcile_oca: Migration to 17.0 --- account_reconcile_oca/__manifest__.py | 2 +- account_reconcile_oca/hooks.py | 4 +- .../migrations/16.0.1.2.0/pre-migration.py | 19 ------- .../models/account_account_reconcile.py | 2 +- .../models/account_bank_statement_line.py | 18 +++---- .../models/account_reconcile_abstract.py | 4 +- .../js/widgets/reconcile_chatter_field.esm.js | 5 +- .../js/widgets/reconcile_data_widget.esm.js | 43 ++++++--------- .../static/src/xml/reconcile.xml | 11 ++-- .../tests/test_bank_account_reconcile.py | 34 ++++++------ .../views/account_account.xml | 6 +-- .../views/account_account_reconcile.xml | 10 ++-- .../views/account_bank_statement_line.xml | 53 ++++++++++--------- .../views/account_journal.xml | 9 ++-- account_reconcile_oca/views/account_move.xml | 2 +- 15 files changed, 95 insertions(+), 127 deletions(-) delete mode 100644 account_reconcile_oca/migrations/16.0.1.2.0/pre-migration.py diff --git a/account_reconcile_oca/__manifest__.py b/account_reconcile_oca/__manifest__.py index a84bda68..44a4e7f9 100644 --- a/account_reconcile_oca/__manifest__.py +++ b/account_reconcile_oca/__manifest__.py @@ -5,7 +5,7 @@ "name": "Account Reconcile Oca", "summary": """ Reconcile addons for Odoo CE accounting""", - "version": "16.0.1.2.7", + "version": "17.0.1.0.0", "license": "AGPL-3", "author": "CreuBlanca,Dixmit,Odoo Community Association (OCA)", "maintainers": ["etobella"], diff --git a/account_reconcile_oca/hooks.py b/account_reconcile_oca/hooks.py index dd1094eb..ce21fab5 100644 --- a/account_reconcile_oca/hooks.py +++ b/account_reconcile_oca/hooks.py @@ -1,5 +1,5 @@ -def post_init_hook(cr, registry): - cr.execute( +def post_init_hook(env): + env.cr.execute( """ UPDATE account_bank_statement_line SET reconcile_mode = 'edit' diff --git a/account_reconcile_oca/migrations/16.0.1.2.0/pre-migration.py b/account_reconcile_oca/migrations/16.0.1.2.0/pre-migration.py deleted file mode 100644 index 4150d2ac..00000000 --- a/account_reconcile_oca/migrations/16.0.1.2.0/pre-migration.py +++ /dev/null @@ -1,19 +0,0 @@ -from openupgradelib import openupgrade - - -@openupgrade.migrate() -def migrate(env, version): - # Due to the big change we did, we need to loose how data is stored - openupgrade.logged_query( - env.cr, - """ - UPDATE account_bank_statement_line - SET reconcile_data = NULL - """, - ) - openupgrade.logged_query( - env.cr, - """ - DELETE FROM account_account_reconcile_data - """, - ) diff --git a/account_reconcile_oca/models/account_account_reconcile.py b/account_reconcile_oca/models/account_account_reconcile.py index fe977dcc..9c8d1540 100644 --- a/account_reconcile_oca/models/account_account_reconcile.py +++ b/account_reconcile_oca/models/account_account_reconcile.py @@ -24,7 +24,7 @@ class AccountAccountReconcile(models.Model): @property def _table_query(self): - return "%s %s %s %s %s" % ( + return "{} {} {} {} {}".format( self._select(), self._from(), self._where(), diff --git a/account_reconcile_oca/models/account_bank_statement_line.py b/account_reconcile_oca/models/account_bank_statement_line.py index 9a524b83..201b680e 100644 --- a/account_reconcile_oca/models/account_bank_statement_line.py +++ b/account_reconcile_oca/models/account_bank_statement_line.py @@ -186,9 +186,9 @@ class AccountBankStatementLine(models.Model): suspense_line = { "reference": "reconcile_auxiliary;%s" % reconcile_auxiliary_id, "id": False, - "account_id": self.journal_id.suspense_account_id.name_get()[0], + "account_id": self.journal_id.suspense_account_id.display_name, "partner_id": self.partner_id - and self.partner_id.name_get()[0] + and self.partner_id.display_name or (False, self.partner_name), "date": fields.Date.to_string(self.date), "name": self.payment_ref or self.name, @@ -218,9 +218,7 @@ class AccountBankStatementLine(models.Model): ) or self.manual_account_id.id != line["account_id"][0] or self.manual_name != line["name"] - or ( - self.manual_partner_id and self.manual_partner_id.name_get()[0] or False - ) + or (self.manual_partner_id and self.manual_partner_id.display_name or False) != line.get("partner_id") ) @@ -291,9 +289,9 @@ class AccountBankStatementLine(models.Model): { "name": self.manual_name, "partner_id": self.manual_partner_id - and self.manual_partner_id.name_get()[0] + and self.manual_partner_id.display_name or (False, self.partner_name), - "account_id": self.manual_account_id.name_get()[0] + "account_id": self.manual_account_id.display_name if self.manual_account_id else [False, _("Undefined")], "amount": self.manual_amount, @@ -378,7 +376,7 @@ class AccountBankStatementLine(models.Model): "kind": "other", "account_id": self.env["account.account"] .browse(line["account_id"]) - .name_get()[0], + .display_name, "date": fields.Date.to_string(self.date), "line_currency_id": self.company_id.currency_id.id, "currency_id": self.company_id.currency_id.id, @@ -388,7 +386,7 @@ class AccountBankStatementLine(models.Model): reconcile_auxiliary_id += 1 if line.get("partner_id"): new_line["partner_id"] = ( - self.env["res.partner"].browse(line["partner_id"]).name_get()[0] + self.env["res.partner"].browse(line["partner_id"]).display_name ) new_data.append(new_line) return new_data, reconcile_auxiliary_id @@ -411,7 +409,7 @@ class AccountBankStatementLine(models.Model): { "reference": "reconcile_auxiliary;%s" % reconcile_auxiliary_id, "id": False, - "account_id": account.name_get()[0], + "account_id": account.display_name, "partner_id": False, "date": fields.Date.to_string(self.date), "name": self.payment_ref or self.name, diff --git a/account_reconcile_oca/models/account_reconcile_abstract.py b/account_reconcile_oca/models/account_reconcile_abstract.py index f07f9d6e..d5a83f06 100644 --- a/account_reconcile_oca/models/account_reconcile_abstract.py +++ b/account_reconcile_oca/models/account_reconcile_abstract.py @@ -68,8 +68,8 @@ class AccountReconcileAbstract(models.AbstractModel): vals = { "reference": "account.move.line;%s" % line.id, "id": line.id, - "account_id": line.account_id.name_get()[0], - "partner_id": line.partner_id and line.partner_id.name_get()[0] or False, + "account_id": line.account_id.display_name, + "partner_id": line.partner_id and line.partner_id.display_name or False, "date": fields.Date.to_string(line.date), "name": line.name, "debit": amount if amount > 0 else 0.0, diff --git a/account_reconcile_oca/static/src/js/widgets/reconcile_chatter_field.esm.js b/account_reconcile_oca/static/src/js/widgets/reconcile_chatter_field.esm.js index e53a0b09..2e481485 100644 --- a/account_reconcile_oca/static/src/js/widgets/reconcile_chatter_field.esm.js +++ b/account_reconcile_oca/static/src/js/widgets/reconcile_chatter_field.esm.js @@ -1,6 +1,7 @@ /** @odoo-module **/ -import {ChatterContainer} from "@mail/components/chatter_container/chatter_container"; +// import {ChatterContainer} from "@mail/components/chatter_container/chatter_container"; +// import {Chatter} from "@mail/core/web/chatter"; import {registry} from "@web/core/registry"; const {Component} = owl; @@ -8,7 +9,7 @@ const {Component} = owl; export class AccountReconcileChatterWidget extends Component {} AccountReconcileChatterWidget.template = "account_reconcile_oca.AccountReconcileChatterWidget"; -AccountReconcileChatterWidget.components = {...Component.components, ChatterContainer}; +// AccountReconcileChatterWidget.components = {...Component.components, ChatterContainer}; registry .category("fields") 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..932b3911 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 @@ -1,8 +1,9 @@ /** @odoo-module **/ -import fieldUtils from "web.field_utils"; +import {formatDate, formatMonetary} from "@web/views/fields/formatters"; +import {parseDate} from "@web/core/l10n/dates"; import {registry} from "@web/core/registry"; -import session from "web.session"; +import {session} from "@web/session"; const {Component} = owl; @@ -22,28 +23,16 @@ export class AccountReconcileDataWidget extends Component { getReconcileLines() { var data = this.props.record.data[this.props.name].data; for (var line in data) { - data[line].amount_format = fieldUtils.format.monetary( - data[line].amount, - undefined, - { - currency: session.get_currency(data[line].currency_id), - } - ); - data[line].debit_format = fieldUtils.format.monetary( - data[line].debit, - undefined, - { - currency: session.get_currency(data[line].currency_id), - } - ); - data[line].credit_format = fieldUtils.format.monetary( - data[line].credit, - undefined, - { - currency: session.get_currency(data[line].currency_id), - } - ); - data[line].amount_currency_format = fieldUtils.format.monetary( + data[line].amount_format = formatMonetary(data[line].amount, undefined, { + currency: session.get_currency(data[line].currency_id), + }); + data[line].debit_format = formatMonetary(data[line].debit, undefined, { + currency: session.get_currency(data[line].currency_id), + }); + data[line].credit_format = formatMonetary(data[line].credit, undefined, { + currency: session.get_currency(data[line].currency_id), + }); + data[line].amount_currency_format = formatMonetary( data[line].currency_amount, undefined, { @@ -51,7 +40,7 @@ export class AccountReconcileDataWidget extends Component { } ); if (data[line].original_amount) { - data[line].original_amount_format = fieldUtils.format.monetary( + data[line].original_amount_format = formatMonetary( data[line].original_amount, undefined, { @@ -59,8 +48,8 @@ export class AccountReconcileDataWidget extends Component { } ); } - data[line].date_format = fieldUtils.format.date( - fieldUtils.parse.date(data[line].date, undefined, {isUTC: true}) + data[line].date_format = formatDate( + parseDate(data[line].date, undefined, {isUTC: true}) ); } return data; diff --git a/account_reconcile_oca/static/src/xml/reconcile.xml b/account_reconcile_oca/static/src/xml/reconcile.xml index 6693baad..43af10d1 100644 --- a/account_reconcile_oca/static/src/xml/reconcile.xml +++ b/account_reconcile_oca/static/src/xml/reconcile.xml @@ -4,7 +4,6 @@ t-name="account_reconcile_oca.ReconcileRenderer" t-inherit="web.KanbanRenderer" t-inherit-mode="primary" - owl="1" > @@ -42,17 +40,17 @@ - + - + - +
- + props.parentRecord diff --git a/account_reconcile_oca/tests/test_bank_account_reconcile.py b/account_reconcile_oca/tests/test_bank_account_reconcile.py index f7470193..e13f031b 100644 --- a/account_reconcile_oca/tests/test_bank_account_reconcile.py +++ b/account_reconcile_oca/tests/test_bank_account_reconcile.py @@ -98,7 +98,7 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): ) as f: self.assertFalse(f.can_reconcile) f.add_account_move_line_id = inv1.line_ids.filtered( - lambda l: l.account_id.account_type == "asset_receivable" + lambda line: line.account_id.account_type == "asset_receivable" ) self.assertFalse(f.add_account_move_line_id) self.assertTrue(f.can_reconcile) @@ -130,7 +130,7 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): } ) receivable1 = inv1.line_ids.filtered( - lambda l: l.account_id.account_type == "asset_receivable" + lambda line: line.account_id.account_type == "asset_receivable" ) with Form( bank_stmt_line, @@ -184,7 +184,7 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): ) as f: self.assertFalse(f.can_reconcile) f.add_account_move_line_id = inv1.line_ids.filtered( - lambda l: l.account_id.account_type == "asset_receivable" + lambda line: line.account_id.account_type == "asset_receivable" ) self.assertFalse(f.add_account_move_line_id) self.assertTrue(f.can_reconcile) @@ -238,10 +238,10 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): } ) receivable1 = inv1.line_ids.filtered( - lambda l: l.account_id.account_type == "asset_receivable" + lambda line: line.account_id.account_type == "asset_receivable" ) receivable2 = inv2.line_ids.filtered( - lambda l: l.account_id.account_type == "asset_receivable" + lambda line: line.account_id.account_type == "asset_receivable" ) with Form( bank_stmt_line, @@ -298,10 +298,10 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): } ) receivable1 = inv1.line_ids.filtered( - lambda l: l.account_id.account_type == "liability_payable" + lambda line: line.account_id.account_type == "liability_payable" ) receivable2 = inv2.line_ids.filtered( - lambda l: l.account_id.account_type == "liability_payable" + lambda line: line.account_id.account_type == "liability_payable" ) with Form( bank_stmt_line, @@ -419,7 +419,7 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): inv1 = self.create_invoice(currency_id=self.currency_euro_id) receivable1 = inv1.line_ids.filtered( - lambda l: l.account_id.account_type == "asset_receivable" + lambda line: line.account_id.account_type == "asset_receivable" ) bank_stmt = self.acc_bank_stmt_model.create( { @@ -525,7 +525,7 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): } ) receivable1 = inv1.line_ids.filtered( - lambda l: l.account_id.account_type == "asset_receivable" + lambda line: line.account_id.account_type == "asset_receivable" ) with Form( bank_stmt_line, @@ -572,7 +572,7 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): } ) receivable1 = inv1.line_ids.filtered( - lambda l: l.account_id.account_type == "asset_receivable" + lambda line: line.account_id.account_type == "asset_receivable" ) with Form( bank_stmt_line, @@ -649,7 +649,7 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): } ) receivable1 = inv1.line_ids.filtered( - lambda l: l.account_id.account_type == "asset_receivable" + lambda line: line.account_id.account_type == "asset_receivable" ) with Form( bank_stmt_line, @@ -687,7 +687,7 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): } ) receivable1 = inv1.line_ids.filtered( - lambda l: l.account_id.account_type == "asset_receivable" + lambda line: line.account_id.account_type == "asset_receivable" ) with Form( bank_stmt_line, @@ -733,12 +733,12 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): ) as f: self.assertFalse(f.can_reconcile) f.add_account_move_line_id = inv1.line_ids.filtered( - lambda l: l.account_id.account_type == "asset_receivable" + lambda line: line.account_id.account_type == "asset_receivable" ) self.assertFalse(f.add_account_move_line_id) self.assertTrue(f.can_reconcile) f.add_account_move_line_id = inv1.line_ids.filtered( - lambda l: l.account_id.account_type == "asset_receivable" + lambda line: line.account_id.account_type == "asset_receivable" ) self.assertFalse(f.add_account_move_line_id) self.assertFalse(f.can_reconcile) @@ -873,11 +873,11 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): partner = inv1.partner_id receivable1 = inv1.line_ids.filtered( - lambda l: l.account_id.account_type == "asset_receivable" + lambda line: line.account_id.account_type == "asset_receivable" ) self.assertTrue(receivable1) receivable2 = inv2.line_ids.filtered( - lambda l: l.account_id.account_type == "asset_receivable" + lambda line: line.account_id.account_type == "asset_receivable" ) self.assertTrue(receivable2) @@ -1000,7 +1000,7 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): ) as f: self.assertFalse(f.can_reconcile) f.add_account_move_line_id = inv1.line_ids.filtered( - lambda l: l.account_id.account_type == "asset_receivable" + lambda line: line.account_id.account_type == "asset_receivable" ) self.assertFalse(f.add_account_move_line_id) self.assertTrue(f.can_reconcile) diff --git a/account_reconcile_oca/views/account_account.xml b/account_reconcile_oca/views/account_account.xml index 02b5f480..72bd824b 100644 --- a/account_reconcile_oca/views/account_account.xml +++ b/account_reconcile_oca/views/account_account.xml @@ -8,15 +8,15 @@ account.account - + diff --git a/account_reconcile_oca/views/account_account_reconcile.xml b/account_reconcile_oca/views/account_account_reconcile.xml index 305435b3..58c2d7f5 100644 --- a/account_reconcile_oca/views/account_account_reconcile.xml +++ b/account_reconcile_oca/views/account_account_reconcile.xml @@ -22,14 +22,14 @@ type="object" string="Reconcile" class="btn btn-primary" - attrs="{'invisible': [('is_reconciled', '=', True)]}" + invisible="is_reconciled == True" />