diff --git a/crm_lead_substage/README.rst b/crm_lead_substage/README.rst new file mode 100644 index 000000000000..a09e5062b53a --- /dev/null +++ b/crm_lead_substage/README.rst @@ -0,0 +1,64 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +================================= +Substages for leads/opportunities +================================= + +This module allows to set substages inside the same stage for fine-graining +the reasons or flows on the CRM pipelines. + +Configuration +============= + +Go to Sales > Configuration > Leads & Opportunities > Substages for defining +the substages you want and set the stages where this substages are going to be +available + +Usage +===== + +Go to Sales > Leads or Sales > Opportunities, and when you are in one stage, +the available substages are shown below. Click on one of them to set it. If you +change the stage, then the substage is reset and the new ones available for +this stage are shown. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/111/8.0 + +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 smashing it by providing a detailed and welcomed `feedback +`_. + +Credits +======= + +Contributors +------------ + +* Pedro M. Baeza + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/crm_lead_substage/__init__.py b/crm_lead_substage/__init__.py new file mode 100644 index 000000000000..5d84acfd31de --- /dev/null +++ b/crm_lead_substage/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. +# © 2016 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import models +from . import report diff --git a/crm_lead_substage/__openerp__.py b/crm_lead_substage/__openerp__.py new file mode 100644 index 000000000000..e2fd25a66237 --- /dev/null +++ b/crm_lead_substage/__openerp__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. +# © 2016 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +{ + "name": "Substages in leads/opportunities", + "version": "8.0.1.0.0", + "license": "AGPL-3", + "author": "Antiun Ingeniería S.L., " + "Serv. Tecnol. Avanzados - Pedro M. Baeza, " + "Odoo Community Association (OCA)", + "website": "https://www.antiun.com", + "category": "Customer Relationship Management", + "depends": [ + 'crm', + ], + "data": [ + 'security/ir.model.access.csv', + 'views/crm_lead_view.xml', + 'views/crm_substage_view.xml', + 'report/crm_lead_report_view.xml', + 'report/crm_opportunity_report_view.xml', + ], + "installable": True, +} diff --git a/crm_lead_substage/i18n/es.po b/crm_lead_substage/i18n/es.po new file mode 100644 index 000000000000..d8882bf3402b --- /dev/null +++ b/crm_lead_substage/i18n/es.po @@ -0,0 +1,99 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_lead_substage +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-02-01 13:38+0000\n" +"PO-Revision-Date: 2016-02-01 13:38+0000\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_lead_substage +#: model:ir.actions.act_window,help:crm_lead_substage.crm_case_substage_action +msgid "

\n" +" Click to set a new substage in your lead/opportunity pipeline.\n" +"

\n" +" Substages will allow salespersons to easily refine the part or the\n" +" reason why a lead or opportunity is positioned in that stage.\n" +"

\n" +" " +msgstr "

\n" +" Pulse para establecer una nueva subetapa en su operativa de iniciativas/oportunidades.\n" +"

\n" +" Las subetapas permitirán a los comerciales refinar fácilmente la parte o\n" +" la razón por la que una iniciativa u oportunidad está posicionada en esa etapa.\n" +"

