diff --git a/partner_manual_rank/README.rst b/partner_manual_rank/README.rst new file mode 100644 index 000000000..d9c722456 --- /dev/null +++ b/partner_manual_rank/README.rst @@ -0,0 +1,74 @@ +=================== +Partner Manual Rank +=================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/13.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-13-0/partner-contact-13-0-partner_manual_rank + :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/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds the ability to manually flag partners as customer or supplier +from the partner form view. + +**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 +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Miquel Raïch + +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_manual_rank/__init__.py b/partner_manual_rank/__init__.py new file mode 100644 index 000000000..49d00bcd6 --- /dev/null +++ b/partner_manual_rank/__init__.py @@ -0,0 +1,31 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models +from odoo.tools.sql import column_exists + + +def pre_init_hook(cr): + if not column_exists(cr, "res_partner", "is_customer"): + cr.execute( + """ + ALTER TABLE res_partner + ADD COLUMN is_customer boolean""", + ) + cr.execute( + """ + UPDATE res_partner + SET is_customer = customer_rank::boolean + """ + ) + if not column_exists(cr, "res_partner", "is_supplier"): + cr.execute( + """ + ALTER TABLE res_partner + ADD COLUMN is_supplier boolean""", + ) + cr.execute( + """ + UPDATE res_partner + SET is_supplier = supplier_rank::boolean + """ + ) diff --git a/partner_manual_rank/__manifest__.py b/partner_manual_rank/__manifest__.py new file mode 100644 index 000000000..ea11a2f83 --- /dev/null +++ b/partner_manual_rank/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2021 ForgeFlow S.L. +# 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": "14.0.1.0.0", + "category": "Partner Management", + "website": "https://github.com/OCA/partner-contact", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "depends": ["account"], + "data": ["views/res_partner.xml"], + "pre_init_hook": "pre_init_hook", +} 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 000000000..d32eeac27 --- /dev/null +++ b/partner_manual_rank/i18n/partner_manual_rank.pot @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_manual_rank +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.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: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 "" diff --git a/partner_manual_rank/models/__init__.py b/partner_manual_rank/models/__init__.py new file mode 100644 index 000000000..284a83ff1 --- /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 000000000..da76efdeb --- /dev/null +++ b/partner_manual_rank/models/res_partner.py @@ -0,0 +1,49 @@ +# Copyright 2021 ForgeFlow, S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + is_customer = fields.Boolean( + compute="_compute_is_customer", + inverse="_inverse_is_customer", + store=True, + readonly=False, + string="Is a Customer", + ) + is_supplier = fields.Boolean( + compute="_compute_is_supplier", + inverse="_inverse_is_supplier", + store=True, + readonly=False, + string="Is a Supplier", + ) + + @api.depends("customer_rank") + def _compute_is_customer(self): + for partner in self: + partner.is_customer = bool(partner.customer_rank) + + @api.depends("supplier_rank") + def _compute_is_supplier(self): + for partner in self: + partner.is_supplier = bool(partner.supplier_rank) + + def _inverse_is_customer(self): + for partner in self: + partners = partner | partner.commercial_partner_id + if partner.is_customer: + partners._increase_rank("customer_rank") + else: + partners.customer_rank = 0 + + def _inverse_is_supplier(self): + for partner in self: + partners = partner | partner.commercial_partner_id + if partner.is_supplier: + partners._increase_rank("supplier_rank") + else: + partners.supplier_rank = 0 diff --git a/partner_manual_rank/readme/CONTRIBUTORS.rst b/partner_manual_rank/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..7202adf84 --- /dev/null +++ b/partner_manual_rank/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Miquel Raïch +* Francesco Apruzzese diff --git a/partner_manual_rank/readme/DESCRIPTION.rst b/partner_manual_rank/readme/DESCRIPTION.rst new file mode 100644 index 000000000..d52bd00f6 --- /dev/null +++ b/partner_manual_rank/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module adds the ability to manually flag partners as customer or supplier +from the partner form view. diff --git a/partner_manual_rank/static/description/icon.png b/partner_manual_rank/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 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 000000000..d81f51961 --- /dev/null +++ b/partner_manual_rank/static/description/index.html @@ -0,0 +1,420 @@ + + + + + + +Partner Manual Rank + + + +
+

Partner Manual Rank

+ + +

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

+

This module adds the ability to manually flag partners as customer or supplier +from the partner form view.

+

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

+
    +
  • ForgeFlow
  • +
+
+
+

Contributors

+ +
+
+

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_manual_rank/views/res_partner.xml b/partner_manual_rank/views/res_partner.xml new file mode 100644 index 000000000..592717a9d --- /dev/null +++ b/partner_manual_rank/views/res_partner.xml @@ -0,0 +1,35 @@ + + + + partner_manual_rank.view_partner_filter + + res.partner + + + + + + + + + partner_manual_rank.view_partner_form + + res.partner + + + + + + + + + + + + + + + + + + diff --git a/setup/partner_manual_rank/odoo/addons/partner_manual_rank b/setup/partner_manual_rank/odoo/addons/partner_manual_rank new file mode 120000 index 000000000..4187c4b85 --- /dev/null +++ b/setup/partner_manual_rank/odoo/addons/partner_manual_rank @@ -0,0 +1 @@ +../../../../partner_manual_rank \ No newline at end of file diff --git a/setup/partner_manual_rank/setup.py b/setup/partner_manual_rank/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/partner_manual_rank/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)