diff --git a/crm_required_field_by_stage/README.rst b/crm_required_field_by_stage/README.rst new file mode 100644 index 00000000000..d6e3e11ecae --- /dev/null +++ b/crm_required_field_by_stage/README.rst @@ -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 `_. +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 +------- + +* Jarsa + +Contributors +------------ + +- `Jarsa `__: + + - 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 `__: + +|maintainer-alan196| + +This module is part of the `OCA/crm `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/crm_required_field_by_stage/__init__.py b/crm_required_field_by_stage/__init__.py new file mode 100644 index 00000000000..fb2fde0d5e5 --- /dev/null +++ b/crm_required_field_by_stage/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2024 Jarsa +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from . import models diff --git a/crm_required_field_by_stage/__manifest__.py b/crm_required_field_by_stage/__manifest__.py new file mode 100644 index 00000000000..7a060cd23b9 --- /dev/null +++ b/crm_required_field_by_stage/__manifest__.py @@ -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"], +} diff --git a/crm_required_field_by_stage/i18n/es_MX.po b/crm_required_field_by_stage/i18n/es_MX.po new file mode 100644 index 00000000000..8a594a3b9c7 --- /dev/null +++ b/crm_required_field_by_stage/i18n/es_MX.po @@ -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 \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" diff --git a/crm_required_field_by_stage/models/__init__.py b/crm_required_field_by_stage/models/__init__.py new file mode 100644 index 00000000000..b1d83a020de --- /dev/null +++ b/crm_required_field_by_stage/models/__init__.py @@ -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 diff --git a/crm_required_field_by_stage/models/crm_lead.py b/crm_required_field_by_stage/models/crm_lead.py new file mode 100644 index 00000000000..766d876b1e1 --- /dev/null +++ b/crm_required_field_by_stage/models/crm_lead.py @@ -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") + ) diff --git a/crm_required_field_by_stage/models/crm_stage.py b/crm_required_field_by_stage/models/crm_stage.py new file mode 100644 index 00000000000..9b774026218 --- /dev/null +++ b/crm_required_field_by_stage/models/crm_stage.py @@ -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.", + ) diff --git a/crm_required_field_by_stage/pyproject.toml b/crm_required_field_by_stage/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/crm_required_field_by_stage/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/crm_required_field_by_stage/readme/CONTRIBUTORS.md b/crm_required_field_by_stage/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..37dde332bdb --- /dev/null +++ b/crm_required_field_by_stage/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Jarsa](https://www.jarsa.com): + - Alan Ramos diff --git a/crm_required_field_by_stage/readme/DESCRIPTION.md b/crm_required_field_by_stage/readme/DESCRIPTION.md new file mode 100644 index 00000000000..f83d65d2920 --- /dev/null +++ b/crm_required_field_by_stage/readme/DESCRIPTION.md @@ -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. diff --git a/crm_required_field_by_stage/readme/USAGE.md b/crm_required_field_by_stage/readme/USAGE.md new file mode 100644 index 00000000000..e8bf42e781d --- /dev/null +++ b/crm_required_field_by_stage/readme/USAGE.md @@ -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. diff --git a/crm_required_field_by_stage/static/description/index.html b/crm_required_field_by_stage/static/description/index.html new file mode 100644 index 00000000000..8edabc752de --- /dev/null +++ b/crm_required_field_by_stage/static/description/index.html @@ -0,0 +1,445 @@ + + + + + + +Required Fields by Stage in CRM + + + +
+

Required Fields by Stage in CRM

+ + +

Beta License: LGPL-3 OCA/crm Translate me on Weblate Try me on Runboat

+

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

+ +
+

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

+
    +
  • Jarsa
  • +
+
+
+

Contributors

+
    +
  • Jarsa:
      +
    • Alan Ramos
    • +
    +
  • +
+
+
+

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:

+

alan196

+

This module is part of the OCA/crm project on GitHub.

+

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

+
+
+
+ + diff --git a/crm_required_field_by_stage/views/crm_stage_views.xml b/crm_required_field_by_stage/views/crm_stage_views.xml new file mode 100644 index 00000000000..66c251113eb --- /dev/null +++ b/crm_required_field_by_stage/views/crm_stage_views.xml @@ -0,0 +1,19 @@ + + + + + crm.stage.view.form + crm.stage + + + + + + + + + diff --git a/pandoc-3.1.13-x86_64-macOS.pkg b/pandoc-3.1.13-x86_64-macOS.pkg new file mode 100644 index 00000000000..55cb3dc1d0c Binary files /dev/null and b/pandoc-3.1.13-x86_64-macOS.pkg differ