Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] partner_tier_validation #1488

Merged
merged 30 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ccbb503
[ADD] partner_tier_validation
dreispt Feb 16, 2021
f508d8e
[14.0][MIG]partner_tier_validation
Freni-OSI Feb 17, 2021
c4100d7
[14.0][IMP]Improved partner_tier_validation
Freni-OSI Mar 3, 2021
512cc30
[UPD] Update partner_tier_validation.pot
oca-travis Mar 3, 2021
1e2be3a
[FIX] partner_tier_validation: workflow was not working
dreispt Mar 24, 2021
6e59472
[UPD] Update partner_tier_validation.pot
oca-travis Apr 7, 2021
c601e68
[UPD] README.rst
OCA-git-bot Apr 7, 2021
b4d73bc
partner_tier_validation 14.0.1.1.0
OCA-git-bot Apr 7, 2021
2559cbe
[IMP]
patrickrwilson May 19, 2021
af24c53
[UPD] Update partner_tier_validation.pot
oca-travis May 28, 2021
a7d3517
[UPD] README.rst
OCA-git-bot May 28, 2021
acc61ab
partner_tier_validation 14.0.2.0.0
OCA-git-bot May 28, 2021
c4d2bca
[FIX] partner_tier_validation: Defer rule activation for compatibility
victoralmau Oct 11, 2021
99dd82c
[UPD] Update partner_tier_validation.pot
oca-travis Nov 11, 2021
59cc95e
[REF] partner_tier_validation: do not archive, depend on partner_stage
dreispt Feb 1, 2022
65b2a51
[UPD] Update partner_tier_validation.pot
oca-travis Feb 17, 2022
0b30249
[UPD] Update partner_tier_validation.pot
oca-travis Feb 24, 2022
a6dc00e
[UPD] README.rst
OCA-git-bot Feb 24, 2022
b6a5626
partner_tier_validation 14.0.3.0.0
OCA-git-bot Feb 24, 2022
8b70e95
[FIX] partner_tier_validation: create does not need custom code, rest…
dreispt Feb 24, 2022
605a8b9
[FIX] partner_tier_validation: fix tests
dreispt Mar 3, 2022
5c24026
[UPD] README.rst
OCA-git-bot Mar 4, 2022
0d25633
partner_tier_validation 14.0.3.0.1
OCA-git-bot Mar 4, 2022
4984897
[UPD] Update partner_tier_validation.pot
oca-travis Apr 26, 2022
db4963d
[IMP] partner_tier_validation (Prevent bypass)
patrickrwilson Apr 27, 2022
ba7e1d4
partner_tier_validation 14.0.3.0.2
OCA-git-bot Apr 30, 2022
7ae06f4
[IMP] partner_tier_validation: black, isort, prettier
BT-dmontull Sep 14, 2022
e1a6bf6
[15.0][MIG] partner_tier_validation: Migration to 15.0
BT-dmontull Sep 14, 2022
737caf7
[IMP] partner_tier_validation: pre-commit stuff
Urvisha-OSI Mar 20, 2023
5190843
[MIG] partner_tier_validation: Migrated to 16.0
Urvisha-OSI Mar 20, 2023
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
130 changes: 130 additions & 0 deletions partner_tier_validation/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
=======================
Partner Tier Validation
=======================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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/16.0/partner_tier_validation
: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-16-0/partner-contact-16-0-partner_tier_validation
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/partner-contact&target_branch=16.0
:alt: Try me on Runboat

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

Adds an approval workflow to Partners.
The default rule requires new company Contacts to be approved
before they can be used.

The rule can be extended to new non-company contact,
but beware that may cause issues with automatically created new contacts,
such as the ones generated when processing incoming emails.

If the 'Is Company' or 'Parent' field changes then the contact is Request
for approval.

For this, the new Contact record is kept as "Archived" until it is approved.

**Table of contents**

.. contents::
:local:

Installation
============

This module depends on ``base_tier_validation``. You can find it at
`OCA/server-ux <https://github.com/OCA/server-ux>`_

Usage
=====

Before using, check Contact Stages configuration,
to ensure that the default stage has the "Related State" field
set to "To Approve".
For example, having the "Draft" stage the default ensures this.

A regular user creates a new Contact and sends it for approval:

#. Create a Contact triggering at least one "Tier Definition".
The Contact will be in Draft state and marked as Archived until approved.
#. Click on *Request Validation* button.
#. In the *Reviews* section, at the bottom of the form, inspect the pending reviews and their status.


The approver reviews Contacts to approve:

#. Navigate to the Contacts app, and select the filter "Needs my Approval"
#. Open the Contact form to approve. It will display a
"This Records needs to be validated" banner, with "Validate" and "Reject" options.
#. The approver can change the state to "Active".
This will automatically unarchive the record and make it available to be used.


The Approve/Reject actions do not automatically change the State.
This could be a future improvement.

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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_tier_validation%0Aversion:%2016.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
~~~~~~~

* Open Source Integrators

Contributors
~~~~~~~~~~~~

* `Open Source Integrators <https://opensourceintegrators.com>`_.

* Antonio Yamuta <[email protected]>
* Daniel Reis <[email protected]>
* Urvisha Desai <[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.

.. |maintainer-dreispt| image:: https://github.com/dreispt.png?size=40px
:target: https://github.com/dreispt
:alt: dreispt

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-dreispt|

This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/16.0/partner_tier_validation>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions partner_tier_validation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import models
18 changes: 18 additions & 0 deletions partner_tier_validation/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2019 Open Source Integrators
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Partner Tier Validation",
"summary": "Support a tier validation process for Contacts",
"version": "16.0.1.0.0",
"website": "https://github.com/OCA/partner-contact",
"category": "Contact",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"depends": ["contacts", "base_tier_validation", "partner_stage"],
"data": [
"data/tier_definition.xml",
"views/res_partner_view.xml",
],
"maintainers": ["dreispt"],
}
11 changes: 11 additions & 0 deletions partner_tier_validation/data/tier_definition.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<odoo noupdate="1">
<record id="partner_tier_definition_company_only" model="tier.definition">
<field name="name">Validate New Company</field>
<field name="model_id" ref="base.model_res_partner" />
<field name="review_type">group</field>
<field name="reviewer_group_id" ref="base.group_user" />
<field name="definition_type">domain</field>
<field name="active" eval="False" />
<field name="definition_domain">[["is_company","=",True]]</field>
</record>
</odoo>
112 changes: 112 additions & 0 deletions partner_tier_validation/i18n/partner_tier_validation.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_tier_validation
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.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_tier_validation
#: model:ir.model.fields,field_description:partner_tier_validation.field_res_partner__can_review
msgid "Can Review"
msgstr ""

#. module: partner_tier_validation
#: model:ir.model,name:partner_tier_validation.model_res_partner
msgid "Contact"
msgstr ""

#. module: partner_tier_validation
#: model:ir.model.fields,field_description:partner_tier_validation.field_res_partner__display_name
#: model:ir.model.fields,field_description:partner_tier_validation.field_tier_definition__display_name
msgid "Display Name"
msgstr ""

#. module: partner_tier_validation
#: model:ir.model.fields,field_description:partner_tier_validation.field_res_partner__has_comment
msgid "Has Comment"
msgstr ""

#. module: partner_tier_validation
#: model:ir.model.fields,field_description:partner_tier_validation.field_res_partner__id
#: model:ir.model.fields,field_description:partner_tier_validation.field_tier_definition__id
msgid "ID"
msgstr ""

#. module: partner_tier_validation
#: model:ir.model.fields,field_description:partner_tier_validation.field_res_partner____last_update
#: model:ir.model.fields,field_description:partner_tier_validation.field_tier_definition____last_update
msgid "Last Modified on"
msgstr ""

#. module: partner_tier_validation
#: model:ir.model.fields,field_description:partner_tier_validation.field_res_partner__need_validation
msgid "Need Validation"
msgstr ""

#. module: partner_tier_validation
#: model_terms:ir.ui.view,arch_db:partner_tier_validation.partner_form_tier_filter
msgid "Needs my Approval"
msgstr ""

#. module: partner_tier_validation
#: model:ir.model.fields,field_description:partner_tier_validation.field_res_partner__next_review
msgid "Next Review"
msgstr ""

#. module: partner_tier_validation
#: model_terms:ir.ui.view,arch_db:partner_tier_validation.partner_form_tier_filter
msgid "Partner(s) to Approve"
msgstr ""

#. module: partner_tier_validation
#: model:ir.model.fields,field_description:partner_tier_validation.field_res_partner__rejected
msgid "Rejected"
msgstr ""

#. module: partner_tier_validation
#: model:ir.model.fields,field_description:partner_tier_validation.field_res_partner__rejected_message
msgid "Rejected Message"
msgstr ""

#. module: partner_tier_validation
#: model:ir.model.fields,field_description:partner_tier_validation.field_res_partner__reviewer_ids
msgid "Reviewers"
msgstr ""

#. module: partner_tier_validation
#: model:ir.model,name:partner_tier_validation.model_tier_definition
msgid "Tier Definition"
msgstr ""

