From bd88cecd2f543a0d7ccc576b451a03180cc5a4b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Fri, 16 Aug 2024 11:34:53 +0200 Subject: [PATCH] [IMP] account_payment_order: add button to view business document Quick access to business document on payment lines. --- .../models/account_payment_line.py | 5 +++++ .../tests/test_payment_order_outbound.py | 22 +++++++++++++++++++ .../views/account_payment_line.xml | 10 ++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/account_payment_order/models/account_payment_line.py b/account_payment_order/models/account_payment_line.py index c41e7409c..bbecc4ba3 100644 --- a/account_payment_order/models/account_payment_line.py +++ b/account_payment_order/models/account_payment_line.py @@ -244,3 +244,8 @@ class AccountPaymentLine(models.Model): if transfer_journal: vals["journal_id"] = transfer_journal.id return vals + + def action_open_business_doc(self): + if not self.move_line_id: + return False + return self.move_line_id.action_open_business_doc() diff --git a/account_payment_order/tests/test_payment_order_outbound.py b/account_payment_order/tests/test_payment_order_outbound.py index 62f55680e..1782d3cbc 100644 --- a/account_payment_order/tests/test_payment_order_outbound.py +++ b/account_payment_order/tests/test_payment_order_outbound.py @@ -516,3 +516,25 @@ class TestPaymentOrderOutbound(TestPaymentOrderOutboundBase): self.assertEqual(len(payment_order.payment_line_ids), 1) self.assertEqual("F1242 R1234", payment_order.payment_line_ids.communication) + + def test_action_open_business_document(self): + # Open invoice + self.invoice.action_post() + # Add to payment order using the wizard + self.env["account.invoice.payment.line.multi"].with_context( + active_model="account.move", active_ids=self.invoice.ids + ).create({}).run() + order = self.env["account.payment.order"].search(self.domain) + # Create payment line without move line + vals = { + "order_id": order.id, + "partner_id": self.partner.id, + "currency_id": order.payment_mode_id.company_id.currency_id.id, + "amount_currency": 200.38, + } + self.env["account.payment.line"].create(vals) + invoice_action = order.payment_line_ids[0].action_open_business_doc() + self.assertEqual(invoice_action["res_model"], "account.move") + self.assertEqual(invoice_action["res_id"], self.invoice.id) + manual_line_action = order.payment_line_ids[1].action_open_business_doc() + self.assertFalse(manual_line_action) diff --git a/account_payment_order/views/account_payment_line.xml b/account_payment_order/views/account_payment_line.xml index c5a54c326..d76258f2a 100644 --- a/account_payment_order/views/account_payment_line.xml +++ b/account_payment_order/views/account_payment_line.xml @@ -18,7 +18,8 @@ name="move_line_id" domain="[('reconciled','=', False), ('account_id.reconcile', '=', True)] " /> - + @@ -93,6 +94,13 @@ invisible="1" /> +