diff --git a/partner_firstname/__manifest__.py b/partner_firstname/__manifest__.py index 256d9984234..39ddb1ab755 100644 --- a/partner_firstname/__manifest__.py +++ b/partner_firstname/__manifest__.py @@ -6,7 +6,7 @@ { "name": "Partner first name and last name", "summary": "Split first name and last name for non company partners", - "version": "18.0.1.1.0", + "version": "18.0.1.2.0", "author": "Camptocamp, " "Grupo ESOC IngenierĂ­a de Servicios, " "Tecnativa, " @@ -15,10 +15,9 @@ "DynApps NV, " "Odoo Community Association (OCA)", "license": "AGPL-3", - "maintainer": "Camptocamp, Acsone", "category": "Extra Tools", "website": "https://github.com/OCA/partner-contact", - "depends": ["base_setup"], + "depends": ["partner_type_base"], "post_init_hook": "post_init_hook", "data": [ "views/base_config_view.xml", diff --git a/partner_firstname/migrations/18.0.1.2.0/pre-migration.py b/partner_firstname/migrations/18.0.1.2.0/pre-migration.py new file mode 100644 index 00000000000..05ab104fccc --- /dev/null +++ b/partner_firstname/migrations/18.0.1.2.0/pre-migration.py @@ -0,0 +1,10 @@ +import logging + +from odoo.upgrade import util + +_logger = logging.getLogger(__name__) + + +def migrate(cr, version): + _logger.info("Installing dependent module 'partner_type_base' by migration script.") + util.force_install_module(cr, "partner_type_base") diff --git a/partner_firstname/views/res_partner.xml b/partner_firstname/views/res_partner.xml index 01c1ba8d250..387cd3957e4 100644 --- a/partner_firstname/views/res_partner.xml +++ b/partner_firstname/views/res_partner.xml @@ -4,25 +4,12 @@ - is_company - not is_company - type == 'contact' and is_company - - - is_company == False - not is_company - type == 'contact' and is_company + is_individual - - - + + + @@ -32,54 +19,39 @@ - is_company - not is_company - type == 'contact' and is_company - - - not is_company - not is_company - type == 'contact' and is_company + is_individual
- +
- - - not is_company - is_company - +
- - +
diff --git a/partner_type_base/README.rst b/partner_type_base/README.rst new file mode 100644 index 00000000000..ba963afe3b7 --- /dev/null +++ b/partner_type_base/README.rst @@ -0,0 +1,77 @@ +===================== +Partner Address Types +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:43d730c51ef59b1c6de4109020507234da1ada647d1a04e2b0bc1dc74dad4451 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github + :target: https://github.com/OCA/partner-contact/tree/18.0/partner_type_base + :alt: OCA/partner-contact +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/partner-contact-18-0/partner-contact-18-0-partner_type_base + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/partner-contact&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module was written to extend the functionality of contact types for +a flexible extension. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* glueckkanja AG + +Contributors +------------ + +- Christopher Rogos + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/partner-contact `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/partner_type_base/__init__.py b/partner_type_base/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/partner_type_base/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/partner_type_base/__manifest__.py b/partner_type_base/__manifest__.py new file mode 100644 index 00000000000..ca409df5143 --- /dev/null +++ b/partner_type_base/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2013 Nicolas Bessi (Camptocamp SA) +# Copyright 2014 Agile Business Group () +# Copyright 2015 Grupo ESOC () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Partner Address Types", + "summary": "Base implementation to improve the address type customization.", + "version": "18.0.1.0.0", + "author": "glueckkanja AG, Odoo Community Association (OCA)", + "license": "AGPL-3", + "category": "Extra Tools", + "website": "https://github.com/OCA/partner-contact", + "depends": ["base_setup"], + "data": [ + "views/res_partner.xml", + ], + "auto_install": False, + "installable": True, +} diff --git a/partner_type_base/models/__init__.py b/partner_type_base/models/__init__.py new file mode 100644 index 00000000000..91fed54d404 --- /dev/null +++ b/partner_type_base/models/__init__.py @@ -0,0 +1 @@ +from . import res_partner diff --git a/partner_type_base/models/res_partner.py b/partner_type_base/models/res_partner.py new file mode 100644 index 00000000000..d5e7515a067 --- /dev/null +++ b/partner_type_base/models/res_partner.py @@ -0,0 +1,46 @@ +# Copyright 2024 Christopher Rogos () + +from odoo import api, fields, models + + +class ResPartner(models.Model): + """Adds last name and first name; name becomes a stored function field.""" + + _inherit = "res.partner" + + is_address_readonly = fields.Boolean( + compute="_compute_contact_type", + help="If true, the address fields are readonly.", + ) + is_individual = fields.Boolean( + compute="_compute_contact_type", help="If true, the partner name is splitted." + ) + can_be_parent = fields.Boolean( + compute="_compute_contact_type", + search="_search_can_be_parent", + help="If true, the partner is available as parent.", + ) + can_be_child = fields.Boolean( + compute="_compute_contact_type", + help="If true, the partner_id field is available.", + ) + + @api.depends("is_company", "type", "parent_id") + def _compute_contact_type(self): + for partner in self: + partner.is_address_readonly = not ( + partner.is_company + or not partner.parent_id + or partner.type not in ["contact"] + ) + partner.is_individual = not partner.is_company and partner.type in [ + "contact", + "other", + ] + + partner.can_be_parent = partner.is_company + partner.can_be_child = not partner.is_company + + @api.model + def _search_can_be_parent(self, operator, value): + return [("is_company", operator, value)] diff --git a/partner_type_base/pyproject.toml b/partner_type_base/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/partner_type_base/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/partner_type_base/readme/CONTRIBUTORS.md b/partner_type_base/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..a498f8fed28 --- /dev/null +++ b/partner_type_base/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Christopher Rogos \ No newline at end of file diff --git a/partner_type_base/readme/DESCRIPTION.md b/partner_type_base/readme/DESCRIPTION.md new file mode 100644 index 00000000000..6cfd5789287 --- /dev/null +++ b/partner_type_base/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module was written to extend the functionality of contact types +for a flexible extension. \ No newline at end of file diff --git a/partner_type_base/static/description/icon.png b/partner_type_base/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/partner_type_base/static/description/icon.png differ diff --git a/partner_type_base/static/description/index.html b/partner_type_base/static/description/index.html new file mode 100644 index 00000000000..8c220555f00 --- /dev/null +++ b/partner_type_base/static/description/index.html @@ -0,0 +1,424 @@ + + + + + +Partner Address Types + + + +
+

Partner Address Types

+ + +

Beta License: AGPL-3 OCA/partner-contact Translate me on Weblate Try me on Runboat

+

This module was written to extend the functionality of contact types for +a flexible extension.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • glueckkanja AG
  • +
+
+
+

Contributors

+
    +
  • Christopher Rogos
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/partner-contact project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/partner_type_base/tests/__init__.py b/partner_type_base/tests/__init__.py new file mode 100644 index 00000000000..d57d215f908 --- /dev/null +++ b/partner_type_base/tests/__init__.py @@ -0,0 +1 @@ +from . import test_res_partner diff --git a/partner_type_base/tests/test_res_partner.py b/partner_type_base/tests/test_res_partner.py new file mode 100644 index 00000000000..4f0ecdeaf36 --- /dev/null +++ b/partner_type_base/tests/test_res_partner.py @@ -0,0 +1,60 @@ +from odoo.tests.common import TransactionCase + + +class TestResPartner(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.ResPartner = cls.env["res.partner"] + + cls.Partner_company = cls.ResPartner.create( + {"name": "Company Partner", "is_company": True, "type": "contact"} + ) + cls.Partner_contact = cls.ResPartner.create( + {"name": "Individual Partner", "is_company": False, "type": "contact"} + ) + cls.Partner_child = cls.ResPartner.create( + { + "name": "Child Partner", + "is_company": False, + "type": "contact", + "parent_id": cls.Partner_company.id, + } + ) + cls.Partner_other = cls.ResPartner.create( + {"name": "Other Partner", "is_company": False, "type": "other"} + ) + cls.Partner_invoice = cls.ResPartner.create( + {"name": "Invoice Partner", "is_company": False, "type": "invoice"} + ) + cls.Partner_delivery = cls.ResPartner.create( + {"name": "Shipping Partner", "is_company": False, "type": "delivery"} + ) + + def test_is_address_readonly(self): + self.assertFalse(self.Partner_company.is_address_readonly) + self.assertFalse(self.Partner_contact.is_address_readonly) + self.assertTrue(self.Partner_child.is_address_readonly) + self.assertFalse(self.Partner_invoice.is_address_readonly) + self.assertFalse(self.Partner_delivery.is_address_readonly) + + def test_is_individual_types(self): + self.assertFalse(self.Partner_company.is_individual) + self.assertTrue(self.Partner_contact.is_individual) + self.assertTrue(self.Partner_other.is_individual) + self.assertFalse(self.Partner_invoice.is_individual) + self.assertFalse(self.Partner_delivery.is_individual) + + def test_can_be_parent(self): + self.assertTrue(self.Partner_company.can_be_parent) + self.assertFalse(self.Partner_contact.can_be_parent) + self.assertFalse(self.Partner_other.can_be_parent) + self.assertFalse(self.Partner_invoice.can_be_parent) + self.assertFalse(self.Partner_delivery.can_be_parent) + + def test_can_be_child(self): + self.assertFalse(self.Partner_company.can_be_child) + self.assertTrue(self.Partner_contact.can_be_child) + self.assertTrue(self.Partner_other.can_be_child) + self.assertTrue(self.Partner_invoice.can_be_child) + self.assertTrue(self.Partner_delivery.can_be_child) diff --git a/partner_type_base/views/res_partner.xml b/partner_type_base/views/res_partner.xml new file mode 100644 index 00000000000..bedfb68b3b6 --- /dev/null +++ b/partner_type_base/views/res_partner.xml @@ -0,0 +1,67 @@ + + + res.partner + + + + not can_be_child + [('can_be_parent', '=', True)] + + + + is_company + is_individual + + + + + res.partner + + + + not can_be_child + [('can_be_parent', '=', True)] + + + is_company + is_individual + + + not is_individual + + + + + is_individual + is_individual or is_company + + + not is_individual + + + not is_individual + + + is_address_readonly + + + is_address_readonly + + + +