#. module: partner_tier_validation
#: model:ir.model.fields,field_description:partner_tier_validation.field_res_partner__to_validate_message
msgid "To Validate Message"
msgstr ""

#. module: partner_tier_validation
#: model:tier.definition,name:partner_tier_validation.partner_tier_definition_company_only
msgid "Validate New Company"
msgstr ""

#. module: partner_tier_validation
#: model:ir.model.fields,field_description:partner_tier_validation.field_res_partner__validated
msgid "Validated"
msgstr ""

#. module: partner_tier_validation
#: model:ir.model.fields,field_description:partner_tier_validation.field_res_partner__validated_message
msgid "Validated Message"
msgstr ""

#. module: partner_tier_validation
#: model:ir.model.fields,field_description:partner_tier_validation.field_res_partner__review_ids
msgid "Validations"
msgstr ""
5 changes: 5 additions & 0 deletions partner_tier_validation/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2019 Open Source Integrators
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import res_partner
from . import tier_definition
50 changes: 50 additions & 0 deletions partner_tier_validation/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2019 Open Source Integrators
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, models


class ResPartner(models.Model):
_name = "res.partner"
_inherit = ["res.partner", "tier.validation"]

_tier_validation_buttons_xpath = "/form/header/field[@name='state']"
_state_from = ["draft", "cancel"]
_state_to = ["confirmed"]
_cancel_state = ["inactive"]
_tier_validation_manual_config = False

@api.model
def _partner_tier_revalidation_fields(self, values):
"""
Changing some Partner fields forces Tier Validation to be reevaluated.
Out of the box these are is_company and parent_id.
Other can be added extending this method.
"""
# IDEA: make it a System Parameter?
return [
"company_type",
"parent_id",
"vat",
"state_id",
"country_id",
"property_account_position_id",
"property_account_receivable_id",
"property_account_payable_id",
]

def write(self, vals):
# Changing certain fields requires a new validation process
revalidate_fields = self._partner_tier_revalidation_fields(vals)
if any(x in revalidate_fields for x in vals.keys()):
vals["stage_id"] = self._get_default_stage_id().id
# Tier Validation does not work with Stages, only States :-(
# Workaround is to signal state transition adding it to the write values
if "stage_id" in vals:
stage_id = vals.get("stage_id")
stage = self.env["res.partner.stage"].browse(stage_id)
vals["state"] = stage.state
res = super().write(vals)
if "stage_id" in vals and vals.get("stage_id") in self._state_from:
self.restart_validation()
return res
14 changes: 14 additions & 0 deletions partner_tier_validation/models/tier_definition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2019 Open Source Integrators
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, models


class TierDefinition(models.Model):
_inherit = "tier.definition"

@api.model
def _get_tier_validation_model_names(self):
res = super(TierDefinition, self)._get_tier_validation_model_names()
res.append("res.partner")
return res
24 changes: 24 additions & 0 deletions partner_tier_validation/readme/CONFIGURATION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
The approval rules can be configured to suit particular use cases.
A default validation rule is provided out of the box,
that can be used as a starting point fot this configuration.

This configuration is done at
*Settings / Technical / Tier Validations / Tier Definition*.

Also relevant is the configuration on the default Stage
for new Contacts/Partners.
This can be set at *Contacts / Configuration / Contact Stage*,
setting the "Default Sate" field on the appropriate Stage record.

Changing some fields will trigger a new request for validation.
This list of fields can be customized extending ``_partner_tier_revalidation_fields``.
By default these fields are:

- Company Type (Individual or Company)
- Parent Company
- Tax ID
- State
- Country
- Fiscal Position
- Account Receivable
- Account Payable
5 changes: 5 additions & 0 deletions partner_tier_validation/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* `Open Source Integrators <https://opensourceintegrators.com>`_.

* Antonio Yamuta <[email protected]>
* Daniel Reis <[email protected]>
* Urvisha Desai <[email protected]>
12 changes: 12 additions & 0 deletions partner_tier_validation/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Adds an approval workflow to Partners.
The default rule requires new company Contacts to be approved
before they can be used.

The rule can be extended to new non-company contact,
but beware that may cause issues with automatically created new contacts,
such as the ones generated when processing incoming emails.

If the 'Is Company' or 'Parent' field changes then the contact is Request
for approval.

For this, the new Contact record is kept as "Archived" until it is approved.
2 changes: 2 additions & 0 deletions partner_tier_validation/readme/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module depends on ``base_tier_validation``. You can find it at
`OCA/server-ux <https://github.com/OCA/server-ux>`_
Loading