From 435e47096805b9f37aaa7bb85c84bbf977c12bd2 Mon Sep 17 00:00:00 2001 From: "maximilien(malb)" Date: Wed, 21 Sep 2022 15:00:25 +0000 Subject: [PATCH] [FIX] account: Bill payment flow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Link to payment not clickable since the owl migration, the click method in xml wasn't there anymore 2. In the past, the view given in the context was problematic, so now we let the orm pick the view Also removed the function open_move and open_payment which was useless since action_open_business_doc_from_aml do the job. I also moved the function in account.move closes odoo/odoo#101342 Task-id: 2988037 X-original-commit: 739ea262b821a71dcb9c7d61d6bd179a4996de0e Related: odoo/enterprise#31876 Signed-off-by: William André (wan) --- addons/account/models/account_move.py | 32 ++++++++++------- addons/account/models/account_move_line.py | 34 ++----------------- .../account_payment_field/account_payment.xml | 2 +- .../account_payment_field.js | 2 +- .../open_move_widget/open_move_widget.js | 2 +- .../src/js/legacy_account_payment_field.js | 2 +- .../static/src/js/legacy_open_move_widget.js | 2 +- .../tests/account_payment_field_tests.js | 4 +-- addons/account/views/account_move_views.xml | 2 +- 9 files changed, 30 insertions(+), 52 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 97d24fb7048..ebb108a1f95 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -3303,25 +3303,33 @@ class AccountMove(models.Model): def open_reconcile_view(self): return self.line_ids.open_reconcile_view() - def open_move(self): + def action_open_business_doc(self): + self.ensure_one() if self.payment_id: - return self.open_payment_view() + name = _("Payment") + res_model = 'account.payment' + res_id = self.payment_id.id + elif self.statement_line_id: + name = _("Bank Transaction") + res_model = 'account.bank.statement.line' + res_id = self.statement_line_id.id else: - return { - 'type': 'ir.actions.act_window', - 'res_model': 'account.move', - 'view_mode': 'form', - 'res_id': self.id, - 'views': [(False, 'form')], - } + name = _("Journal Entry") + res_model = 'account.move' + res_id = self.id - def open_payment_view(self): return { + 'name': name, 'type': 'ir.actions.act_window', - 'res_model': 'account.payment', 'view_mode': 'form', - 'res_id': self.payment_id.id, 'views': [(False, 'form')], + 'res_model': res_model, + 'res_id': res_id, + 'context': { + 'create': False, + 'delete': False, + }, + 'target': 'current', } def open_created_caba_entries(self): diff --git a/addons/account/models/account_move_line.py b/addons/account/models/account_move_line.py index ccb2f5bbc2c..43b64363ac3 100644 --- a/addons/account/models/account_move_line.py +++ b/addons/account/models/account_move_line.py @@ -2509,8 +2509,8 @@ class AccountMoveLine(models.Model): action['domain'] = [('id', 'in', ids)] return clean_action(action, self.env) - def open_move(self): - return self.move_id.open_move() + def action_open_business_doc(self): + return self.move_id.action_open_business_doc() def action_automatic_entry(self): action = self.env['ir.actions.act_window']._for_xml_id('account.account_automatic_entry_wizard_action') @@ -2523,36 +2523,6 @@ class AccountMoveLine(models.Model): action['context'] = ctx return action - def action_open_business_doc_from_aml(self): - self.ensure_one() - - if self.payment_id: - name = _("Payment") - res_model = 'account.payment' - res_id = self.payment_id.id - elif self.statement_line_id: - name = _("Bank Transaction") - res_model = 'account.bank.statement.line' - res_id = self.statement_line_id.id - else: - name = _("Journal Entry") - res_model = 'account.move' - res_id = self.move_id.id - - return { - 'name': name, - 'type': 'ir.actions.act_window', - 'view_mode': 'form', - 'view_id': self.env.ref('account.view_move_form').id, - 'res_model': res_model, - 'res_id': res_id, - 'context': { - 'create': False, - 'delete': False, - }, - 'target': 'current', - } - # ------------------------------------------------------------------------- # TOOLING # ------------------------------------------------------------------------- diff --git a/addons/account/static/src/components/account_payment_field/account_payment.xml b/addons/account/static/src/components/account_payment_field/account_payment.xml index 617825b79d2..7b77b08c92e 100644 --- a/addons/account/static/src/components/account_payment_field/account_payment.xml +++ b/addons/account/static/src/components/account_payment_field/account_payment.xml @@ -27,7 +27,7 @@