From ba50e66fd2ab7d7237187d5c61075f26735d268f Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Thu, 21 Oct 2021 12:11:00 +0700 Subject: [PATCH] [ADD] partner_title_order --- partner_title_order/README.rst | 83 ++++ partner_title_order/__init__.py | 1 + partner_title_order/__manifest__.py | 18 + partner_title_order/models/__init__.py | 1 + .../models/res_partner_title.py | 11 + partner_title_order/readme/CONTRIBUTORS.rst | 3 + partner_title_order/readme/CREDITS.rst | 4 + partner_title_order/readme/DESCRIPTION.rst | 1 + .../static/description/index.html | 436 ++++++++++++++++++ partner_title_order/tests/__init__.py | 1 + .../tests/test_partner_title.py | 33 ++ .../views/res_partner_title_views.xml | 26 ++ .../odoo/addons/partner_title_order | 1 + setup/partner_title_order/setup.py | 6 + 14 files changed, 625 insertions(+) create mode 100644 partner_title_order/README.rst create mode 100644 partner_title_order/__init__.py create mode 100644 partner_title_order/__manifest__.py create mode 100644 partner_title_order/models/__init__.py create mode 100644 partner_title_order/models/res_partner_title.py create mode 100644 partner_title_order/readme/CONTRIBUTORS.rst create mode 100644 partner_title_order/readme/CREDITS.rst create mode 100644 partner_title_order/readme/DESCRIPTION.rst create mode 100644 partner_title_order/static/description/index.html create mode 100644 partner_title_order/tests/__init__.py create mode 100644 partner_title_order/tests/test_partner_title.py create mode 100644 partner_title_order/views/res_partner_title_views.xml create mode 120000 setup/partner_title_order/odoo/addons/partner_title_order create mode 100644 setup/partner_title_order/setup.py diff --git a/partner_title_order/README.rst b/partner_title_order/README.rst new file mode 100644 index 000000000..29e5d4f4f --- /dev/null +++ b/partner_title_order/README.rst @@ -0,0 +1,83 @@ +=================== +Partner title order +=================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/14.0/partner_title_order + :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-14-0/partner-contact-14-0-partner_title_order + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/134/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Add sequence to partner title to be able to determine their order. + +**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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* Simone Orsi +* `Trobz `_: + * Khoi Vo + +Other credits +~~~~~~~~~~~~~ + +**Financial support** + +* Cosanum +* Camptocamp R&D + +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_title_order/__init__.py b/partner_title_order/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/partner_title_order/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/partner_title_order/__manifest__.py b/partner_title_order/__manifest__.py new file mode 100644 index 000000000..ff7f9bd96 --- /dev/null +++ b/partner_title_order/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Partner title order", + "summary": "Makes partner title sortable by sequence", + "version": "14.0.1.0.0", + "category": "Hidden", + "author": "Camptocamp, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": [ + "base", + ], + "website": "https://github.com/OCA/partner-contact", + "data": [ + "views/res_partner_title_views.xml", + ], + "installable": True, +} diff --git a/partner_title_order/models/__init__.py b/partner_title_order/models/__init__.py new file mode 100644 index 000000000..a98a60679 --- /dev/null +++ b/partner_title_order/models/__init__.py @@ -0,0 +1 @@ +from . import res_partner_title diff --git a/partner_title_order/models/res_partner_title.py b/partner_title_order/models/res_partner_title.py new file mode 100644 index 000000000..0a2af0b7c --- /dev/null +++ b/partner_title_order/models/res_partner_title.py @@ -0,0 +1,11 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) + +from odoo import fields, models + + +class ResPartnerTitle(models.Model): + _inherit = "res.partner.title" + _order = "sequence, name" + + sequence = fields.Integer(default=10) diff --git a/partner_title_order/readme/CONTRIBUTORS.rst b/partner_title_order/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..ede66d84b --- /dev/null +++ b/partner_title_order/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Simone Orsi +* `Trobz `_: + * Khoi Vo diff --git a/partner_title_order/readme/CREDITS.rst b/partner_title_order/readme/CREDITS.rst new file mode 100644 index 000000000..4641e1066 --- /dev/null +++ b/partner_title_order/readme/CREDITS.rst @@ -0,0 +1,4 @@ +**Financial support** + +* Cosanum +* Camptocamp R&D diff --git a/partner_title_order/readme/DESCRIPTION.rst b/partner_title_order/readme/DESCRIPTION.rst new file mode 100644 index 000000000..a76907293 --- /dev/null +++ b/partner_title_order/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Add sequence to partner title to be able to determine their order. diff --git a/partner_title_order/static/description/index.html b/partner_title_order/static/description/index.html new file mode 100644 index 000000000..a6b5cdb5c --- /dev/null +++ b/partner_title_order/static/description/index.html @@ -0,0 +1,436 @@ + + + + + + +Partner title order + + + +
+

Partner title order

+ + +

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

+

Add sequence to partner title to be able to determine their order.

+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

Financial support

+
    +
  • Cosanum
  • +
  • Camptocamp R&D
  • +
+
+
+

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_title_order/tests/__init__.py b/partner_title_order/tests/__init__.py new file mode 100644 index 000000000..484fb30f6 --- /dev/null +++ b/partner_title_order/tests/__init__.py @@ -0,0 +1 @@ +from . import test_partner_title diff --git a/partner_title_order/tests/test_partner_title.py b/partner_title_order/tests/test_partner_title.py new file mode 100644 index 000000000..646a8a410 --- /dev/null +++ b/partner_title_order/tests/test_partner_title.py @@ -0,0 +1,33 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) + +from odoo.tests.common import SavepointCase + + +class TestPartnerTitle(SavepointCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + + def test_default_order(self): + partner_titles = self.env["res.partner.title"].search([]) + self.assertEqual( + partner_titles.mapped("name"), + partner_titles.sorted(lambda x: x.name).mapped("name"), + ) + + def test_sequence_order(self): + partner_titles = self.env["res.partner.title"].search([]) + partner_first = partner_titles[0] + partner_first.sequence = 100 + partner_last = partner_titles[-1] + partner_last.sequence = 0 + partner_titles = self.env["res.partner.title"].search([]) + self.assertEqual( + partner_titles.mapped("name"), + partner_titles.sorted(lambda x: (x.sequence, x.name)).mapped("name"), + ) + # last and first inverted + self.assertEqual(partner_titles[0], partner_last) + self.assertEqual(partner_titles[-1], partner_first) diff --git a/partner_title_order/views/res_partner_title_views.xml b/partner_title_order/views/res_partner_title_views.xml new file mode 100644 index 000000000..c4217d253 --- /dev/null +++ b/partner_title_order/views/res_partner_title_views.xml @@ -0,0 +1,26 @@ + + + + + + res.partner.title + + + + + + + + + + res.partner.title + + + + + + + + + diff --git a/setup/partner_title_order/odoo/addons/partner_title_order b/setup/partner_title_order/odoo/addons/partner_title_order new file mode 120000 index 000000000..3c3da644a --- /dev/null +++ b/setup/partner_title_order/odoo/addons/partner_title_order @@ -0,0 +1 @@ +../../../../partner_title_order \ No newline at end of file diff --git a/setup/partner_title_order/setup.py b/setup/partner_title_order/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/partner_title_order/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)