From d328870c717f758f1af0eab7e3da6de118c9d602 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 18 Jul 2024 18:32:55 +0200 Subject: [PATCH] [ADD] account_operating_unit: increase test coverage --- .../tests/test_invoice_operating_unit.py | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/account_operating_unit/tests/test_invoice_operating_unit.py b/account_operating_unit/tests/test_invoice_operating_unit.py index dc8d7be33d..4ab83c67f5 100644 --- a/account_operating_unit/tests/test_invoice_operating_unit.py +++ b/account_operating_unit/tests/test_invoice_operating_unit.py @@ -3,7 +3,7 @@ # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from odoo.exceptions import UserError -from odoo.tests import tagged +from odoo.tests import Form, tagged from . import test_account_operating_unit as test_ou @@ -42,4 +42,32 @@ def test_create_invoice_validate(self): with self.assertRaises(UserError): self.invoice.line_ids[0].company_id = new_company.id # Check report invoice - self.env["account.invoice.report"].sudo().search_read([]) + self.env["account.invoice.report"].sudo().read_group( + [], ["operating_unit_id"], ["operating_unit_id"] + ) + + def test_form(self): + """Test that the UI behaves as expected""" + journal_b2b = self.env["account.journal"].create( + { + "name": "B2B journal", + "code": "B2B", + "type": "sale", + "operating_unit_id": self.b2b.id, + "company_id": self.company.id, + } + ) + with Form( + self.env["account.move"].with_context(default_move_type="out_invoice") + ) as invoice_form: + self.assertEqual(invoice_form.operating_unit_id, self.ou1) + ou1_journal = invoice_form.journal_id.copy( + dict( + operating_unit_id=self.ou1.id, + company_id=self.company.id, + ) + ) + invoice_form.operating_unit_id = self.b2b + self.assertEqual(invoice_form.journal_id, journal_b2b) + invoice_form.journal_id = ou1_journal + self.assertEqual(invoice_form.operating_unit_id, self.ou1)