diff --git a/partner_manual_rank/README.rst b/partner_manual_rank/README.rst new file mode 100644 index 00000000000..779e6cef316 --- /dev/null +++ b/partner_manual_rank/README.rst @@ -0,0 +1,100 @@ +=================== +Partner Manual Rank +=================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:8de928cdce120a1f5d9b7631f949818828d315d42e533152fdfd0ca93254ed9d + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_manual_rank + :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_manual_rank + :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 restores the functionality of <= 12.0 to set contacts as +customer or vendor, and allows users to create custom filters on a more +user-friendly manner. + +**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 +------- + +* ForgeFlow +* Vauxoo + +Contributors +------------ + +- Miquel Raïch +- Francesco Apruzzese +- Francisco Luna +- Luis González +- Le Dinh Tien + +Other credits +------------- + +- ForgeFlow, S.L. +- Vauxoo + +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. + +.. |maintainer-luisg123v| image:: https://github.com/luisg123v.png?size=40px + :target: https://github.com/luisg123v + :alt: luisg123v +.. |maintainer-frahikLV| image:: https://github.com/frahikLV.png?size=40px + :target: https://github.com/frahikLV + :alt: frahikLV + +Current `maintainers `__: + +|maintainer-luisg123v| |maintainer-frahikLV| + +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_manual_rank/__init__.py b/partner_manual_rank/__init__.py new file mode 100644 index 00000000000..f737d1d7e9b --- /dev/null +++ b/partner_manual_rank/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models +from odoo.tools.sql import column_exists diff --git a/partner_manual_rank/__manifest__.py b/partner_manual_rank/__manifest__.py new file mode 100644 index 00000000000..aa622454c3b --- /dev/null +++ b/partner_manual_rank/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2021 ForgeFlow S.L. +# Copyright 2022 Vauxoo, S.A. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Partner Manual Rank", + "summary": "Be able to manually flag partners as customer or supplier.", + "version": "18.0.1.0.0", + "category": "Partner Management", + "website": "https://github.com/OCA/partner-contact", + "author": "ForgeFlow, Vauxoo, Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "maintainers": ["luisg123v", "frahikLV"], + "depends": ["account"], + "data": ["views/res_partner.xml"], +} diff --git a/partner_manual_rank/i18n/de.po b/partner_manual_rank/i18n/de.po new file mode 100644 index 00000000000..789505fa688 --- /dev/null +++ b/partner_manual_rank/i18n/de.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_manual_rank +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-07-18 15:30+0000\n" +"Last-Translator: Nils Coenen \n" +"Language-Team: none\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.6.2\n" + +#. module: partner_manual_rank +#: model:ir.model,name:partner_manual_rank.model_res_partner +msgid "Contact" +msgstr "Kontakt" + +#. module: partner_manual_rank +#: model_terms:ir.ui.view,arch_db:partner_manual_rank.view_res_partner_filter +msgid "Customers" +msgstr "Kunden" + +#. module: partner_manual_rank +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_partner__is_customer +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_users__is_customer +msgid "Is a Customer" +msgstr "Ist ein Kunde" + +#. module: partner_manual_rank +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_partner__is_supplier +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_users__is_supplier +msgid "Is a Supplier" +msgstr "Ist ein Lieferant" + +#. module: partner_manual_rank +#. odoo-python +#: code:addons/partner_manual_rank/models/res_partner.py:0 +#: code:addons/partner_manual_rank/models/res_partner.py:0 +#, python-format +msgid "Operation not supported" +msgstr "Vorgang wird nicht unterstützt" + +#. module: partner_manual_rank +#: model_terms:ir.ui.view,arch_db:partner_manual_rank.view_res_partner_filter +msgid "Suppliers" +msgstr "Lieferanten" diff --git a/partner_manual_rank/i18n/es.po b/partner_manual_rank/i18n/es.po new file mode 100644 index 00000000000..f71a8690632 --- /dev/null +++ b/partner_manual_rank/i18n/es.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_manual_rank +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-01-11 09:11+0000\n" +"PO-Revision-Date: 2023-01-11 09:11+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: partner_manual_rank +#: model:ir.model,name:partner_manual_rank.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: partner_manual_rank +#: model_terms:ir.ui.view,arch_db:partner_manual_rank.view_res_partner_filter +msgid "Customers" +msgstr "Clientes" + +#. module: partner_manual_rank +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_partner__is_customer +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_users__is_customer +msgid "Is a Customer" +msgstr "Es cliente" + +#. module: partner_manual_rank +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_partner__is_supplier +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_users__is_supplier +msgid "Is a Supplier" +msgstr "Es proveedor" + +#. module: partner_manual_rank +#. odoo-python +#: code:addons/partner_manual_rank/models/res_partner.py:0 +#, python-format +msgid "Operation not supported" +msgstr "Operación no permitida" + +#. module: partner_manual_rank +#: model_terms:ir.ui.view,arch_db:partner_manual_rank.view_res_partner_filter +msgid "Suppliers" +msgstr "Proveedores" diff --git a/partner_manual_rank/i18n/fr.po b/partner_manual_rank/i18n/fr.po new file mode 100644 index 00000000000..c02524406de --- /dev/null +++ b/partner_manual_rank/i18n/fr.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_manual_rank +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-05-02 11:33+0000\n" +"Last-Translator: Hughes Damry \n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.14.1\n" + +#. module: partner_manual_rank +#: model:ir.model,name:partner_manual_rank.model_res_partner +msgid "Contact" +msgstr "Contact" + +#. module: partner_manual_rank +#: model_terms:ir.ui.view,arch_db:partner_manual_rank.view_res_partner_filter +msgid "Customers" +msgstr "Clients" + +#. module: partner_manual_rank +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_partner__is_customer +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_users__is_customer +msgid "Is a Customer" +msgstr "Client" + +#. module: partner_manual_rank +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_partner__is_supplier +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_users__is_supplier +msgid "Is a Supplier" +msgstr "Fournisseur" + +#. module: partner_manual_rank +#. odoo-python +#: code:addons/partner_manual_rank/models/res_partner.py:0 +#, python-format +msgid "Operation not supported" +msgstr "Opération non supportée" + +#. module: partner_manual_rank +#: model_terms:ir.ui.view,arch_db:partner_manual_rank.view_res_partner_filter +msgid "Suppliers" +msgstr "Fournisseurs" diff --git a/partner_manual_rank/i18n/it.po b/partner_manual_rank/i18n/it.po new file mode 100644 index 00000000000..331d9269e9d --- /dev/null +++ b/partner_manual_rank/i18n/it.po @@ -0,0 +1,60 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_manual_rank +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-12-26 14:48+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: partner_manual_rank +#: model:ir.model,name:partner_manual_rank.model_res_partner +msgid "Contact" +msgstr "Contatto" + +#. module: partner_manual_rank +#: model_terms:ir.ui.view,arch_db:partner_manual_rank.view_res_partner_filter +msgid "Customers" +msgstr "Clienti" + +#. module: partner_manual_rank +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_partner__is_customer +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_users__is_customer +msgid "Is a Customer" +msgstr "È un cliente" + +#. module: partner_manual_rank +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_partner__is_supplier +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_users__is_supplier +msgid "Is a Supplier" +msgstr "È un fornitore" + +#. module: partner_manual_rank +#. odoo-python +#: code:addons/partner_manual_rank/models/res_partner.py:0 +#, python-format +msgid "Operation not supported" +msgstr "Operazione non supportata" + +#. module: partner_manual_rank +#: model_terms:ir.ui.view,arch_db:partner_manual_rank.view_res_partner_filter +msgid "Suppliers" +msgstr "Fornitori" + +#~ msgid "Display Name" +#~ msgstr "Nome visualizzato" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Ultima modifica il" diff --git a/partner_manual_rank/i18n/partner_manual_rank.pot b/partner_manual_rank/i18n/partner_manual_rank.pot new file mode 100644 index 00000000000..663271c79ff --- /dev/null +++ b/partner_manual_rank/i18n/partner_manual_rank.pot @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_manual_rank +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: partner_manual_rank +#: model:ir.model,name:partner_manual_rank.model_res_partner +msgid "Contact" +msgstr "" + +#. module: partner_manual_rank +#: model_terms:ir.ui.view,arch_db:partner_manual_rank.view_res_partner_filter +msgid "Customers" +msgstr "" + +#. module: partner_manual_rank +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_partner__is_customer +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_users__is_customer +msgid "Is a Customer" +msgstr "" + +#. module: partner_manual_rank +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_partner__is_supplier +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_users__is_supplier +msgid "Is a Supplier" +msgstr "" + +#. module: partner_manual_rank +#. odoo-python +#: code:addons/partner_manual_rank/models/res_partner.py:0 +#: code:addons/partner_manual_rank/models/res_partner.py:0 +#, python-format +msgid "Operation not supported" +msgstr "" + +#. module: partner_manual_rank +#: model_terms:ir.ui.view,arch_db:partner_manual_rank.view_res_partner_filter +msgid "Suppliers" +msgstr "" diff --git a/partner_manual_rank/i18n/pt.po b/partner_manual_rank/i18n/pt.po new file mode 100644 index 00000000000..a7d7e78e093 --- /dev/null +++ b/partner_manual_rank/i18n/pt.po @@ -0,0 +1,60 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_manual_rank +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-04-19 14:05+0000\n" +"Last-Translator: Pedro Castro Silva \n" +"Language-Team: none\n" +"Language: pt\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: partner_manual_rank +#: model:ir.model,name:partner_manual_rank.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: partner_manual_rank +#: model_terms:ir.ui.view,arch_db:partner_manual_rank.view_res_partner_filter +msgid "Customers" +msgstr "" + +#. module: partner_manual_rank +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_partner__is_customer +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_users__is_customer +msgid "Is a Customer" +msgstr "É Cliente" + +#. module: partner_manual_rank +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_partner__is_supplier +#: model:ir.model.fields,field_description:partner_manual_rank.field_res_users__is_supplier +msgid "Is a Supplier" +msgstr "É Fornecedor" + +#. module: partner_manual_rank +#. odoo-python +#: code:addons/partner_manual_rank/models/res_partner.py:0 +#, python-format +msgid "Operation not supported" +msgstr "" + +#. module: partner_manual_rank +#: model_terms:ir.ui.view,arch_db:partner_manual_rank.view_res_partner_filter +msgid "Suppliers" +msgstr "" + +#~ msgid "Display Name" +#~ msgstr "Nome a Exibir" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Última Modificação em" diff --git a/partner_manual_rank/models/__init__.py b/partner_manual_rank/models/__init__.py new file mode 100644 index 00000000000..284a83ff1c2 --- /dev/null +++ b/partner_manual_rank/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import res_partner diff --git a/partner_manual_rank/models/res_partner.py b/partner_manual_rank/models/res_partner.py new file mode 100644 index 00000000000..9411c37ebb3 --- /dev/null +++ b/partner_manual_rank/models/res_partner.py @@ -0,0 +1,74 @@ +# Copyright 2021 ForgeFlow, S.L. +# Copyright 2022 Vauxoo, S.A. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import _, api, fields, models +from odoo.exceptions import UserError + +DOMAIN_SEARCH = { + ("=", False): ("=", 0), + ("=", True): (">=", 1), + ("!=", False): (">=", 1), + ("!=", True): ("=", 0), +} + + +class ResPartner(models.Model): + _inherit = "res.partner" + + is_customer = fields.Boolean( + compute="_compute_is_customer", + inverse="_inverse_is_customer", + search="_search_is_customer", + string="Is a Customer", + default=lambda self: self._default_is_customer(), + ) + is_supplier = fields.Boolean( + compute="_compute_is_supplier", + inverse="_inverse_is_supplier", + search="_search_is_supplier", + string="Is a Supplier", + default=lambda self: self._default_is_supplier(), + ) + + @api.depends("customer_rank") + def _compute_is_customer(self): + for partner in self: + if not partner.is_customer: + partner.is_customer = bool(partner.customer_rank) + + @api.depends("supplier_rank") + def _compute_is_supplier(self): + for partner in self: + if not partner.is_supplier: + partner.is_supplier = bool(partner.supplier_rank) + + def _inverse_is_customer(self): + self.filtered(lambda p: not p.is_customer).write({"customer_rank": 0}) + self.filtered(lambda p: p.is_customer and not p.customer_rank).write( + {"customer_rank": 1} + ) + + def _search_is_customer(self, operator, value): + if operator not in ["=", "!="] or not isinstance(value, bool): + raise UserError(_("Operation not supported")) + operator, value = DOMAIN_SEARCH.get((operator, value)) + return [("customer_rank", operator, value)] + + def _inverse_is_supplier(self): + self.filtered(lambda p: not p.is_supplier).write({"supplier_rank": 0}) + self.filtered(lambda p: p.is_supplier and not p.supplier_rank).write( + {"supplier_rank": 1} + ) + + def _search_is_supplier(self, operator, value): + if operator not in ["=", "!="] or not isinstance(value, bool): + raise UserError(_("Operation not supported")) + operator, value = DOMAIN_SEARCH.get((operator, value)) + return [("supplier_rank", operator, value)] + + def _default_is_customer(self): + return self.env.context.get("res_partner_search_mode") == "customer" + + def _default_is_supplier(self): + return self.env.context.get("res_partner_search_mode") == "supplier" diff --git a/partner_manual_rank/pyproject.toml b/partner_manual_rank/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/partner_manual_rank/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/partner_manual_rank/readme/CONTRIBUTORS.md b/partner_manual_rank/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..71a3c4a1dc5 --- /dev/null +++ b/partner_manual_rank/readme/CONTRIBUTORS.md @@ -0,0 +1,5 @@ +- Miquel Raïch \<\> +- Francesco Apruzzese \<\> +- Francisco Luna \<\> +- Luis González \<\> +- Le Dinh Tien \<\> diff --git a/partner_manual_rank/readme/CREDITS.md b/partner_manual_rank/readme/CREDITS.md new file mode 100644 index 00000000000..7c7f24a4c86 --- /dev/null +++ b/partner_manual_rank/readme/CREDITS.md @@ -0,0 +1,2 @@ +- ForgeFlow, S.L. +- Vauxoo diff --git a/partner_manual_rank/readme/DESCRIPTION.md b/partner_manual_rank/readme/DESCRIPTION.md new file mode 100644 index 00000000000..29cd30ba5af --- /dev/null +++ b/partner_manual_rank/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +This module restores the functionality of \<= 12.0 to set contacts as +customer or vendor, and allows users to create custom filters on a more +user-friendly manner. diff --git a/partner_manual_rank/static/description/icon.png b/partner_manual_rank/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/partner_manual_rank/static/description/icon.png differ diff --git a/partner_manual_rank/static/description/index.html b/partner_manual_rank/static/description/index.html new file mode 100644 index 00000000000..1f1bdd0fddb --- /dev/null +++ b/partner_manual_rank/static/description/index.html @@ -0,0 +1,440 @@ + + + + + +Partner Manual Rank + + + +
+

