Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
316 changes: 316 additions & 0 deletions partner_stage_only_confirmed/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,316 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

===============================================
Partner Stage - Display only confirmed partners
===============================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6798741b40f265ab2535dc965b0d110aa92306c31190a3fd93a60a9fc2cc6c67
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Fpartner--contact-lightgray.png?logo=github
:target: https://github.com/OCA/partner-contact/tree/19.0/partner_stage_only_confirmed
: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-19-0/partner-contact-19-0-partner_stage_only_confirmed
: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=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the partner stage functionality by implementing a
filtering mechanism that ensures only confirmed partners are displayed
in Many2one fields on form views. This is particularly useful in
business scenarios where you want to prevent users from selecting
partners that are not yet confirmed in your system.

Problem Solved
~~~~~~~~~~~~~~

In standard Odoo, when using Many2one fields that reference partners
(like ``parent_id``, ``contact_id``, etc.), all partners are available
for selection regardless of their state or confirmation status. This can
lead to:

- Selection of partners that are not yet properly validated
- Accidental linking to partners that are in draft or unconfirmed
states
- Data integrity issues when business processes require confirmed
partners

Solution
~~~~~~~~

The module automatically modifies form views at runtime to filter
partner-related Many2one fields, showing only partners in the
'confirmed' state. This filtering is configurable via:

- Context parameters
- System configuration parameters
- Default behavior that can be overridden as needed

The filtering is applied transparently without requiring manual domain
updates on individual views, making it a robust solution that works
across the entire application for any partner-related Many2one field.

**Table of contents**

.. contents::
:local:

Use Cases / Context
===================

Business Context
~~~~~~~~~~~~~~~~

Many organizations implement partner lifecycle management where contacts
move through various stages before being fully confirmed and eligible
for business transactions. This workflow typically includes:

- **Draft Stage:** Initial partner entry, possibly pending validation
- **Validation Stage:** Partner details being verified
- **Confirmed Stage:** Fully validated partner ready for business
- **Other Stages:** Potentially archived or suspended partners

Problem Statement
~~~~~~~~~~~~~~~~~

Without proper filtering mechanisms, users can accidentally select
unconfirmed partners in critical business operations:

- Creating sales orders for draft partners
- Generating invoices for unverified contacts
- Assigning projects to partners not yet confirmed
- Linking transactions to partners that may not exist legally

This leads to potential business disruption, data quality issues, and
compliance problems.

Industry Scenarios
~~~~~~~~~~~~~~~~~~

Financial Services
~~~~~~~~~~~~~~~~~~

Banks and financial institutions must ensure that all customer
references in transactions are to properly verified and confirmed
clients. This filter prevents linking to customers who may not have
completed the required KYC (Know Your Customer) processes.

E-commerce and Retail
~~~~~~~~~~~~~~~~~~~~~

Online retailers often have a customer validation process before
allowing full purchasing capabilities. This module ensures that business
transactions only reference validated customers.

Professional Services
~~~~~~~~~~~~~~~~~~~~~

Consulting firms and professional services often have a client
onboarding process. This module ensures that only properly onboarded
clients appear in selection lists for new projects or contracts.

Manufacturing and Supply Chain
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Manufacturers often have supplier qualification processes. The filtering
ensures that only qualified suppliers appear in procurement operations.

Regulatory Compliance
~~~~~~~~~~~~~~~~~~~~~

In many jurisdictions, businesses must maintain proper verification of
their partner relationships. This module supports:

- **GDPR Compliance:** Ensuring personal data is properly validated
before use
- **Financial Regulations:** Meeting requirements for customer
verification in financial transactions
- **Contract Law:** Ensuring legal capacity of contracting partners
- **Industry Standards:** Meeting sector-specific requirements for
partner validation

Technical Context
~~~~~~~~~~~~~~~~~

The module addresses the gap between partner state management (handled
by the ``partner_stage`` module) and user interface behavior. While
partner states may be properly managed in the backend, the user
interface previously provided no automatic filtering mechanism.

Integration Considerations
~~~~~~~~~~~~~~~~~~~~~~~~~~

This module works in conjunction with:

- The ``partner_stage`` module for state management
- Standard Odoo partner management functionality
- Custom partner validation workflows
- Existing business processes that depend on partner confirmation
status

