mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[FIX] account_payment_order_return: Set correct journal in tests to prevent error
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "Account Payment Order Return",
|
"name": "Account Payment Order Return",
|
||||||
"version": "13.0.1.0.0",
|
"version": "13.0.1.0.1",
|
||||||
"category": "Banking addons",
|
"category": "Banking addons",
|
||||||
"author": "Tecnativa, " "Odoo Community Association (OCA)",
|
"author": "Tecnativa, " "Odoo Community Association (OCA)",
|
||||||
"website": "https://github.com/OCA/bank-payment",
|
"website": "https://github.com/OCA/bank-payment",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# Copyright 2017 Tecnativa - Luis M. Ontalba
|
# Copyright 2017 Tecnativa - Luis M. Ontalba
|
||||||
# Copyright 2021 Tecnativa - João Marques
|
# Copyright 2021 Tecnativa - João Marques
|
||||||
|
# Copyright 2021 Tecnativa - Víctor Martínez
|
||||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0
|
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0
|
||||||
|
|
||||||
from odoo import fields
|
from odoo import fields
|
||||||
@@ -29,13 +30,12 @@ class TestAccountPaymentOrderReturn(common.SavepointCase):
|
|||||||
)
|
)
|
||||||
cls.partner = cls.env["res.partner"].create({"name": "Test Partner 2"})
|
cls.partner = cls.env["res.partner"].create({"name": "Test Partner 2"})
|
||||||
cls.journal = cls.env["account.journal"].create(
|
cls.journal = cls.env["account.journal"].create(
|
||||||
{"name": "Test Journal", "type": "bank"}
|
{"name": "Test Journal", "type": "bank", "code": "Test"}
|
||||||
)
|
)
|
||||||
move_form = Form(
|
move_form = Form(
|
||||||
cls.env["account.move"].with_context(default_type="out_invoice")
|
cls.env["account.move"].with_context(default_type="out_invoice")
|
||||||
)
|
)
|
||||||
move_form.partner_id = cls.partner
|
move_form.partner_id = cls.partner
|
||||||
move_form.journal_id = cls.journal
|
|
||||||
with move_form.invoice_line_ids.new() as line_form:
|
with move_form.invoice_line_ids.new() as line_form:
|
||||||
line_form.name = "Test line"
|
line_form.name = "Test line"
|
||||||
line_form.account_id = cls.a_receivable
|
line_form.account_id = cls.a_receivable
|
||||||
@@ -45,7 +45,7 @@ class TestAccountPaymentOrderReturn(common.SavepointCase):
|
|||||||
cls.payment_mode = cls.env["account.payment.mode"].create(
|
cls.payment_mode = cls.env["account.payment.mode"].create(
|
||||||
{
|
{
|
||||||
"name": "Test payment mode",
|
"name": "Test payment mode",
|
||||||
"fixed_journal_id": cls.journal.id,
|
"fixed_journal_id": cls.invoice.journal_id.id,
|
||||||
"bank_account_link": "variable",
|
"bank_account_link": "variable",
|
||||||
"payment_method_id": cls.env.ref(
|
"payment_method_id": cls.env.ref(
|
||||||
"account.account_payment_method_manual_in"
|
"account.account_payment_method_manual_in"
|
||||||
@@ -73,7 +73,7 @@ class TestAccountPaymentOrderReturn(common.SavepointCase):
|
|||||||
wizard = wizard_o.with_context(context).create(
|
wizard = wizard_o.with_context(context).create(
|
||||||
{
|
{
|
||||||
"order_id": self.payment_order.id,
|
"order_id": self.payment_order.id,
|
||||||
"journal_ids": [(4, self.journal.id)],
|
"journal_ids": [(4, self.journal.id), (4, self.invoice.journal_id.id)],
|
||||||
"allow_blocked": True,
|
"allow_blocked": True,
|
||||||
"date_type": "move",
|
"date_type": "move",
|
||||||
"move_date": fields.Date.today(),
|
"move_date": fields.Date.today(),
|
||||||
@@ -89,9 +89,7 @@ class TestAccountPaymentOrderReturn(common.SavepointCase):
|
|||||||
)
|
)
|
||||||
# Invert the move to simulate the payment
|
# Invert the move to simulate the payment
|
||||||
self.payment_move = self.env["account.move"].create(
|
self.payment_move = self.env["account.move"].create(
|
||||||
self.invoice._reverse_move_vals(
|
self.invoice._reverse_move_vals(default_values={})
|
||||||
default_values={"journal_id": self.journal.id}
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
self.payment_move.action_post()
|
self.payment_move.action_post()
|
||||||
self.payment_line = self.payment_move.line_ids.filtered(
|
self.payment_line = self.payment_move.line_ids.filtered(
|
||||||
@@ -99,6 +97,10 @@ class TestAccountPaymentOrderReturn(common.SavepointCase):
|
|||||||
)
|
)
|
||||||
# Reconcile both
|
# Reconcile both
|
||||||
(self.receivable_line | self.payment_line).reconcile()
|
(self.receivable_line | self.payment_line).reconcile()
|
||||||
|
# prev_move_lines
|
||||||
|
wizard.include_returned = False
|
||||||
|
wizard.populate()
|
||||||
|
prev_move_lines = wizard.move_line_ids
|
||||||
# Create payment return
|
# Create payment return
|
||||||
self.payment_return = self.env["payment.return"].create(
|
self.payment_return = self.env["payment.return"].create(
|
||||||
{
|
{
|
||||||
@@ -119,4 +121,4 @@ class TestAccountPaymentOrderReturn(common.SavepointCase):
|
|||||||
self.payment_return.action_confirm()
|
self.payment_return.action_confirm()
|
||||||
wizard.include_returned = False
|
wizard.include_returned = False
|
||||||
wizard.populate()
|
wizard.populate()
|
||||||
self.assertFalse(wizard.move_line_ids)
|
self.assertTrue((wizard.move_line_ids - prev_move_lines), 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user