diff --git a/sale_partner_display_ref/README.rst b/sale_partner_display_ref/README.rst new file mode 100644 index 00000000000..45dfa449ce2 --- /dev/null +++ b/sale_partner_display_ref/README.rst @@ -0,0 +1,109 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +============================== +Sale Partner Display Reference +============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:3f6d47315481b2141d5d8ac0d49379f06f318461cef0c8fbea60a42912acf580 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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/19.0/sale_partner_display_ref + :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-19-0/sale-workflow-19-0-sale_partner_display_ref + :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=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module prefixes the customer reference (``res.partner.ref``) to the +partner's ``display_name`` whenever it is rendered inside a Sales view — +shown as ``[C00123] Acme Corp`` in the customer field of a sales +quotation or order, both in the dropdown and on the selected value. + +The decoration mechanism lives in the generic ``partner_display_ref`` +module; this module only injects the ``partner_display_ref_field`` +context key (set to ``ref``) into the Sales views. Contacts, CRM, +Invoicing and any other module that reads ``display_name`` continues to +see the plain partner name. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Set a value on the **Reference** field of any contact +(``res.partner.ref``). + +Open the **Sales** app, create or edit a quotation and open the +**Customer** dropdown — matching partners appear with the reference +prefix: + +:: + + [C00123] Acme Corp + +The prefix stays on the selected value too, so the reference remains +visible on the saved order. Views outside Sales keep the plain partner +name. + +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 + +Contributors +------------ + +- `ForgeFlow `__ + + - Jasmin Solanki + +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/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_display_ref/__init__.py b/sale_partner_display_ref/__init__.py new file mode 100644 index 00000000000..ae4fe9e3d96 --- /dev/null +++ b/sale_partner_display_ref/__init__.py @@ -0,0 +1,2 @@ +# Copyright 2026 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/sale_partner_display_ref/__manifest__.py b/sale_partner_display_ref/__manifest__.py new file mode 100644 index 00000000000..a15c0efe974 --- /dev/null +++ b/sale_partner_display_ref/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2026 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Sale Partner Display Reference", + "summary": "Wire the partner reference prefix into Sales views.", + "version": "19.0.1.0.0", + "category": "Sales/Sales", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/sale-workflow", + "license": "AGPL-3", + "depends": ["partner_display_ref", "sale"], + "data": [ + "views/sale_order_views.xml", + ], + "installable": True, +} diff --git a/sale_partner_display_ref/pyproject.toml b/sale_partner_display_ref/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/sale_partner_display_ref/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/sale_partner_display_ref/readme/CONTRIBUTORS.md b/sale_partner_display_ref/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..195652ad1ec --- /dev/null +++ b/sale_partner_display_ref/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [ForgeFlow](https://www.forgeflow.com) + - Jasmin Solanki \<\> diff --git a/sale_partner_display_ref/readme/DESCRIPTION.md b/sale_partner_display_ref/readme/DESCRIPTION.md new file mode 100644 index 00000000000..5d2481f149e --- /dev/null +++ b/sale_partner_display_ref/readme/DESCRIPTION.md @@ -0,0 +1,9 @@ +This module prefixes the customer reference (`res.partner.ref`) to the +partner's `display_name` whenever it is rendered inside a Sales view — +shown as `[C00123] Acme Corp` in the customer field of a sales quotation or +order, both in the dropdown and on the selected value. + +The decoration mechanism lives in the generic `partner_display_ref` module; +this module only injects the `partner_display_ref_field` context key (set to +`ref`) into the Sales views. Contacts, CRM, Invoicing and any other module that reads +`display_name` continues to see the plain partner name. diff --git a/sale_partner_display_ref/readme/USAGE.md b/sale_partner_display_ref/readme/USAGE.md new file mode 100644 index 00000000000..07ab5c4234f --- /dev/null +++ b/sale_partner_display_ref/readme/USAGE.md @@ -0,0 +1,9 @@ +Set a value on the **Reference** field of any contact (`res.partner.ref`). + +Open the **Sales** app, create or edit a quotation and open the **Customer** +dropdown — matching partners appear with the reference prefix: + + [C00123] Acme Corp + +The prefix stays on the selected value too, so the reference remains visible +on the saved order. Views outside Sales keep the plain partner name. diff --git a/sale_partner_display_ref/static/description/index.html b/sale_partner_display_ref/static/description/index.html new file mode 100644 index 00000000000..eab9c9f3d2d --- /dev/null +++ b/sale_partner_display_ref/static/description/index.html @@ -0,0 +1,455 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Sale Partner Display Reference

