diff --git a/account_payment_order/models/account_move.py b/account_payment_order/models/account_move.py index 3faae049e..46478cc84 100644 --- a/account_payment_order/models/account_move.py +++ b/account_payment_order/models/account_move.py @@ -233,3 +233,12 @@ class AccountMove(models.Model): } ) return action + + @api.model + def _get_invoice_in_payment_state(self): + """Called from _compute_payment_state method. + Consider in_payment all the moves that are included in a payment order. + """ + if self.line_ids.payment_line_ids: + return "in_payment" + return super()._get_invoice_in_payment_state() diff --git a/account_payment_order/tests/test_payment_order_inbound.py b/account_payment_order/tests/test_payment_order_inbound.py index 775ac8cb4..5b461857d 100644 --- a/account_payment_order/tests/test_payment_order_inbound.py +++ b/account_payment_order/tests/test_payment_order_inbound.py @@ -122,25 +122,20 @@ class TestPaymentOrderInbound(TestPaymentOrderInboundBase): def test_creation(self): payment_order = self.inbound_order self.assertEqual(len(payment_order.ids), 1) - payment_order.write({"journal_id": self.journal.id}) - self.assertEqual(len(payment_order.payment_line_ids), 1) self.assertFalse(payment_order.payment_ids) - # Open payment order payment_order.draft2open() - self.assertEqual(payment_order.payment_count, 1) - # Generate and upload payment_order.open2generated() payment_order.generated2uploaded() - self.assertEqual(payment_order.state, "uploaded") + self.assertEqual(self.invoice.payment_state, "in_payment") with self.assertRaises(UserError): payment_order.unlink() - + # Cancel order payment_order.action_uploaded_cancel() self.assertEqual(payment_order.state, "cancel") payment_order.cancel2draft()