diff --git a/sale_partner_selectable_option/README.rst b/sale_partner_selectable_option/README.rst new file mode 100644 index 00000000000..c2f1f8adc24 --- /dev/null +++ b/sale_partner_selectable_option/README.rst @@ -0,0 +1,114 @@ +============================== +Sale Partner Selectable Option +============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:89d65b7254f42288a61f34981549e8d4ccb9890dc4467dd62f2d6f8bfe6ce9af + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fsale--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/sale-workflow/tree/18.0/sale_partner_selectable_option + :alt: OCA/sale-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-sale_partner_selectable_option + :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/sale-workflow&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module limits the partners to be selected in the sales orders +according to the "Selectable in orders" field. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +The "Selectable in sale orders" field is set to True by default. To +change this default to False, adjust the system parameter +'sale_partner_selectable_option.default_sale_selectable' by setting it +to "0". + +Usage +===== + +To use this module, you need to: + +1. Go to **Contacts > Contacts** +2. Create a record and uncheck the "Selectable in orders" box on the + Sales part of the "Sales & Purchases" tab. +3. Go to **Sales > Orders > Quotations** +4. Create a record and the previously created partner will not appear in + the Customer field. + +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 +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__: + + - Víctor Martínez + - Pedro M. Baeza + - César A. Sánchez + - Juan Carlos Oñate + +- `Binhex Systems Solutions `__: + + - Deriman Alonso + +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-victoralmau| image:: https://github.com/victoralmau.png?size=40px + :target: https://github.com/victoralmau + :alt: victoralmau + +Current `maintainer `__: + +|maintainer-victoralmau| + +This module is part of the `OCA/sale-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_partner_selectable_option/__init__.py b/sale_partner_selectable_option/__init__.py new file mode 100644 index 00000000000..69f7babdfb1 --- /dev/null +++ b/sale_partner_selectable_option/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/sale_partner_selectable_option/__manifest__.py b/sale_partner_selectable_option/__manifest__.py new file mode 100644 index 00000000000..6e54711b08c --- /dev/null +++ b/sale_partner_selectable_option/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Sale Partner Selectable Option", + "version": "18.0.1.0.0", + "category": "Sales Management", + "website": "https://github.com/OCA/sale-workflow", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": ["sale"], + "data": ["data/ir_config_parameter.xml", "views/res_partner_view.xml"], + "installable": True, + "maintainers": ["victoralmau"], +} diff --git a/sale_partner_selectable_option/data/ir_config_parameter.xml b/sale_partner_selectable_option/data/ir_config_parameter.xml new file mode 100644 index 00000000000..41db97e2885 --- /dev/null +++ b/sale_partner_selectable_option/data/ir_config_parameter.xml @@ -0,0 +1,9 @@ + + + + + sale_partner_selectable_option.default_sale_selectable + 1 + + + diff --git a/sale_partner_selectable_option/i18n/es.po b/sale_partner_selectable_option/i18n/es.po new file mode 100644 index 00000000000..cf4fc369540 --- /dev/null +++ b/sale_partner_selectable_option/i18n/es.po @@ -0,0 +1,39 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_partner_selectable_option +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-12-02 15:52+0000\n" +"PO-Revision-Date: 2023-07-25 12:10+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: sale_partner_selectable_option +#: model:ir.model,name:sale_partner_selectable_option.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: sale_partner_selectable_option +#: model:ir.model,name:sale_partner_selectable_option.model_sale_order +msgid "Sales Order" +msgstr "Orden de Venta" + +#. module: sale_partner_selectable_option +#: model_terms:ir.ui.view,arch_db:sale_partner_selectable_option.view_partner_form +msgid "Selectable in orders" +msgstr "Seleccionable en pedidos" + +#. module: sale_partner_selectable_option +#: model:ir.model.fields,field_description:sale_partner_selectable_option.field_res_partner__sale_selectable +#: model:ir.model.fields,field_description:sale_partner_selectable_option.field_res_users__sale_selectable +msgid "Selectable in sale orders" +msgstr "Seleccionable en pedidos de venta" diff --git a/sale_partner_selectable_option/i18n/it.po b/sale_partner_selectable_option/i18n/it.po new file mode 100644 index 00000000000..000bc2db624 --- /dev/null +++ b/sale_partner_selectable_option/i18n/it.po @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_partner_selectable_option +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-12-04 06:35+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: sale_partner_selectable_option +#: model:ir.model,name:sale_partner_selectable_option.model_res_partner +msgid "Contact" +msgstr "Contatto" + +#. module: sale_partner_selectable_option +#: model:ir.model,name:sale_partner_selectable_option.model_sale_order +msgid "Sales Order" +msgstr "Ordine di vendita" + +#. module: sale_partner_selectable_option +#: model_terms:ir.ui.view,arch_db:sale_partner_selectable_option.view_partner_form +msgid "Selectable in orders" +msgstr "Selezionabile negli ordini" + +#. module: sale_partner_selectable_option +#: model:ir.model.fields,field_description:sale_partner_selectable_option.field_res_partner__sale_selectable +#: model:ir.model.fields,field_description:sale_partner_selectable_option.field_res_users__sale_selectable +msgid "Selectable in sale orders" +msgstr "Selezionabile negli ordini di vendita" diff --git a/sale_partner_selectable_option/i18n/sale_partner_selectable_option.pot b/sale_partner_selectable_option/i18n/sale_partner_selectable_option.pot new file mode 100644 index 00000000000..399ca79aaee --- /dev/null +++ b/sale_partner_selectable_option/i18n/sale_partner_selectable_option.pot @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_partner_selectable_option +# +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: sale_partner_selectable_option +#: model:ir.model,name:sale_partner_selectable_option.model_res_partner +msgid "Contact" +msgstr "" + +#. module: sale_partner_selectable_option +#: model:ir.model,name:sale_partner_selectable_option.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: sale_partner_selectable_option +#: model_terms:ir.ui.view,arch_db:sale_partner_selectable_option.view_partner_form +msgid "Selectable in orders" +msgstr "" + +#. module: sale_partner_selectable_option +#: model:ir.model.fields,field_description:sale_partner_selectable_option.field_res_partner__sale_selectable +#: model:ir.model.fields,field_description:sale_partner_selectable_option.field_res_users__sale_selectable +msgid "Selectable in sale orders" +msgstr "" diff --git a/sale_partner_selectable_option/models/__init__.py b/sale_partner_selectable_option/models/__init__.py new file mode 100644 index 00000000000..34dad8d9a1e --- /dev/null +++ b/sale_partner_selectable_option/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import res_partner +from . import sale_order diff --git a/sale_partner_selectable_option/models/res_partner.py b/sale_partner_selectable_option/models/res_partner.py new file mode 100644 index 00000000000..6ac930bd03d --- /dev/null +++ b/sale_partner_selectable_option/models/res_partner.py @@ -0,0 +1,22 @@ +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class Partner(models.Model): + _inherit = "res.partner" + + sale_selectable = fields.Boolean( + string="Selectable in sale orders", + default=lambda self: self._default_sale_selectable(), + ) + + @api.model + def _default_sale_selectable(self): + param = ( + self.env["ir.config_parameter"] + .sudo() + .get_param("sale_partner_selectable_option.default_sale_selectable") + ) + return False if param == "0" else True diff --git a/sale_partner_selectable_option/models/sale_order.py b/sale_partner_selectable_option/models/sale_order.py new file mode 100644 index 00000000000..3847d3dd7fa --- /dev/null +++ b/sale_partner_selectable_option/models/sale_order.py @@ -0,0 +1,24 @@ +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from lxml import etree + +from odoo import api, models + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + @api.model + def get_view(self, view_id=None, view_type="form", **options): + res = super().get_view(view_id, view_type, **options) + if view_type == "form": + order_xml = etree.XML(res["arch"]) + partner_id_fields = order_xml.xpath("//field[@name='partner_id']") + if partner_id_fields: + partner_id_field = partner_id_fields[0] + domain = partner_id_field.get("domain", "[]").replace( + "[", "[('sale_selectable', '=', True)," + ) + partner_id_field.attrib["domain"] = domain + res["arch"] = etree.tostring(order_xml) + return res diff --git a/sale_partner_selectable_option/pyproject.toml b/sale_partner_selectable_option/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/sale_partner_selectable_option/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/sale_partner_selectable_option/readme/CONFIGURE.md b/sale_partner_selectable_option/readme/CONFIGURE.md new file mode 100644 index 00000000000..1f3baf3d909 --- /dev/null +++ b/sale_partner_selectable_option/readme/CONFIGURE.md @@ -0,0 +1,4 @@ +The "Selectable in sale orders" field is set to True by default. To +change this default to False, adjust the system parameter +'sale_partner_selectable_option.default_sale_selectable' by setting it +to "0". diff --git a/sale_partner_selectable_option/readme/CONTRIBUTORS.md b/sale_partner_selectable_option/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..288e267f9a7 --- /dev/null +++ b/sale_partner_selectable_option/readme/CONTRIBUTORS.md @@ -0,0 +1,8 @@ +- [Tecnativa](https://www.tecnativa.com): + - Víctor Martínez + - Pedro M. Baeza + - César A. Sánchez \<\> + - Juan Carlos Oñate + +- [Binhex Systems Solutions](https://binhex.cloud/): + - Deriman Alonso \<\> diff --git a/sale_partner_selectable_option/readme/DESCRIPTION.md b/sale_partner_selectable_option/readme/DESCRIPTION.md new file mode 100644 index 00000000000..4a42e116091 --- /dev/null +++ b/sale_partner_selectable_option/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module limits the partners to be selected in the sales orders +according to the "Selectable in orders" field. diff --git a/sale_partner_selectable_option/readme/USAGE.md b/sale_partner_selectable_option/readme/USAGE.md new file mode 100644 index 00000000000..0e7ca458f24 --- /dev/null +++ b/sale_partner_selectable_option/readme/USAGE.md @@ -0,0 +1,8 @@ +To use this module, you need to: + +1. Go to **Contacts \> Contacts** +2. Create a record and uncheck the "Selectable in orders" box on the + Sales part of the "Sales & Purchases" tab. +3. Go to **Sales \> Orders \> Quotations** +4. Create a record and the previously created partner will not appear + in the Customer field. diff --git a/sale_partner_selectable_option/static/description/icon.png b/sale_partner_selectable_option/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/sale_partner_selectable_option/static/description/icon.png differ diff --git a/sale_partner_selectable_option/static/description/index.html b/sale_partner_selectable_option/static/description/index.html new file mode 100644 index 00000000000..94443e720d1 --- /dev/null +++ b/sale_partner_selectable_option/static/description/index.html @@ -0,0 +1,457 @@ + + + + + +Sale Partner Selectable Option + + + +
+