+ +

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

+

This module prefixes the customer reference (res.partner.ref) to the +partner’s display_name whenever it is rendered inside a Sales view — +shown as [C00123] Acme Corp in the customer field of a sales +quotation or order, both in the dropdown and on the selected value.

+

The decoration mechanism lives in the generic partner_display_ref +module; this module only injects the partner_display_ref_field +context key (set to ref) into the Sales views. Contacts, CRM, +Invoicing and any other module that reads display_name continues to +see the plain partner name.

+

Table of contents

+ +
+

Usage

+

Set a value on the Reference field of any contact +(res.partner.ref).

+

Open the Sales app, create or edit a quotation and open the +Customer dropdown — matching partners appear with the reference +prefix:

+
+[C00123] Acme Corp
+
+

The prefix stays on the selected value too, so the reference remains +visible on the saved order. Views outside Sales keep the plain partner +name.

+
+
+

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
  • +
+
+
+

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/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_display_ref/tests/__init__.py b/sale_partner_display_ref/tests/__init__.py new file mode 100644 index 00000000000..4e3dd3701e0 --- /dev/null +++ b/sale_partner_display_ref/tests/__init__.py @@ -0,0 +1 @@ +from . import test_sale_partner_display_ref diff --git a/sale_partner_display_ref/tests/test_sale_partner_display_ref.py b/sale_partner_display_ref/tests/test_sale_partner_display_ref.py new file mode 100644 index 00000000000..3b9eed7b644 --- /dev/null +++ b/sale_partner_display_ref/tests/test_sale_partner_display_ref.py @@ -0,0 +1,41 @@ +# Copyright 2026 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import ast + +from lxml import etree + +from odoo.tests import TransactionCase, tagged + + +@tagged("post_install", "-at_install") +class TestSalePartnerDisplayRef(TransactionCase): + """The Sales views must inject ``partner_display_ref_field='ref'`` into the + customer ``partner_id`` field context. The decoration mechanism itself is + covered by the ``partner_display_ref`` base module's tests. + """ + + def _assert_partner_display_ref_field(self, xmlid): + view = self.env.ref(xmlid) + tree = etree.fromstring(view.get_combined_arch()) + partner_fields = tree.xpath("//field[@name='partner_id']") + self.assertTrue(partner_fields, f"{xmlid} must contain a partner_id field") + contexts = [ + ast.literal_eval(field.get("context")) + for field in partner_fields + if field.get("context") + ] + self.assertTrue( + any(ctx.get("partner_display_ref_field") == "ref" for ctx in contexts), + f"{xmlid} must inject partner_display_ref_field='ref' into the " + f"partner_id context", + ) + + def test_order_form_injects_context(self): + self._assert_partner_display_ref_field("sale.view_order_form") + + def test_quotation_tree_injects_context(self): + self._assert_partner_display_ref_field("sale.view_quotation_tree") + + def test_sales_order_filter_injects_context(self): + self._assert_partner_display_ref_field("sale.view_sales_order_filter") diff --git a/sale_partner_display_ref/views/sale_order_views.xml b/sale_partner_display_ref/views/sale_order_views.xml new file mode 100644 index 00000000000..187c00a3945 --- /dev/null +++ b/sale_partner_display_ref/views/sale_order_views.xml @@ -0,0 +1,45 @@ + + + + + sale.view.order.form.inherit.partner.display.ref + sale.order + + + + {'partner_display_ref_field': 'ref'} + + + + + + sale.view.quotation.tree.inherit.partner.display.ref + sale.order + + + + {'partner_display_ref_field': 'ref'} + + + + + + sale.view.sales.order.filter.inherit.partner.display.ref + sale.order + + + + {'partner_display_ref_field': 'ref'} + + + +