diff --git a/account_payment_order/models/account_payment_line.py b/account_payment_order/models/account_payment_line.py index 824d289f1..f9d2ce5e0 100644 --- a/account_payment_order/models/account_payment_line.py +++ b/account_payment_order/models/account_payment_line.py @@ -237,3 +237,8 @@ class AccountPaymentLine(models.Model): "destination_account_id" ] = self.partner_id.property_account_payable_id.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 d0b8dec9e..0e5bfffc9 100644 --- a/account_payment_order/tests/test_payment_order_outbound.py +++ b/account_payment_order/tests/test_payment_order_outbound.py @@ -463,3 +463,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 7e13514f2..05c58e902 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" /> +