Sale Partner Selectable Option

+ + +

Beta License: AGPL-3 OCA/sale-workflow Translate me on Weblate Try me on Runboat

+

This module limits the partners to be selected in the sales orders +according to the “Selectable in orders” field.

+

Table of contents

+ +
+

Configuration

+

The “Selectable in sale orders” field is set to True by default. To +change this default to False, adjust the system parameter +‘sale_partner_selectable_option.default_sale_selectable’ by setting it +to “0”.

+
+
+

Usage

+

To use this module, you need to:

+
    +
  1. Go to Contacts > Contacts
  2. +
  3. Create a record and uncheck the “Selectable in orders” box on the +Sales part of the “Sales & Purchases” tab.
  4. +
  5. Go to Sales > Orders > Quotations
  6. +
  7. Create a record and the previously created partner will not appear in +the Customer field.
  8. +
+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

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.

+

Current maintainer:

+

victoralmau

+

This module is part of the OCA/sale-workflow project on GitHub.

+

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

+
+
+
+ + diff --git a/sale_partner_selectable_option/tests/__init__.py b/sale_partner_selectable_option/tests/__init__.py new file mode 100644 index 00000000000..9e9d23376e2 --- /dev/null +++ b/sale_partner_selectable_option/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_sale_partner_selectable_option diff --git a/sale_partner_selectable_option/tests/test_sale_partner_selectable_option.py b/sale_partner_selectable_option/tests/test_sale_partner_selectable_option.py new file mode 100644 index 00000000000..77acc579fdb --- /dev/null +++ b/sale_partner_selectable_option/tests/test_sale_partner_selectable_option.py @@ -0,0 +1,21 @@ +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from lxml import etree + +from odoo.addons.base.tests.common import BaseCommon + + +class TestSalePartnerSelectableOption(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + + def test_sale_order(self): + result = self.env["sale.order"].get_view( + self.env.ref("sale.view_order_form").id, + "form", + ) + doc = etree.XML(result["arch"]) + field = doc.xpath("//field[@name='partner_id']") + domain = field[0].get("domain") + self.assertTrue("('sale_selectable', '=', True)" in domain) diff --git a/sale_partner_selectable_option/views/res_partner_view.xml b/sale_partner_selectable_option/views/res_partner_view.xml new file mode 100644 index 00000000000..c1006b48567 --- /dev/null +++ b/sale_partner_selectable_option/views/res_partner_view.xml @@ -0,0 +1,28 @@ + + + + + Add sale_selectable to partner form + res.partner + + + + + + + + + res.partner.view.buttons + res.partner + + + + not sale_selectable + + + + +