-
-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] crm_required_field_by_stage: new module that allow to define re…
…quired fields in lead depending by stage
- Loading branch information
Showing
14 changed files
with
692 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
=============================== | ||
Required Fields by Stage in CRM | ||
=============================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:fd5d37d78ea01679f05c1a52d1e1720c31e2c941682c529f03be2c21bb0c462f | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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-LGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcrm-lightgray.png?logo=github | ||
:target: https://github.com/OCA/crm/tree/17.0/crm_required_field_by_stage | ||
:alt: OCA/crm | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/crm-17-0/crm-17-0-crm_required_field_by_stage | ||
: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/crm&target_branch=17.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module was written to extend the functionality of CRM leads to | ||
require certain fields to be filled out based on the stage of the lead. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
- Go to *CRM > Configuration > Stages*. | ||
- Select a stage. | ||
- You will see the new field called required fields. | ||
- Add the fields that you want to be required when the lead is in this | ||
stage. | ||
- Save the stage. | ||
- Now, when a lead is in this stage, the selected fields will be | ||
required. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/crm/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/crm/issues/new?body=module:%20crm_required_field_by_stage%0Aversion:%2017.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 | ||
------- | ||
|
||
* Jarsa | ||
|
||
Contributors | ||
------------ | ||
|
||
- `Jarsa <https://www.jarsa.com>`__: | ||
|
||
- Alan Ramos | ||
|
||
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-alan196| image:: https://github.com/alan196.png?size=40px | ||
:target: https://github.com/alan196 | ||
:alt: alan196 | ||
|
||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-alan196| | ||
|
||
This module is part of the `OCA/crm <https://github.com/OCA/crm/tree/17.0/crm_required_field_by_stage>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2024 Jarsa | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2024 Jarsa | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
|
||
{ | ||
"name": "Required Fields by Stage in CRM", | ||
"summary": "Define required fields by stage in CRM leads", | ||
"version": "17.0.1.0.0", | ||
"category": "Customer Relationship Management", | ||
"website": "https://github.com/OCA/crm", | ||
"author": "Jarsa, Odoo Community Association (OCA)", | ||
"maintainers": ["alan196"], | ||
"license": "LGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"depends": ["crm"], | ||
"data": ["views/crm_stage_views.xml"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * crm_required_field_by_stage | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 17.0+e\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-04-19 15:37+0000\n" | ||
"PO-Revision-Date: 2024-04-19 09:37-0600\n" | ||
"Last-Translator: Jesús Alan Ramos Rodríguez <[email protected]>\n" | ||
"Language-Team: \n" | ||
"Language: es_MX\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: Poedit 3.4.2\n" | ||
|
||
#. module: crm_required_field_by_stage | ||
#: model:ir.model,name:crm_required_field_by_stage.model_crm_stage | ||
msgid "CRM Stages" | ||
msgstr "Etapas del CRM" | ||
|
||
#. module: crm_required_field_by_stage | ||
#: model:ir.model.fields,help:crm_required_field_by_stage.field_crm_stage__required_field_ids | ||
msgid "Fields that are required when the lead is in this stage." | ||
msgstr "Campos que son obligatorios cuando la oportunidad se encuentra en esta etapa." | ||
|
||
#. module: crm_required_field_by_stage | ||
#: model:ir.model,name:crm_required_field_by_stage.model_crm_lead | ||
msgid "Lead/Opportunity" | ||
msgstr "Lead/oportunidad" | ||
|
||
#. module: crm_required_field_by_stage | ||
#: model:ir.model.fields,field_description:crm_required_field_by_stage.field_crm_stage__required_field_ids | ||
msgid "Required Field" | ||
msgstr "Campo requerido" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright 2024 Jarsa | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
|
||
from . import crm_lead | ||
from . import crm_stage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright 2024 Jarsa | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class CrmLead(models.Model): | ||
_inherit = "crm.lead" | ||
|
||
@api.model | ||
def _get_view(self, view_id=None, view_type="form", **options): | ||
arch, view = super()._get_view(view_id, view_type, **options) | ||
stages = self.env["crm.stage"].search([("required_field_ids", "!=", False)]) | ||
if view.type == "form" and stages: | ||
for field in stages.mapped("required_field_ids"): | ||
stages_with_field = stages.filtered( | ||
lambda stage, field=field: field in stage.required_field_ids | ||
) | ||
for node in arch.xpath("//field[@name='%s']" % field.name): | ||
node.attrib["required"] = "stage_id in [%s]" % ",".join( | ||
[str(id) for id in stages_with_field.ids] | ||
) | ||
return arch, view | ||
|
||
@api.model | ||
def _get_view_cache_key(self, view_id=None, view_type="form", **options): | ||
"""The override of _get_view changing the required fields labels according | ||
to the stage makes the view cache dependent on the stages with required fields.""" | ||
key = super()._get_view_cache_key(view_id, view_type, **options) | ||
return key + tuple( | ||
self.env["crm.stage"] | ||
.search([("required_field_ids", "!=", False)]) | ||
.mapped("required_field_ids.name") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright 2024 Jarsa | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class CrmStage(models.Model): | ||
_inherit = "crm.stage" | ||
|
||
required_field_ids = fields.Many2many( | ||
comodel_name="ir.model.fields", | ||
domain=[("model", "=", "crm.lead")], | ||
help="Fields that are required when the lead is in this stage.", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- [Jarsa](https://www.jarsa.com): | ||
- Alan Ramos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This module was written to extend the functionality of CRM leads to | ||
require certain fields to be filled out based on the stage of the lead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
To use this module, you need to: | ||
|
||
- Go to *CRM \> Configuration \> Stages*. | ||
- Select a stage. | ||
- You will see the new field called required fields. | ||
- Add the fields that you want to be required when the lead is in this stage. | ||
- Save the stage. | ||
- Now, when a lead is in this stage, the selected fields will be required. |
Oops, something went wrong.