From 3eb25bdbb6f157c83c71f54e8940b38d14739c23 Mon Sep 17 00:00:00 2001 From: Bhavesh Heliconia Date: Thu, 26 Dec 2024 16:47:07 +0530 Subject: [PATCH] [MIG] res_company_search_view: Migration to 18.0 --- res_company_search_view/README.rst | 1 + res_company_search_view/__manifest__.py | 2 +- .../readme/CONTRIBUTORS.md | 1 + .../static/description/index.html | 1 + res_company_search_view/tests/__init__.py | 1 + .../tests/test_res_company.py | 113 ++++++++++++++++++ 6 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 res_company_search_view/tests/__init__.py create mode 100644 res_company_search_view/tests/test_res_company.py diff --git a/res_company_search_view/README.rst b/res_company_search_view/README.rst index b3bf29a5f11..2bae61a5ae1 100644 --- a/res_company_search_view/README.rst +++ b/res_company_search_view/README.rst @@ -62,6 +62,7 @@ Contributors ------------ - Sylvain LE GAL +- `Heliconia Solutions Pvt. Ltd. `__ Maintainers ----------- diff --git a/res_company_search_view/__manifest__.py b/res_company_search_view/__manifest__.py index 6d115c9ecd4..04978a72294 100644 --- a/res_company_search_view/__manifest__.py +++ b/res_company_search_view/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Company - Search View", "summary": "Add a search view for company model", - "version": "16.0.1.0.0", + "version": "18.0.1.0.0", "category": "Tools", "author": "GRAP, Odoo Community Association (OCA)", "maintainers": ["legalsylvain"], diff --git a/res_company_search_view/readme/CONTRIBUTORS.md b/res_company_search_view/readme/CONTRIBUTORS.md index a454b96bdfc..55d63443e7f 100644 --- a/res_company_search_view/readme/CONTRIBUTORS.md +++ b/res_company_search_view/readme/CONTRIBUTORS.md @@ -1 +1,2 @@ - Sylvain LE GAL \<\> +- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io) diff --git a/res_company_search_view/static/description/index.html b/res_company_search_view/static/description/index.html index ce6edce5731..ef23d2cfa79 100644 --- a/res_company_search_view/static/description/index.html +++ b/res_company_search_view/static/description/index.html @@ -406,6 +406,7 @@

Authors

Contributors

diff --git a/res_company_search_view/tests/__init__.py b/res_company_search_view/tests/__init__.py new file mode 100644 index 00000000000..2c9568e64bc --- /dev/null +++ b/res_company_search_view/tests/__init__.py @@ -0,0 +1 @@ +from . import test_res_company diff --git a/res_company_search_view/tests/test_res_company.py b/res_company_search_view/tests/test_res_company.py new file mode 100644 index 00000000000..050dcf00290 --- /dev/null +++ b/res_company_search_view/tests/test_res_company.py @@ -0,0 +1,113 @@ +from odoo.tests.common import TransactionCase + + +class TestResCompany(TransactionCase): + def setUp(self): + super().setUp() + # Create a test company for use in test cases + self.company = self.env["res.company"].create( + { + "name": "Test Company", + "country_id": self.env.ref("base.us").id, + "street": "123 Test Street", + "street2": "Suite 456", + "zip": "12345", + "city": "Test City", + "state_id": self.env.ref("base.state_us_1").id, + } + ) + + def test_create_company_with_address(self): + """Test creation of a company with address details.""" + self.assertEqual( + self.company.street, "123 Test Street", "Street value is incorrect" + ) + self.assertEqual( + self.company.street2, "Suite 456", "Street2 value is incorrect" + ) + self.assertEqual(self.company.zip, "12345", "ZIP code value is incorrect") + self.assertEqual(self.company.city, "Test City", "City value is incorrect") + self.assertEqual( + self.company.state_id, + self.env.ref("base.state_us_1"), + "State value is incorrect", + ) + self.assertEqual( + self.company.country_id, + self.env.ref("base.us"), + "Country value is incorrect", + ) + + def test_update_company_address(self): + """Test updating the address details of a company.""" + self.company.write( + { + "street": "789 New Street", + "street2": "Apt 101", + "zip": "67890", + "city": "New City", + "state_id": self.env.ref("base.state_us_2").id, + "country_id": self.env.ref("base.ca").id, + } + ) + self.assertEqual( + self.company.street, + "789 New Street", + "Street value did not update correctly", + ) + self.assertEqual( + self.company.street2, "Apt 101", "Street2 value did not update correctly" + ) + self.assertEqual( + self.company.zip, "67890", "ZIP code value did not update correctly" + ) + self.assertEqual( + self.company.city, "New City", "City value did not update correctly" + ) + self.assertEqual( + self.company.state_id, + self.env.ref("base.state_us_2"), + "State value did not update correctly", + ) + self.assertEqual( + self.company.country_id, + self.env.ref("base.ca"), + "Country value did not update correctly", + ) + + def test_field_storage(self): + """Test that fields are stored in the database.""" + stored_fields = ["country_id", "street", "street2", "zip", "city", "state_id"] + for field_name in stored_fields: + field = self.company._fields[field_name] + self.assertTrue( + field.store, f"{field_name} should be stored in the database" + ) + + def test_create_company_with_partial_address(self): + """Test creation of a company with partial address details.""" + partial_company = self.env["res.company"].create( + { + "name": "Partial Address Company", + "street": "456 Partial Street", + "zip": "54321", + "city": "Partial City", + } + ) + self.assertEqual( + partial_company.street, + "456 Partial Street", + "Partial street value is incorrect", + ) + self.assertEqual( + partial_company.zip, "54321", "Partial ZIP code value is incorrect" + ) + self.assertEqual( + partial_company.city, "Partial City", "Partial city value is incorrect" + ) + self.assertFalse( + partial_company.country_id, "Country should not be set for partial address" + ) + self.assertFalse( + partial_company.state_id, "State should not be set for partial address" + )