Solution Scope
~~~~~~~~~~~~~~

The module provides an elegant solution that:

- Maintains data integrity without restricting functionality
- Provides configuration flexibility for different business needs
- Integrates seamlessly with existing user interfaces
- Supports both global and granular control over the filtering behavior

Usage
=====

Default Behavior
~~~~~~~~~~~~~~~~

By default, the module applies the partner filtering automatically to
all applicable Many2one fields that reference partners. When selecting a
partner in any form view, only partners in the 'confirmed' state will be
available.

Configuration Methods
~~~~~~~~~~~~~~~~~~~~~

The filtering behavior can be controlled in several ways:

1. Context Parameter
~~~~~~~~~~~~~~~~~~~~

You can disable the filtering for specific views by adding
``only_confirmed_partners: false`` to the context:

**In views (XML):**

.. code:: xml

<field name="parent_id" context="{'only_confirmed_partners': false}"/>

**In Python code:**

.. code:: python

record.with_context(only_confirmed_partners=False).get_view(...)

2. System Configuration Parameter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can set the global filtering behavior using system parameters:

**Enable filtering:**

- Go to Settings > Technical > Parameters > System Parameters
- Create or update parameter: ``partner_stage.only_confirmed_partners``
- Set value to any non-false value (e.g., "True", "1", "yes")

**Disable filtering:**

- Set parameter value to: "False", "false", "0", or empty string

3. Explicit Enable
~~~~~~~~~~~~~~~~~~

To explicitly enable the filtering globally, set the system parameter to
any true-like value.

Common Use Cases
~~~~~~~~~~~~~~~~

Case 1: Sales Orders
~~~~~~~~~~~~~~~~~~~~

When creating sales orders, ensure that only confirmed customers can be
selected as the main partner, preventing orders from being created for
unconfirmed/draft partners.

Case 2: Invoicing
~~~~~~~~~~~~~~~~~

When creating invoices, ensure that only confirmed partners are
available as the billing address partner.

Case 3: Project Management
~~~~~~~~~~~~~~~~~~~~~~~~~~

When assigning projects to contacts, restrict the selection to only
confirmed partners to maintain data quality.

Technical Implementation
~~~~~~~~~~~~~~~~~~~~~~~~

The module uses the ``get_view`` method override to dynamically modify
form view architectures at runtime. This approach ensures that:

- Existing views don't require modifications
- The filtering applies to all partner-related Many2one fields
- Performance impact is minimal and only affects form views
- The filtering is transparent to end users (they simply see fewer
options)

Limitations
~~~~~~~~~~~

- The filtering only applies to form views
- Only affects Many2one fields with comodel_name "res.partner"
- Other view types (tree, search, kanban) are not affected
- Context and system parameters provide override mechanisms for
exceptions

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/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 <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_stage_only_confirmed%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* Camptocamp

Contributors
------------

- Silvio Gregorini <[email protected]>
- Maksym Yankin <[email protected]>
- Ruchir Shukla <[email protected]>

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 <https://github.com/OCA/partner-contact/tree/19.0/partner_stage_only_confirmed>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions partner_stage_only_confirmed/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions partner_stage_only_confirmed/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

{
"name": "Partner Stage - Display only confirmed partners",
"summary": "Adds filters on form views to display only confirmed partners",
"author": "Odoo Community Association (OCA), Camptocamp",
"website": "https://github.com/OCA/partner-contact",
"category": "Partner Management",
"version": "19.0.1.0.0",
"license": "AGPL-3",
"depends": ["partner_stage"],
"installable": True,
}
22 changes: 22 additions & 0 deletions partner_stage_only_confirmed/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_stage_only_confirmed
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-05-07 10:38+0000\n"
"Last-Translator: mymage <[email protected]>\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_stage_only_confirmed
#: model:ir.model,name:partner_stage_only_confirmed.model_base
msgid "Base"
msgstr "Base"
19 changes: 19 additions & 0 deletions partner_stage_only_confirmed/i18n/partner_stage_only_confirmed.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_stage_only_confirmed
#
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_stage_only_confirmed
#: model:ir.model,name:partner_stage_only_confirmed.model_base
msgid "Base"
msgstr ""
1 change: 1 addition & 0 deletions partner_stage_only_confirmed/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import base
Loading
Loading