\n" +" " + +#. module: crm_lead_substage +#: model:ir.model,name:crm_lead_substage.model_crm_lead_report +msgid "CRM Lead Analysis" +msgstr "Análisis Iniciativas CRM" + +#. module: crm_lead_substage +#: model:ir.model,name:crm_lead_substage.model_crm_opportunity_report +msgid "CRM Opportunity Analysis" +msgstr "Análisis de oportunidades CRM" + +#. module: crm_lead_substage +#: field:crm.case.substage,create_uid:0 +msgid "Created by" +msgstr "Creado por" + +#. module: crm_lead_substage +#: field:crm.case.substage,create_date:0 +msgid "Created on" +msgstr "Creado en" + +#. module: crm_lead_substage +#: field:crm.case.substage,id:0 +msgid "ID" +msgstr "ID" + +#. module: crm_lead_substage +#: field:crm.case.substage,write_uid:0 +msgid "Last Updated by" +msgstr "Última actualización por" + +#. module: crm_lead_substage +#: field:crm.case.substage,write_date:0 +msgid "Last Updated on" +msgstr "Última actualización en" + +#. module: crm_lead_substage +#: model:ir.model,name:crm_lead_substage.model_crm_lead +msgid "Lead/Opportunity" +msgstr "Iniciativa/Oportunidad" + +#. module: crm_lead_substage +#: field:crm.case.substage,name:0 +msgid "Name" +msgstr "Nombre" + +#. module: crm_lead_substage +#: field:crm.case.substage,stage_id:0 +msgid "Stage" +msgstr "Etap" + +#. module: crm_lead_substage +#: field:crm.lead,substage_id:0 +#: view:crm.lead.report:crm_lead_substage.view_report_crm_lead_filter +#: field:crm.lead.report,substage_id:0 +#: view:crm.opportunity.report:crm_lead_substage.view_report_crm_opportunity_filter +#: field:crm.opportunity.report,substage_id:0 +msgid "Substage" +msgstr "Subetapa" + +#. module: crm_lead_substage +#: model:ir.actions.act_window,name:crm_lead_substage.crm_case_substage_action +#: model:ir.ui.menu,name:crm_lead_substage.menu_crm_case_substage +msgid "Substages" +msgstr "Subetapas" + diff --git a/crm_lead_substage/models/__init__.py b/crm_lead_substage/models/__init__.py new file mode 100644 index 000000000000..5b5e595e9f7f --- /dev/null +++ b/crm_lead_substage/models/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. +# © 2016 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import crm_case_substage +from . import crm_lead diff --git a/crm_lead_substage/models/crm_case_substage.py b/crm_lead_substage/models/crm_case_substage.py new file mode 100644 index 000000000000..6e7af3a44637 --- /dev/null +++ b/crm_lead_substage/models/crm_case_substage.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. +# © 2016 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from openerp import fields, models + + +class CrmCaseSubstage(models.Model): + _name = 'crm.case.substage' + + name = fields.Char(required=True) + stage_id = fields.Many2one( + comodel_name="crm.case.stage", required=True, string="Stage", + translate=True) diff --git a/crm_lead_substage/models/crm_lead.py b/crm_lead_substage/models/crm_lead.py new file mode 100644 index 000000000000..5ea038600bb9 --- /dev/null +++ b/crm_lead_substage/models/crm_lead.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. +# © 2016 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from openerp import api, fields, models + + +class CrmLead(models.Model): + _inherit = 'crm.lead' + + substage_id = fields.Many2one( + comodel_name="crm.case.substage", string="Substage", + domain="[('stage_id', '=', stage_id)]") + + @api.multi + def onchange_stage_id(self, stage_id): + res = super(CrmLead, self).onchange_stage_id(stage_id) + res['value'] = res.get('value', {}) + res['value']['substage_id'] = False + return res diff --git a/crm_lead_substage/report/__init__.py b/crm_lead_substage/report/__init__.py new file mode 100644 index 000000000000..166c497ac680 --- /dev/null +++ b/crm_lead_substage/report/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. +# © 2016 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import crm_lead_report +from . import crm_opportunity_report diff --git a/crm_lead_substage/report/crm_lead_report.py b/crm_lead_substage/report/crm_lead_report.py new file mode 100644 index 000000000000..12f8224bcef9 --- /dev/null +++ b/crm_lead_substage/report/crm_lead_report.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. +# © 2016 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from openerp import fields, models, tools + + +class CrmLeadReport(models.Model): + _inherit = "crm.lead.report" + + substage_id = fields.Many2one( + comodel_name="crm.case.substage", string="Substage") + + def init(self, cr): + super(CrmLeadReport, self).init(cr) + cr.execute("SELECT pg_get_viewdef('crm_lead_report', true)") + view_def = cr.fetchone()[0] + # Inject the new field in the expected SQL + sql = "c.stage_id,\n" + index = view_def.find(sql) + len(sql) + sql = " c.substage_id,\n" + view_def = view_def[:index] + sql + view_def[index:-1] + tools.drop_view_if_exists(cr, 'crm_lead_report') + cr.execute("CREATE OR REPLACE VIEW crm_lead_report AS (%s)" % view_def) diff --git a/crm_lead_substage/report/crm_lead_report_view.xml b/crm_lead_substage/report/crm_lead_report_view.xml new file mode 100644 index 000000000000..5bf6dbf064d2 --- /dev/null +++ b/crm_lead_substage/report/crm_lead_report_view.xml @@ -0,0 +1,19 @@ + + + + + + Leads report search (substage) + crm.lead.report + + + + + + + + + + diff --git a/crm_lead_substage/report/crm_opportunity_report.py b/crm_lead_substage/report/crm_opportunity_report.py new file mode 100644 index 000000000000..5339b12861d9 --- /dev/null +++ b/crm_lead_substage/report/crm_opportunity_report.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. +# © 2016 Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from openerp import fields, models, tools + + +class CrmOpportunityReport(models.Model): + _inherit = "crm.opportunity.report" + + substage_id = fields.Many2one( + comodel_name="crm.case.substage", string="Substage") + + def init(self, cr): + super(CrmOpportunityReport, self).init(cr) + cr.execute("SELECT pg_get_viewdef('crm_opportunity_report', true)") + view_def = cr.fetchone()[0] + # Inject the new field in the expected SQL + sql = "c.stage_id,\n" + index = view_def.find(sql) + len(sql) + sql = " c.substage_id,\n" + view_def = view_def[:index] + sql + view_def[index:-1] + tools.drop_view_if_exists(cr, 'crm_opportunity_report') + cr.execute( + "CREATE OR REPLACE VIEW crm_opportunity_report AS (%s)" % view_def) diff --git a/crm_lead_substage/report/crm_opportunity_report_view.xml b/crm_lead_substage/report/crm_opportunity_report_view.xml new file mode 100644 index 000000000000..67a4953bcaaf --- /dev/null +++ b/crm_lead_substage/report/crm_opportunity_report_view.xml @@ -0,0 +1,19 @@ + + + + + + Opportunities report search (substage) + crm.opportunity.report + + + + + + + + + + diff --git a/crm_lead_substage/security/ir.model.access.csv b/crm_lead_substage/security/ir.model.access.csv new file mode 100644 index 000000000000..761590cdf3de --- /dev/null +++ b/crm_lead_substage/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_case_substage,crm.case.substage,model_crm_case_substage,,1,0,0,0 +access_crm_case_substage_manager,crm.case.substage,model_crm_case_substage,base.group_sale_manager,1,1,1,1 diff --git a/crm_lead_substage/static/description/icon.png b/crm_lead_substage/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/crm_lead_substage/static/description/icon.png differ diff --git a/crm_lead_substage/views/crm_lead_view.xml b/crm_lead_substage/views/crm_lead_view.xml new file mode 100644 index 000000000000..9350e8a29d09 --- /dev/null +++ b/crm_lead_substage/views/crm_lead_view.xml @@ -0,0 +1,34 @@ + + + + + + CRM - Leads Form (substage) + crm.lead + + + + + + + + + + Opportunities Form (substage) + crm.lead + + + + + + + + + + diff --git a/crm_lead_substage/views/crm_substage_view.xml b/crm_lead_substage/views/crm_substage_view.xml new file mode 100644 index 000000000000..7c8cec968fe6 --- /dev/null +++ b/crm_lead_substage/views/crm_substage_view.xml @@ -0,0 +1,38 @@ + + + + + + CRM case substage tree view + crm.case.substage + + + + + + + + + + Substages + crm.case.substage + form + tree + +

+ Click to set a new substage in your lead/opportunity pipeline. +

+ Substages will allow salespersons to easily refine the part or the + reason why a lead or opportunity is positioned in that stage. +

+
+
+ + + +
+