Skip to content

Commit

Permalink
[ADD] crm_lead_substage: Substages for leads/opportunities
Browse files Browse the repository at this point in the history
=================================
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.
  • Loading branch information
pedrobaeza committed Feb 1, 2016
1 parent ac40a07 commit acbf9f5
Show file tree
Hide file tree
Showing 16 changed files with 408 additions and 0 deletions.
64 changes: 64 additions & 0 deletions crm_lead_substage/README.rst
Original file line number Diff line number Diff line change
@@ -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
<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 smashing it by providing a detailed and welcomed `feedback
<https://github.com/OCA/
crm/issues/new?body=module:%20
crm_lead_substage%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Credits
=======

Contributors
------------

* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>

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.
7 changes: 7 additions & 0 deletions crm_lead_substage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import models
from . import report
26 changes: 26 additions & 0 deletions crm_lead_substage/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# 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,
}
99 changes: 99 additions & 0 deletions crm_lead_substage/i18n/es.po
Original file line number Diff line number Diff line change
@@ -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 "<p class=\"oe_view_nocontent_create\">\n"
" Click to set a new substage in your lead/opportunity pipeline.\n"
" </p><p>\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"
" </p>\n"
" "
msgstr "<p class=\"oe_view_nocontent_create\">\n"
" Pulse para establecer una nueva subetapa en su operativa de iniciativas/oportunidades.\n"
" </p><p>\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"
" </p>\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"

7 changes: 7 additions & 0 deletions crm_lead_substage/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import crm_case_substage
from . import crm_lead
15 changes: 15 additions & 0 deletions crm_lead_substage/models/crm_case_substage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# 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)
21 changes: 21 additions & 0 deletions crm_lead_substage/models/crm_lead.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# 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
7 changes: 7 additions & 0 deletions crm_lead_substage/report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import crm_lead_report
from . import crm_opportunity_report
24 changes: 24 additions & 0 deletions crm_lead_substage/report/crm_lead_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# 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)
19 changes: 19 additions & 0 deletions crm_lead_substage/report/crm_lead_report_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record id="view_report_crm_lead_filter" model="ir.ui.view">
<field name="name">Leads report search (substage)</field>
<field name="model">crm.lead.report</field>
<field name="inherit_id" ref="crm.view_report_crm_lead_filter"/>
<field name="arch" type="xml">
<filter context="{'group_by':'stage_id'}" position="after">
<filter string="Substage"
context="{'group_by': 'substage_id'}"
/>
</filter>
</field>
</record>

</data>
</openerp>
25 changes: 25 additions & 0 deletions crm_lead_substage/report/crm_opportunity_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# 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)
19 changes: 19 additions & 0 deletions crm_lead_substage/report/crm_opportunity_report_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record id="view_report_crm_opportunity_filter" model="ir.ui.view">
<field name="name">Opportunities report search (substage)</field>
<field name="model">crm.opportunity.report</field>
<field name="inherit_id" ref="crm.view_report_crm_opportunity_filter"/>
<field name="arch" type="xml">
<filter context="{'group_by':'stage_id'}" position="after">
<filter string="Substage"
context="{'group_by': 'substage_id'}"
/>
</filter>
</field>
</record>

</data>
</openerp>
3 changes: 3 additions & 0 deletions crm_lead_substage/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -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
Binary file added crm_lead_substage/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions crm_lead_substage/views/crm_lead_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>

<record model="ir.ui.view" id="crm_case_form_view_leads">
<field name="name">CRM - Leads Form (substage)</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_leads"/>
<field name="arch" type="xml">
<field name="stage_id" position="after">
<field name="substage_id"
widget="statusbar"
clickable="True"
/>
</field>
</field>
</record>

<record model="ir.ui.view" id="crm_case_form_view_oppor">
<field name="name">Opportunities Form (substage)</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
<field name="arch" type="xml">
<field name="stage_id" position="after">
<field name="substage_id"
widget="statusbar"
clickable="True"
/>
</field>
</field>
</record>

</data>
</openerp>
Loading

0 comments on commit acbf9f5

Please sign in to comment.