Partner Manual Rank

+ + +

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

+

This module restores the functionality of <= 12.0 to set contacts as +customer or vendor, and allows users to create custom filters on a more +user-friendly manner.

+

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

+
    +
  • ForgeFlow
  • +
  • Vauxoo
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+
    +
  • ForgeFlow, S.L.
  • +
  • Vauxoo
  • +
+
+
+

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.

+

Current maintainers:

+

luisg123v frahikLV

+

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_manual_rank/tests/__init__.py b/partner_manual_rank/tests/__init__.py new file mode 100644 index 00000000000..d57d215f908 --- /dev/null +++ b/partner_manual_rank/tests/__init__.py @@ -0,0 +1 @@ +from . import test_res_partner diff --git a/partner_manual_rank/tests/test_res_partner.py b/partner_manual_rank/tests/test_res_partner.py new file mode 100644 index 00000000000..0443eed3f27 --- /dev/null +++ b/partner_manual_rank/tests/test_res_partner.py @@ -0,0 +1,102 @@ +from odoo.exceptions import UserError +from odoo.tests import common, tagged + + +@tagged("res_partner") +class TestResPartner(common.TransactionCase): + def setUp(self): + super().setUp() + self.partner = self.env["res.partner"].create({"name": "Microsoft Corporation"}) + self.partner_2 = self.env["res.partner"].create({"name": "Apple Inc."}) + + def test_01_is_customer(self): + partners = self.partner | self.partner_2 + self.assertRecordValues( + partners, + [ + {"is_customer": False, "customer_rank": 0}, + {"is_customer": False, "customer_rank": 0}, + ], + ) + self.partner.write({"is_customer": True}) + self.assertRecordValues( + partners, + [ + {"is_customer": True, "customer_rank": 1}, + {"is_customer": False, "customer_rank": 0}, + ], + ) + partners_found = self.env["res.partner"].search([("is_customer", "=", True)]) + self.assertIn(self.partner, partners_found) + partners.write({"is_customer": True}) + self.assertRecordValues( + partners, + [ + {"is_customer": True, "customer_rank": 1}, + {"is_customer": True, "customer_rank": 1}, + ], + ) + partners.write({"is_customer": False}) + self.assertRecordValues( + partners, + [ + {"is_customer": False, "customer_rank": 0}, + {"is_customer": False, "customer_rank": 0}, + ], + ) + partners.write({"customer_rank": 1}) + self.assertRecordValues( + partners, + [ + {"is_customer": True, "customer_rank": 1}, + {"is_customer": True, "customer_rank": 1}, + ], + ) + with self.assertRaisesRegex(UserError, "Operation not supported"): + self.env["res.partner"].search([("is_customer", "in", [True, False])]) + + def test_02_is_supplier(self): + partners = self.partner | self.partner_2 + self.assertRecordValues( + partners, + [ + {"is_supplier": False, "supplier_rank": 0}, + {"is_supplier": False, "supplier_rank": 0}, + ], + ) + self.partner.write({"is_supplier": True}) + self.assertRecordValues( + partners, + [ + {"is_supplier": True, "supplier_rank": 1}, + {"is_supplier": False, "supplier_rank": 0}, + ], + ) + partners_found = self.env["res.partner"].search([("is_supplier", "=", True)]) + self.assertIn(self.partner, partners_found) + partners.write({"is_supplier": True}) + self.assertRecordValues( + partners, + [ + {"is_supplier": True, "supplier_rank": 1}, + {"is_supplier": True, "supplier_rank": 1}, + ], + ) + partners.write({"is_supplier": False}) + self.assertRecordValues( + partners, + [ + {"is_supplier": False, "supplier_rank": 0}, + {"is_supplier": False, "supplier_rank": 0}, + ], + ) + partners.write({"supplier_rank": 1}) + self.assertRecordValues( + partners, + [ + {"is_supplier": True, "supplier_rank": 1}, + {"is_supplier": True, "supplier_rank": 1}, + ], + ) + with self.assertRaisesRegex(UserError, "Operation not supported"): + self.env["res.partner"].search([("is_supplier", "in", [True, False])]) diff --git a/partner_manual_rank/views/res_partner.xml b/partner_manual_rank/views/res_partner.xml new file mode 100644 index 00000000000..01a9a94ce9f --- /dev/null +++ b/partner_manual_rank/views/res_partner.xml @@ -0,0 +1,56 @@ + + + + partner_manual_rank.view_partner_filter + + res.partner + + + + + + + + + partner_manual_rank.view_partner_filter.account + + res.partner + + + 1 + + + 1 + + + + + partner_manual_rank.view_partner_form + + res.partner + + + + + + + + + + + + + + + + + +