diff --git a/crm_stage_probability/README.rst b/crm_stage_probability/README.rst new file mode 100644 index 00000000000..94d67efe219 --- /dev/null +++ b/crm_stage_probability/README.rst @@ -0,0 +1,94 @@ +===================== +CRM stage probability +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:ab826e8c5301c81423925e86915d4d550e8040d627b730e294524225b8baf90d + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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%2Fcrm-lightgray.png?logo=github + :target: https://github.com/OCA/crm/tree/18.0/crm_stage_probability + :alt: OCA/crm +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/crm-18-0/crm-18-0-crm_stage_probability + :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=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module restore the CRM feature from Odoo <= 12.0 with lead +probability according to its stage. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure this module, you need to: + +1. Set the probabilities on the stages +2. Run the "Update leads probability" wizard on the stages to update + +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 +------- + +* Camptocamp +* Odoo SA + +Contributors +------------ + +- Odoo SA +- Akim Juillerat +- Robin Goots +- Heliconia Solutions Pvt. Ltd. + +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/crm `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/crm_stage_probability/__init__.py b/crm_stage_probability/__init__.py new file mode 100644 index 00000000000..9b4296142f4 --- /dev/null +++ b/crm_stage_probability/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizard diff --git a/crm_stage_probability/__manifest__.py b/crm_stage_probability/__manifest__.py new file mode 100644 index 00000000000..815fdf052d5 --- /dev/null +++ b/crm_stage_probability/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +{ + "name": "CRM stage probability", + "summary": "Define fixed probability on the stages", + "version": "18.0.1.0.0", + "development_status": "Alpha", + "category": "Sales/CRM", + "website": "https://github.com/OCA/crm", + "author": "Camptocamp, Odoo Community Association (OCA), Odoo SA", + "license": "AGPL-3", + "depends": ["crm"], + "data": [ + "views/crm_lead.xml", + "views/crm_stage.xml", + "wizard/crm_lead_stage_probability_update.xml", + "data/crm_stage.xml", + "security/ir.model.access.csv", + ], +} diff --git a/crm_stage_probability/data/crm_stage.xml b/crm_stage_probability/data/crm_stage.xml new file mode 100644 index 00000000000..969fa608249 --- /dev/null +++ b/crm_stage_probability/data/crm_stage.xml @@ -0,0 +1,19 @@ + + + + + 10 + + + + 30 + + + + 70 + + + + 100 + + diff --git a/crm_stage_probability/i18n/crm_stage_probability.pot b/crm_stage_probability/i18n/crm_stage_probability.pot new file mode 100644 index 00000000000..e122d6c043c --- /dev/null +++ b/crm_stage_probability/i18n/crm_stage_probability.pot @@ -0,0 +1,178 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_stage_probability +# +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: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.crm_lead_view_form_inherit +msgid "% (According to stage)" +msgstr "" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.crm_lead_view_form_inherit +msgid "" +"" +msgstr "" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.view_crm_lead_stage_probability_update +msgid "All the Leads and opportunities on following stages will be updated." +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model,name:crm_stage_probability.model_crm_stage +msgid "CRM Stages" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model,name:crm_stage_probability.model_crm_lead_stage_probability_update_line +msgid "CRM leads stages to updates" +msgstr "" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.view_crm_lead_stage_probability_update +msgid "Cancel" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_stage__on_change +msgid "Change Probability Automatically" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__create_uid +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__create_uid +msgid "Created by" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__create_date +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__create_date +msgid "Created on" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__crm_stage_update_ids +msgid "Crm Stage Update" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__display_name +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__display_name +msgid "Display Name" +msgstr "" + +#. module: crm_stage_probability +#. odoo-python +#: code:addons/crm_stage_probability/wizard/crm_lead_stage_probability_update.py:0 +#, python-format +msgid "" +"Following stages must be set as 'Change Probability Automatically' in order to update their related leads:\n" +"\n" +"%s" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__id +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__id +msgid "ID" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead__is_stage_probability +msgid "Is Stage Probability" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__write_uid +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__write_date +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__write_date +msgid "Last Updated on" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model,name:crm_stage_probability.model_crm_lead +msgid "Lead/Opportunity" +msgstr "" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.view_crm_lead_stage_probability_update +msgid "Leads probability mass update" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model,name:crm_stage_probability.model_crm_lead_stage_probability_update +msgid "Mass update of crm lead probability according to stage" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__lead_count +msgid "No of leads" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead__probability +msgid "Probability" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead__stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_stage__probability +msgid "Probability (%)" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.fields,help:crm_stage_probability.field_crm_stage__on_change +msgid "" +"Setting this stage will change the probability automatically on the " +"opportunity." +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__stage_id +msgid "Stage" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.constraint,message:crm_stage_probability.constraint_crm_stage_check_probability +msgid "The probability should be between 0% and 100%!" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.fields,help:crm_stage_probability.field_crm_lead__stage_probability +#: model:ir.model.fields,help:crm_stage_probability.field_crm_stage__probability +msgid "" +"This percentage depicts the default/average probability of the Case for this" +" stage to be a success" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.actions.act_window,name:crm_stage_probability.action_crm_lead_stage_probability_update +msgid "Update leads probability" +msgstr "" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.view_crm_lead_stage_probability_update +msgid "Update probabilities" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__wizard_id +msgid "Wizard" +msgstr "" diff --git a/crm_stage_probability/i18n/es.po b/crm_stage_probability/i18n/es.po new file mode 100644 index 00000000000..c4a9ed90b26 --- /dev/null +++ b/crm_stage_probability/i18n/es.po @@ -0,0 +1,196 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_stage_probability +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-09-26 14:18+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\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: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.crm_lead_view_form_inherit +msgid "% (According to stage)" +msgstr "% (de acuerdo a la etapa)" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.crm_lead_view_form_inherit +msgid "" +"" +msgstr "" +"" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.view_crm_lead_stage_probability_update +msgid "All the Leads and opportunities on following stages will be updated." +msgstr "" +"Todas las iniciativas y oportunidades en esta etapa serán actualizadas." + +#. module: crm_stage_probability +#: model:ir.model,name:crm_stage_probability.model_crm_stage +msgid "CRM Stages" +msgstr "Etapas de CRM" + +#. module: crm_stage_probability +#: model:ir.model,name:crm_stage_probability.model_crm_lead_stage_probability_update_line +msgid "CRM leads stages to updates" +msgstr "CRM lidera las etapas hacia las actualizaciones" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.view_crm_lead_stage_probability_update +msgid "Cancel" +msgstr "Cancelar" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_stage__on_change +msgid "Change Probability Automatically" +msgstr "Cambio automático de probabilidad" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__create_uid +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__create_date +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__create_date +msgid "Created on" +msgstr "Creado el" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__crm_stage_update_ids +msgid "Crm Stage Update" +msgstr "Actualización de la etapa CRM" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__display_name +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__display_name +msgid "Display Name" +msgstr "Mostrar Nombre" + +#. module: crm_stage_probability +#. odoo-python +#: code:addons/crm_stage_probability/wizard/crm_lead_stage_probability_update.py:0 +#, python-format +msgid "" +"Following stages must be set as 'Change Probability Automatically' in order " +"to update their related leads:\n" +"\n" +"%s" +msgstr "" +"Las siguientes etapas deben configurarse como \"Cambiar probabilidad " +"automáticamente\" para actualizar sus clientes potenciales relacionados:\n" +"\n" +"%s" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__id +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__id +msgid "ID" +msgstr "ID (identificación)" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead__is_stage_probability +msgid "Is Stage Probability" +msgstr "Es Probabilidad de Etapa" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__write_uid +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__write_uid +msgid "Last Updated by" +msgstr "Última Actualzacíón por" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__write_date +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__write_date +msgid "Last Updated on" +msgstr "Última Actualización el" + +#. module: crm_stage_probability +#: model:ir.model,name:crm_stage_probability.model_crm_lead +msgid "Lead/Opportunity" +msgstr "Iniciativa/Oportunidad" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.view_crm_lead_stage_probability_update +msgid "Leads probability mass update" +msgstr "Actualización masiva de la probabilidad de clientes potenciales" + +#. module: crm_stage_probability +#: model:ir.model,name:crm_stage_probability.model_crm_lead_stage_probability_update +msgid "Mass update of crm lead probability according to stage" +msgstr "Actualización masiva de la probabilidad de iniciativas según la etapa" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__lead_count +msgid "No of leads" +msgstr "Nº de iniciativas" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead__probability +msgid "Probability" +msgstr "Probabilidad" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead__stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_stage__probability +msgid "Probability (%)" +msgstr "Probabilidad (%)" + +#. module: crm_stage_probability +#: model:ir.model.fields,help:crm_stage_probability.field_crm_stage__on_change +msgid "" +"Setting this stage will change the probability automatically on the " +"opportunity." +msgstr "" +"Al establecer esta etapa, la probabilidad de la oportunidad cambiará " +"automáticamente." + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__stage_id +msgid "Stage" +msgstr "Etapa" + +#. module: crm_stage_probability +#: model:ir.model.constraint,message:crm_stage_probability.constraint_crm_stage_check_probability +msgid "The probability should be between 0% and 100%!" +msgstr "¡La probabilidad debe estar entre 0% y 100%!" + +#. module: crm_stage_probability +#: model:ir.model.fields,help:crm_stage_probability.field_crm_lead__stage_probability +#: model:ir.model.fields,help:crm_stage_probability.field_crm_stage__probability +msgid "" +"This percentage depicts the default/average probability of the Case for this " +"stage to be a success" +msgstr "" +"Este porcentaje representa la probabilidad por defecto/media del caso para " +"que esta etapa sea un éxito" + +#. module: crm_stage_probability +#: model:ir.actions.act_window,name:crm_stage_probability.action_crm_lead_stage_probability_update +msgid "Update leads probability" +msgstr "Actualizar probabilidad de iniciativas" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.view_crm_lead_stage_probability_update +msgid "Update probabilities" +msgstr "Actualizar probabilidades" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__wizard_id +msgid "Wizard" +msgstr "Asistente" + +#~ msgid "Last Modified on" +#~ msgstr "Última Modificación el" diff --git a/crm_stage_probability/i18n/it.po b/crm_stage_probability/i18n/it.po new file mode 100644 index 00000000000..2f9e8048834 --- /dev/null +++ b/crm_stage_probability/i18n/it.po @@ -0,0 +1,197 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_stage_probability +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-06-14 14:09+0000\n" +"Last-Translator: mymage \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: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.crm_lead_view_form_inherit +msgid "% (According to stage)" +msgstr "% (corrispondente alla fase)" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.crm_lead_view_form_inherit +msgid "" +"" +msgstr "" +"" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.view_crm_lead_stage_probability_update +msgid "All the Leads and opportunities on following stages will be updated." +msgstr "" +"Tutti i contatti e le opportunità delle fasi seguenti verranno aggiornati." + +#. module: crm_stage_probability +#: model:ir.model,name:crm_stage_probability.model_crm_stage +msgid "CRM Stages" +msgstr "Fasi CRM" + +#. module: crm_stage_probability +#: model:ir.model,name:crm_stage_probability.model_crm_lead_stage_probability_update_line +msgid "CRM leads stages to updates" +msgstr "Fasi contatti CRM da aggiornare" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.view_crm_lead_stage_probability_update +msgid "Cancel" +msgstr "Annulla" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_stage__on_change +msgid "Change Probability Automatically" +msgstr "Cambia probabilità automaticamente" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__create_uid +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__create_uid +msgid "Created by" +msgstr "Creato da" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__create_date +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__create_date +msgid "Created on" +msgstr "Creato il" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__crm_stage_update_ids +msgid "Crm Stage Update" +msgstr "Aggiornamento fase CRM" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__display_name +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: crm_stage_probability +#. odoo-python +#: code:addons/crm_stage_probability/wizard/crm_lead_stage_probability_update.py:0 +#, python-format +msgid "" +"Following stages must be set as 'Change Probability Automatically' in order " +"to update their related leads:\n" +"\n" +"%s" +msgstr "" +"Le fasi seguenti devono essere impostate come 'Cambia probabilità " +"automaticamente' per aggiornare i contatti relativi:\n" +"\n" +"%s" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__id +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__id +msgid "ID" +msgstr "ID" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead__is_stage_probability +msgid "Is Stage Probability" +msgstr "È probabilità della fase" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__write_uid +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__write_uid +msgid "Last Updated by" +msgstr "Ultimo aggiornamento di" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__write_date +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__write_date +msgid "Last Updated on" +msgstr "Ultimo aggiornamento il" + +#. module: crm_stage_probability +#: model:ir.model,name:crm_stage_probability.model_crm_lead +msgid "Lead/Opportunity" +msgstr "Contatto/Opportunità" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.view_crm_lead_stage_probability_update +msgid "Leads probability mass update" +msgstr "Aggiornamento di massa probabilità contatti" + +#. module: crm_stage_probability +#: model:ir.model,name:crm_stage_probability.model_crm_lead_stage_probability_update +msgid "Mass update of crm lead probability according to stage" +msgstr "" +"Aggiornamento di massa della probabilità contatto CRM coerentemente alla fase" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__lead_count +msgid "No of leads" +msgstr "Nr. di contatti" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead__probability +msgid "Probability" +msgstr "Probabilità" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead__stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_stage__probability +msgid "Probability (%)" +msgstr "Probabilità (%)" + +#. module: crm_stage_probability +#: model:ir.model.fields,help:crm_stage_probability.field_crm_stage__on_change +msgid "" +"Setting this stage will change the probability automatically on the " +"opportunity." +msgstr "" +"Impostando questa fase modificherà automaticamente la probabilità " +"dell'opportunità." + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__stage_id +msgid "Stage" +msgstr "Fase" + +#. module: crm_stage_probability +#: model:ir.model.constraint,message:crm_stage_probability.constraint_crm_stage_check_probability +msgid "The probability should be between 0% and 100%!" +msgstr "La probabilità deve essere tra 0% e 100%!" + +#. module: crm_stage_probability +#: model:ir.model.fields,help:crm_stage_probability.field_crm_lead__stage_probability +#: model:ir.model.fields,help:crm_stage_probability.field_crm_stage__probability +msgid "" +"This percentage depicts the default/average probability of the Case for this " +"stage to be a success" +msgstr "" +"Questa percentuale descrive la probabilità predefinita/media dell'argomento " +"per questa fase di essere un successo" + +#. module: crm_stage_probability +#: model:ir.actions.act_window,name:crm_stage_probability.action_crm_lead_stage_probability_update +msgid "Update leads probability" +msgstr "Aggiorna probabilità contatti" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.view_crm_lead_stage_probability_update +msgid "Update probabilities" +msgstr "Aggiorna probabilità" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__wizard_id +msgid "Wizard" +msgstr "Procedura guidata" + +#~ msgid "Last Modified on" +#~ msgstr "Ultima modifica il" diff --git a/crm_stage_probability/i18n/nl.po b/crm_stage_probability/i18n/nl.po new file mode 100644 index 00000000000..0987ca5febc --- /dev/null +++ b/crm_stage_probability/i18n/nl.po @@ -0,0 +1,197 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_stage_probability +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-11-02 14:44+0000\n" +"Last-Translator: Dennis Sluijk \n" +"Language-Team: none\n" +"Language: nl\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.14.1\n" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.crm_lead_view_form_inherit +msgid "% (According to stage)" +msgstr "% (Volgens de fase)" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.crm_lead_view_form_inherit +msgid "" +"" +msgstr "" +"" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.view_crm_lead_stage_probability_update +msgid "All the Leads and opportunities on following stages will be updated." +msgstr "Alle leads en verkoopkansen op de volgende fases worden bijgewerkt." + +#. module: crm_stage_probability +#: model:ir.model,name:crm_stage_probability.model_crm_stage +msgid "CRM Stages" +msgstr "CRM Fases" + +#. module: crm_stage_probability +#: model:ir.model,name:crm_stage_probability.model_crm_lead_stage_probability_update_line +msgid "CRM leads stages to updates" +msgstr "CRM fases die bijgewerkt moeten worden" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.view_crm_lead_stage_probability_update +msgid "Cancel" +msgstr "Annuleren" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_stage__on_change +msgid "Change Probability Automatically" +msgstr "Pas slagingskans automatisch aan" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__create_uid +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__create_uid +msgid "Created by" +msgstr "Aangemaakt door" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__create_date +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__create_date +msgid "Created on" +msgstr "Aangemaakt op" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__crm_stage_update_ids +msgid "Crm Stage Update" +msgstr "" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__display_name +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__display_name +msgid "Display Name" +msgstr "Schermnaam" + +#. module: crm_stage_probability +#. odoo-python +#: code:addons/crm_stage_probability/wizard/crm_lead_stage_probability_update.py:0 +#, python-format +msgid "" +"Following stages must be set as 'Change Probability Automatically' in order " +"to update their related leads:\n" +"\n" +"%s" +msgstr "" +"De volgende fases moeten ingesteld worden op 'Pas slagingskans automatisch " +"aan' om hun gerelateerde leads bij te werken:\n" +"\n" +"%s" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__id +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__id +msgid "ID" +msgstr "ID" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead__is_stage_probability +msgid "Is Stage Probability" +msgstr "Gebruik Slagingskans van Fase" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__write_uid +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__write_uid +msgid "Last Updated by" +msgstr "Laatst bijgewerkt door" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update__write_date +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__write_date +msgid "Last Updated on" +msgstr "Laatst bijgewerkt op" + +#. module: crm_stage_probability +#: model:ir.model,name:crm_stage_probability.model_crm_lead +msgid "Lead/Opportunity" +msgstr "Lead/Verkoopkans" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.view_crm_lead_stage_probability_update +msgid "Leads probability mass update" +msgstr "Pas de slagingskans van veel leads aan" + +#. module: crm_stage_probability +#: model:ir.model,name:crm_stage_probability.model_crm_lead_stage_probability_update +msgid "Mass update of crm lead probability according to stage" +msgstr "" +"Pas de slagingskans van veel leads aan volgens de slagingskans ingesteld op " +"fase" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__lead_count +msgid "No of leads" +msgstr "Aantal leads" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead__probability +msgid "Probability" +msgstr "Kans" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead__stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_stage__probability +msgid "Probability (%)" +msgstr "Kans (%)" + +#. module: crm_stage_probability +#: model:ir.model.fields,help:crm_stage_probability.field_crm_stage__on_change +msgid "" +"Setting this stage will change the probability automatically on the " +"opportunity." +msgstr "" +"Als dit ingesteld is worden de slagingskansen van verkoopkansen op deze fase " +"automatisch bijgewerkt." + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__stage_id +msgid "Stage" +msgstr "Fase" + +#. module: crm_stage_probability +#: model:ir.model.constraint,message:crm_stage_probability.constraint_crm_stage_check_probability +msgid "The probability should be between 0% and 100%!" +msgstr "De slagingskans moet tussen 0% en 100% liggen!" + +#. module: crm_stage_probability +#: model:ir.model.fields,help:crm_stage_probability.field_crm_lead__stage_probability +#: model:ir.model.fields,help:crm_stage_probability.field_crm_stage__probability +msgid "" +"This percentage depicts the default/average probability of the Case for this " +"stage to be a success" +msgstr "" +"Dit percentage geeft de standaard/gemiddelde slagingskans aan voor deze fase " +"om de verkoopkans te winnen" + +#. module: crm_stage_probability +#: model:ir.actions.act_window,name:crm_stage_probability.action_crm_lead_stage_probability_update +msgid "Update leads probability" +msgstr "Werk de slagingskansen van leads bij" + +#. module: crm_stage_probability +#: model_terms:ir.ui.view,arch_db:crm_stage_probability.view_crm_lead_stage_probability_update +msgid "Update probabilities" +msgstr "Actualiseer slagingskansen" + +#. module: crm_stage_probability +#: model:ir.model.fields,field_description:crm_stage_probability.field_crm_lead_stage_probability_update_line__wizard_id +msgid "Wizard" +msgstr "" + +#~ msgid "Last Modified on" +#~ msgstr "Laatst gewijzigd op" diff --git a/crm_stage_probability/models/__init__.py b/crm_stage_probability/models/__init__.py new file mode 100644 index 00000000000..40635a2a948 --- /dev/null +++ b/crm_stage_probability/models/__init__.py @@ -0,0 +1,2 @@ +from . import crm_lead +from . import crm_stage diff --git a/crm_stage_probability/models/crm_lead.py b/crm_stage_probability/models/crm_lead.py new file mode 100644 index 00000000000..6fbb3782841 --- /dev/null +++ b/crm_stage_probability/models/crm_lead.py @@ -0,0 +1,78 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +from odoo import api, fields, models, tools + + +class CrmLead(models.Model): + _inherit = "crm.lead" + + is_stage_probability = fields.Boolean( + compute="_compute_is_stage_probability", readonly=True + ) + stage_probability = fields.Float(related="stage_id.probability", readonly=True) + probability = fields.Float(default=lambda self: self._default_probability()) + + def _default_probability(self): + if "default_stage_id" in self._context: + stage_id = self._context.get("default_stage_id") + else: + stage_id = self._stage_find(domain=[("fold", "=", False)]).id + if stage_id: + return self.env["crm.stage"].browse(stage_id).probability + return 10 + + @api.depends("probability", "stage_id", "stage_id.probability") + def _compute_is_stage_probability(self): + for lead in self: + lead.is_stage_probability = ( + tools.float_compare(lead.probability, lead.stage_probability, 2) == 0 + ) + + @api.depends("probability", "automated_probability") + def _compute_is_automated_probability(self): + for lead in self: + if lead.probability != lead.stage_id.probability: + super(CrmLead, lead)._compute_is_automated_probability() + continue + lead.is_automated_probability = False + return + + @api.depends( + lambda self: ["tag_ids", "stage_id", "team_id"] + self._pls_get_safe_fields() + ) + def _compute_probabilities(self): + self = self.with_context(_auto_update_probability=True) + return super()._compute_probabilities() + + @api.model + def _onchange_stage_id_values(self, stage_id): + """returns the new values when stage_id has changed""" + if not stage_id: + return {} + stage = self.env["crm.stage"].browse(stage_id) + if stage.on_change: + return {"probability": stage.probability} + return {} + + @api.onchange("stage_id") + def _onchange_stage_id(self): + values = self._onchange_stage_id_values(self.stage_id.id) + self.update(values) + + def write(self, vals): + # Avoid to update probability with automated_probability on + # _update_probability if the stage is set as on_change + # If the stage is not set as on_change, auto PLS will be applied + if ( + self.env.context.get("_auto_update_probability") + and "probability" in vals + and "stage_id" not in vals + ): + vals.update(self._onchange_stage_id_values(self.stage_id.id)) + # Force to use the probability from the stage if set as on_change + if vals.get("stage_id") and "probability" not in vals: + vals.update(self._onchange_stage_id_values(vals.get("stage_id"))) + return super().write(vals) + + def action_set_stage_probability(self): + self.write({"probability": self.stage_id.probability}) diff --git a/crm_stage_probability/models/crm_stage.py b/crm_stage_probability/models/crm_stage.py new file mode 100644 index 00000000000..ef0465867ab --- /dev/null +++ b/crm_stage_probability/models/crm_stage.py @@ -0,0 +1,28 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +from odoo import fields, models + + +class CrmStage(models.Model): + _inherit = "crm.stage" + + probability = fields.Float( + "Probability (%)", + required=True, + default=10.0, + help="This percentage depicts the default/average probability of the " + "Case for this stage to be a success", + ) + on_change = fields.Boolean( + "Change Probability Automatically", + help="Setting this stage will change the probability automatically on " + "the opportunity.", + ) + + _sql_constraints = [ + ( + "check_probability", + "check(probability >= 0 and probability <= 100)", + "The probability should be between 0% and 100%!", + ) + ] diff --git a/crm_stage_probability/pyproject.toml b/crm_stage_probability/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/crm_stage_probability/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/crm_stage_probability/readme/CONFIGURE.md b/crm_stage_probability/readme/CONFIGURE.md new file mode 100644 index 00000000000..7ca918e5e68 --- /dev/null +++ b/crm_stage_probability/readme/CONFIGURE.md @@ -0,0 +1,4 @@ +To configure this module, you need to: + +1. Set the probabilities on the stages +2. Run the "Update leads probability" wizard on the stages to update diff --git a/crm_stage_probability/readme/CONTRIBUTORS.md b/crm_stage_probability/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..b57287759a5 --- /dev/null +++ b/crm_stage_probability/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- Odoo SA +- Akim Juillerat \<\> +- Robin Goots \<\> +- Heliconia Solutions Pvt. Ltd. \<\> diff --git a/crm_stage_probability/readme/DESCRIPTION.md b/crm_stage_probability/readme/DESCRIPTION.md new file mode 100644 index 00000000000..6d418c4a12b --- /dev/null +++ b/crm_stage_probability/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module restore the CRM feature from Odoo \<= 12.0 with lead +probability according to its stage. diff --git a/crm_stage_probability/security/ir.model.access.csv b/crm_stage_probability/security/ir.model.access.csv new file mode 100644 index 00000000000..45de09df775 --- /dev/null +++ b/crm_stage_probability/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_crm_lead_stage_probability_update,access_crm_lead_stage_probability_update,model_crm_lead_stage_probability_update,base.group_user,1,0,1,0 +access_crm_lead_stage_probability_update_line,access_crm_lead_stage_probability_update_line,model_crm_lead_stage_probability_update_line,base.group_user,1,0,1,0 diff --git a/crm_stage_probability/static/description/icon.png b/crm_stage_probability/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/crm_stage_probability/static/description/icon.png differ diff --git a/crm_stage_probability/static/description/index.html b/crm_stage_probability/static/description/index.html new file mode 100644 index 00000000000..ea691499211 --- /dev/null +++ b/crm_stage_probability/static/description/index.html @@ -0,0 +1,443 @@ + + + + + +CRM stage probability + + + +
+

CRM stage probability

+ + +

Alpha License: AGPL-3 OCA/crm Translate me on Weblate Try me on Runboat

+

This module restore the CRM feature from Odoo <= 12.0 with lead +probability according to its stage.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

Configuration

+

To configure this module, you need to:

+
    +
  1. Set the probabilities on the stages
  2. +
  3. Run the “Update leads probability” wizard on the stages to update
  4. +
+
+
+

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

+
    +
  • Camptocamp
  • +
  • Odoo SA
  • +
+
+
+

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/crm project on GitHub.

+

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

+
+
+
+ + diff --git a/crm_stage_probability/tests/__init__.py b/crm_stage_probability/tests/__init__.py new file mode 100644 index 00000000000..e8233436ddc --- /dev/null +++ b/crm_stage_probability/tests/__init__.py @@ -0,0 +1 @@ +from . import test_crm_lead_probability diff --git a/crm_stage_probability/tests/test_crm_lead_probability.py b/crm_stage_probability/tests/test_crm_lead_probability.py new file mode 100644 index 00000000000..690f2b38749 --- /dev/null +++ b/crm_stage_probability/tests/test_crm_lead_probability.py @@ -0,0 +1,107 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +from odoo.exceptions import UserError +from odoo.tests import TransactionCase + + +class TestCrmLeadProbability(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.stage_new = cls.env.ref("crm.stage_lead1") + cls.stage_qualified = cls.env.ref("crm.stage_lead2") + cls.stage_proposition = cls.env.ref("crm.stage_lead3") + cls.stage_won = cls.env.ref("crm.stage_lead4") + cls.opportunity_1 = cls.env.ref("crm.crm_case_32") + + def test_update_probability(self): + self.assertEqual(self.opportunity_1.stage_id, self.stage_qualified) + self.assertFalse(self.opportunity_1.is_automated_probability) + self.assertFalse(self.opportunity_1.is_stage_probability) + self.opportunity_1.write({"stage_id": self.stage_new.id}) + self.assertEqual(self.opportunity_1.probability, self.stage_new.probability) + self.assertFalse(self.opportunity_1.is_automated_probability) + self.assertTrue(self.opportunity_1.is_stage_probability) + self.opportunity_1.write({"stage_id": self.stage_proposition.id}) + self.assertEqual( + self.opportunity_1.probability, self.stage_proposition.probability + ) + self.assertFalse(self.opportunity_1.is_automated_probability) + self.assertTrue(self.opportunity_1.is_stage_probability) + self.opportunity_1.write({"probability": 31.56}) + self.assertFalse(self.opportunity_1.is_automated_probability) + self.assertFalse(self.opportunity_1.is_stage_probability) + self.opportunity_1.action_set_stage_probability() + self.assertEqual( + self.opportunity_1.probability, self.opportunity_1.stage_id.probability + ) + self.assertTrue(self.opportunity_1.is_stage_probability) + self.opportunity_1.write({"stage_id": False}) + self.assertFalse(self.opportunity_1.is_automated_probability) + self.assertFalse(self.opportunity_1.is_stage_probability) + self.opportunity_1.action_set_stage_probability() + self.assertFalse(self.opportunity_1.probability) + + def test_create_opportunity(self): + opportunity = self.env["crm.lead"].create( + [{"name": "My opportunity", "type": "opportunity"}] + ) + default_stage_id = ( + self.env["crm.lead"]._stage_find(domain=[("fold", "=", False)]).id + ) + default_stage = self.env["crm.stage"].browse(default_stage_id) + self.assertEqual(opportunity.probability, default_stage.probability) + self.assertFalse(opportunity.is_automated_probability) + # test if there is no default stage + self.env["crm.stage"].search([("fold", "=", False)]).write({"fold": True}) + opportunity = self.env["crm.lead"].create( + [{"name": "My opportunity", "type": "opportunity"}] + ) + self.assertEqual(opportunity.probability, 10) + self.assertFalse(opportunity.is_automated_probability) + + def test_change_stage_id_values(self): + self.opportunity_1._onchange_stage_id_values(False) + + def test_create_opportunity_default_stage_id(self): + opportunity = ( + self.env["crm.lead"] + .with_context(default_stage_id=self.stage_qualified.id) + .create([{"name": "My opportunity", "type": "opportunity"}]) + ) + self.assertEqual(opportunity.probability, self.stage_qualified.probability) + self.assertFalse(opportunity.is_automated_probability) + + def test_mass_update(self): + all_stages = self.env["crm.stage"].search([]) + self.assertTrue(all(all_stages.mapped("on_change"))) + wiz = ( + self.env["crm.lead.stage.probability.update"] + .with_context(active_ids=all_stages.ids) + .create([{}]) + ) + wiz.execute() + all_leads = self.env["crm.lead"].search([]) + self.assertTrue(all(all_leads.mapped("is_stage_probability"))) + self.assertFalse(all(all_leads.mapped("is_automated_probability"))) + new_line = wiz.crm_stage_update_ids.filtered( + lambda x: x.stage_id == self.stage_new + ) + self.assertEqual(new_line.lead_count, 13) + won_line = wiz.crm_stage_update_ids.filtered( + lambda x: x.stage_id == self.stage_won + ) + self.assertEqual(won_line.lead_count, 3) + + def test_mass_update_no_onchange_stage(self): + new_stage = self.env["crm.stage"].create( + [{"name": "No Onchange", "sequence": 10}] + ) + self.assertFalse(new_stage.on_change) + with self.assertRaises(UserError) as context: + ( + self.env["crm.lead.stage.probability.update"] + .with_context(active_ids=new_stage.ids) + .create([{}]) + ) + self.assertTrue("Following stages must be set as" in str(context.exception)) diff --git a/crm_stage_probability/views/crm_lead.xml b/crm_stage_probability/views/crm_lead.xml new file mode 100644 index 00000000000..9346edd66e7 --- /dev/null +++ b/crm_stage_probability/views/crm_lead.xml @@ -0,0 +1,32 @@ + + + + crm.lead.form.inherit + + crm.lead + + + + + %% (According to stage) + + + + diff --git a/crm_stage_probability/views/crm_stage.xml b/crm_stage_probability/views/crm_stage.xml new file mode 100644 index 00000000000..bc5bcae1907 --- /dev/null +++ b/crm_stage_probability/views/crm_stage.xml @@ -0,0 +1,36 @@ + + + + Stage - Search - inherit + + crm.stage + + + + + + + + crm.stage.tree.inherit + crm.stage + + + + + + + + + crm.stage.form.inherit + crm.stage + + + + + + + + + + + diff --git a/crm_stage_probability/wizard/__init__.py b/crm_stage_probability/wizard/__init__.py new file mode 100644 index 00000000000..572a9cfbb6a --- /dev/null +++ b/crm_stage_probability/wizard/__init__.py @@ -0,0 +1 @@ +from . import crm_lead_stage_probability_update diff --git a/crm_stage_probability/wizard/crm_lead_stage_probability_update.py b/crm_stage_probability/wizard/crm_lead_stage_probability_update.py new file mode 100644 index 00000000000..0aacafda4a8 --- /dev/null +++ b/crm_stage_probability/wizard/crm_lead_stage_probability_update.py @@ -0,0 +1,82 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +from odoo import _, api, fields, models +from odoo.exceptions import UserError + + +class CrmLeadStageProbabilityUpdate(models.TransientModel): + _name = "crm.lead.stage.probability.update" + _description = "Mass update of crm lead probability according to stage" + + crm_stage_update_ids = fields.Many2many( + "crm.lead.stage.probability.update.line", + "crm_lead_stage_probability_update_line_rel", + "wizard_id", + "stage_id", + readonly=True, + ) + + @api.model + def default_get(self, fields_list): + res = super().default_get(fields_list) + if "crm_stage_update_ids" in fields_list and "active_ids" in self.env.context: + active_ids = self.env.context.get("active_ids") + stages = self.env["crm.stage"].browse(active_ids) + stages_missing_on_change = stages.filtered(lambda s: not s.on_change) + if stages_missing_on_change: + raise UserError( + _( + "Following stages must be set as 'Change Probability " + "Automatically' in order to update their related leads:" + "\n\n" + "%s" + ) + % "\n".join([s.name for s in stages_missing_on_change]) + ) + line_ids = [] + for stage in stages: + new_line = self.env["crm.lead.stage.probability.update.line"].create( + [{"stage_id": stage.id}] + ) + line_ids.append(new_line.id) + res["crm_stage_update_ids"] = [(6, 0, line_ids)] + return res + + def execute(self): + updated_leads_ids = [] + for stage_line in self.crm_stage_update_ids: + leads = self.env["crm.lead"].search( + [("stage_id", "=", stage_line.stage_id.id)] + ) + leads.write({"probability": stage_line.stage_id.probability}) + updated_leads_ids += leads.ids + action = self.env.ref("crm.crm_lead_all_leads").read()[0] + action["domain"] = f"[('id', 'in', {updated_leads_ids})]" + action.pop("context") + return action + + +class CrmLeadStageProbabilityUpdateStage(models.TransientModel): + _name = "crm.lead.stage.probability.update.line" + _description = "CRM leads stages to updates" + + wizard_id = fields.Many2many( + "crm.lead.stage.probability.update", + "crm_lead_stage_probability_update_line_rel", + "stage_id", + "wizard_id", + readonly=True, + ) + stage_id = fields.Many2one( + "crm.stage", domain=[("on_change", "=", True)], readonly=True + ) + lead_count = fields.Integer( + "No of leads", compute="_compute_lead_count", readonly=True + ) + + @api.depends("stage_id") + def _compute_lead_count(self): + for stage_line in self: + stage_line.lead_count = self.env["crm.lead"].search_count( + [("stage_id", "=", stage_line.stage_id.id)] + ) diff --git a/crm_stage_probability/wizard/crm_lead_stage_probability_update.xml b/crm_stage_probability/wizard/crm_lead_stage_probability_update.xml new file mode 100644 index 00000000000..86746989676 --- /dev/null +++ b/crm_stage_probability/wizard/crm_lead_stage_probability_update.xml @@ -0,0 +1,42 @@ + + + + crm.lead.stage.probability.update.form + crm.lead.stage.probability.update + +
+
+

All the Leads and opportunities on following stages will be updated.

+
+ + + + + + + + +
+
+
+
+
+ + + Update leads probability + crm.lead.stage.probability.update + + form + + + new + +