18 changed files with 489 additions and 2 deletions
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# Copyright (C) 2009-TODAY Cybrosys Technologies(<http://www.cybrosys.com>). |
|||
# Author: Nilmar Shereef(<http://www.cybrosys.com>) |
|||
# you can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# It is forbidden to publish, distribute, sublicense, or sell copies |
|||
# of the Software or modified copies of the Software. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
import models |
@ -0,0 +1,43 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# Copyright (C) 2009-TODAY Cybrosys Technologies(<http://www.cybrosys.com>). |
|||
# Author: Nilmar Shereef(<http://www.cybrosys.com>) |
|||
# you can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# It is forbidden to publish, distribute, sublicense, or sell copies |
|||
# of the Software or modified copies of the Software. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
{ |
|||
'name': 'CRM Kanban Drag Back Permission', |
|||
'version': '0.2', |
|||
'category': 'CRM', |
|||
'sequence': 6, |
|||
'summary': 'Permission for Drag Back in CRM', |
|||
'author': 'Cybrosys Techno Solutions', |
|||
'company': 'Cybrosys Techno Solutions', |
|||
'website': 'http://www.cybrosys.com', |
|||
'depends': ['crm', 'sale', 'sales_team'], |
|||
'images': ['static/description/banner.jpg'], |
|||
'data': [ |
|||
'views/crm_sales_team.xml', |
|||
'views/crm_lead_update.xml', |
|||
'views/templates.xml', |
|||
'security/ir.model.access.csv', |
|||
|
|||
], |
|||
'installable': True, |
|||
'auto_install': False, |
|||
} |
@ -0,0 +1,25 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# Copyright (C) 2009-TODAY Cybrosys Technologies(<http://www.cybrosys.com>). |
|||
# Author: Nilmar Shereef(<http://www.cybrosys.com>) |
|||
# you can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# It is forbidden to publish, distribute, sublicense, or sell copies |
|||
# of the Software or modified copies of the Software. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
import update_kanban_record |
|||
|
|||
|
@ -0,0 +1,136 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# Copyright (C) 2009-TODAY Cybrosys Technologies(<http://www.cybrosys.com>). |
|||
# Author: Nilmar Shereef(<http://www.cybrosys.com>) |
|||
# you can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# It is forbidden to publish, distribute, sublicense, or sell copies |
|||
# of the Software or modified copies of the Software. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
from openerp import models, fields, api |
|||
|
|||
|
|||
class StageChange(models.Model): |
|||
_inherit = 'crm.lead' |
|||
|
|||
stage_previous = fields.Integer(string="Previous stage", default=False) |
|||
stage_next = fields.Integer(string="Next stage", default=False) |
|||
stage_type = fields.Char() |
|||
new_stage_id = fields.Selection([('previous', 'Previous'), ('current', 'Current'), ('next', 'Next')], readonly=True) |
|||
previous = fields.Char(string="Previous Stage", compute='get_previous_stage') |
|||
next_stage = fields.Char(string="Next Stage", compute='get_next_stage') |
|||
|
|||
@api.one |
|||
def get_previous_stage(self): |
|||
self.previous = self.env['crm.case.stage'].search([('id', '=', self.stage_previous)]).name |
|||
|
|||
@api.one |
|||
def get_next_stage(self): |
|||
self.next_stage = self.env['crm.case.stage'].search([('id', '=', self.stage_next)]).name |
|||
|
|||
@api.one |
|||
def approve_oppor(self): |
|||
self.write({'stage_id': self.env['crm.case.stage'].browse([self.stage_next]).id, 'stage_previous': self.stage_id.id, 'stage_next': 0, 'new_stage_id': ''}) |
|||
return |
|||
|
|||
@api.one |
|||
def decline_oppor(self): |
|||
self.write({'stage_id': self.env['crm.case.stage'].browse([self.stage_previous]).id, 'stage_previous': self.stage_id.id, 'stage_next': 0, 'new_stage_id': ''}) |
|||
return |
|||
|
|||
@api.multi |
|||
def write(self, vals): |
|||
if not vals.get('stage_previous') and vals.get('stage_id'): |
|||
last_stage = self.browse(self.ids).stage_id |
|||
|
|||
if self.env['crm.case.stage'].browse([vals['stage_id']]).stage_order < last_stage.stage_order \ |
|||
and not self.env['res.users'].browse(self._uid).has_group('base.group_sale_manager') \ |
|||
and not self.env['res.users'].browse(self._uid).has_group('base.group_sale_salesman_all_leads'): |
|||
vals['stage_previous'] = last_stage.id |
|||
vals['stage_next'] = vals['stage_id'] |
|||
vals['stage_type'] = "approval" |
|||
vals['new_stage_id'] = 'current' |
|||
to_approve = self.env['crm.case.stage'].search([('type', '=', 'approval'), ('name', '=', 'Waiting for approval')]) |
|||
if to_approve: |
|||
vals['stage_id'] = to_approve.id |
|||
else: |
|||
values = { |
|||
'name': "Waiting for approval", |
|||
'type': "approval", |
|||
'stage_order': -1, |
|||
} |
|||
result = self.env['crm.case.stage'].create(values) |
|||
vals['stage_id'] = result.id |
|||
|
|||
elif vals.get('stage_id'): |
|||
vals['stage_type'] = "" |
|||
res = super(StageChange, self).write(vals) |
|||
return res |
|||
|
|||
def get_approvals(self, cr, uid, context=None): |
|||
tree_res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', |
|||
'crm_case_tree_view_oppor') |
|||
x = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm_drag_back_permission', 'action_waiting_approval_window') |
|||
tree_id = tree_res and tree_res[1] or False |
|||
form_res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', |
|||
'crm_case_form_view_leads') |
|||
form_id = form_res and form_res[1] or False |
|||
approval_stage = self.pool.get('crm.lead') |
|||
approvals = approval_stage.search(cr, uid, [('stage_id.type', '=', "approval")]) |
|||
user_obj = self.pool.get('res.users') |
|||
u_id = user_obj.browse(cr, uid, uid, context=context) |
|||
if u_id.has_group('base.group_sale_salesman_all_leads') and u_id.has_group( |
|||
'base.group_sale_salesman') and u_id.has_group('base.group_sale_manager'): |
|||
object_list = approvals |
|||
elif u_id.has_group('base.group_sale_salesman_all_leads') and u_id.has_group('base.group_sale_salesman'): |
|||
teams = self.pool.get('crm.case.section').search(cr, uid, [('user_id.id', '=', uid)]) |
|||
object_list = [] |
|||
if approvals: |
|||
for obj in approvals: |
|||
if self.pool.get('crm.lead').browse(cr, uid, [obj]).section_id.id in teams: |
|||
object_list.append(obj) |
|||
elif u_id.has_group('base.group_sale_salesman'): |
|||
object_list = [] |
|||
if approvals: |
|||
for obj in approvals: |
|||
if self.pool.get('crm.lead').browse(cr, uid, [obj]).user_id.id == uid: |
|||
object_list.append(obj) |
|||
return { |
|||
'model': 'ir.actions.act_window', |
|||
'name': 'Waiting Approval', |
|||
'type': 'ir.actions.act_window', |
|||
'view_type': 'form', |
|||
'view_mode': 'form,tree', |
|||
'res_model': 'crm.lead', |
|||
'views': [(tree_id, 'tree'), (form_id, 'form')], |
|||
'domain': [('id', 'in', object_list)], |
|||
'id': x[1], |
|||
} |
|||
|
|||
|
|||
class NewStage(models.Model): |
|||
_inherit = 'crm.case.stage' |
|||
|
|||
stage_order = fields.Integer(string='Order') |
|||
type = fields.Selection([('lead', 'Lead'), ('opportunity', 'Opportunity'), ('both', 'Both'), ('approval', '')], |
|||
string='Type', required=True, |
|||
help="This field is used to distinguish stages related to Leads from stages related to " |
|||
"Opportunities or to specify stages available for both types.") |
|||
|
|||
|
|||
|
|||
|
|||
|
|
After Width: | Height: | Size: 120 KiB |
After Width: | Height: | Size: 9.3 KiB |
After Width: | Height: | Size: 64 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 61 KiB |
@ -0,0 +1,93 @@ |
|||
<section class="oe_container"> |
|||
<div class="oe_row oe_spaced"> |
|||
<h2 class="oe_slogan">CRM Kanban Drag Back</h2> |
|||
<h3 class="oe_slogan">Permission for Back Drag in CRM Kanban view</h3> |
|||
<h4 class="oe_slogan">Author : Cybrosys Techno Solutions , www.cybrosys.com</h4> |
|||
</div> |
|||
<div class="oe_row oe_spaced"> |
|||
<div> |
|||
This module restricts some users to drag leads backwards in sales pipeline without permission. |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="oe_row oe_spaced"> |
|||
<div class="oe_span12"> |
|||
<div class="oe_demo oe_picture oe_screenshot"> |
|||
<img src="image1.png"> |
|||
</div> |
|||
</div> |
|||
<div class="oe_span12"> |
|||
<p class='oe_mt32'> |
|||
Go to Settings -> Configuration -> Sales, and enable the 'Manage Sales Teams' option |
|||
under the Sales Teams. |
|||
</p> |
|||
</div> |
|||
<div class="oe_span12"> |
|||
<div class="oe_demo oe_picture oe_screenshot"> |
|||
<img src="image2.png"> |
|||
</div> |
|||
</div> |
|||
<div class="oe_span12"> |
|||
<p class='oe_mt32'> |
|||
Go to Configuration -> Stages, and set an 'order'(integer value) for each stage you want to use in the pipeline. |
|||
The drag back is working based on this 'order' field value. When a user tries to drag a lead from one stage to another, |
|||
we will check the 'order' of those two stages. |
|||
If the movement is from a stage with higher order value to a stage with lower order value, it will be considered |
|||
as a back drag. |
|||
</p> |
|||
</div> |
|||
</div> |
|||
</section> |
|||
|
|||
<section> |
|||
<div class="oe_row oe_spaced"> |
|||
<div class="oe_span12"> |
|||
<p class='oe_mt32'> |
|||
When a salesperson tries to perform a back drag, the lead will go to a new stage, 'Waiting for Approval'. |
|||
From this stage, the Administrator or the Head of Sales of team which the lead belongs to, can |
|||
approve the lead to the stage requested by the user or decline the lead back to it's previous stage. |
|||
The salesperson can't move the lead from this stage. |
|||
</p> |
|||
<div class="oe_span12"> |
|||
<div class="oe_demo oe_picture oe_screenshot"> |
|||
<img src="image3.png"> |
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
</section> |
|||
<section> |
|||
<div class="oe_row oe_spaced"> |
|||
<div class="oe_span12"> |
|||
<p class='oe_mt32'> |
|||
In the 'Waiting for Approval' stage, a lead will be visible only to the administrator, |
|||
the user to which the lead is assigned to and the head of sales of team that the lead belongs to. |
|||
When we select a lead in the 'Waiting for Approval' stage, we can see the stages, the lead comes from and where the lead is headed to. |
|||
</p> |
|||
</div> |
|||
<div class="oe_span12"> |
|||
<div class="oe_demo oe_picture oe_screenshot"> |
|||
<img src="image5.png"> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</section> |
|||
|
|||
<section class="oe_container oe_dark"> |
|||
<h2 class="oe_slogan">Need Any Help?</h2> |
|||
<div class="oe_slogan"> |
|||
<a class="btn btn-primary btn-lg mt8" |
|||
style="color: #FFFFFF !important;" href="http://www.cybrosys.com"><i |
|||
class="fa fa-envelope"></i> Email </a> <a |
|||
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;" |
|||
href="http://www.cybrosys.com/contact/"><i |
|||
class="fa fa-phone"></i> Contact Us </a> <a |
|||
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;" |
|||
href="http://www.cybrosys.com/odoo-customization-and-installation/"><i |
|||
class="fa fa-check-square"></i> Request Customization </a> |
|||
</div> |
|||
</section> |
|||
|
|||
|
|||
|
@ -0,0 +1,16 @@ |
|||
openerp.crm_drag_back_permission = function (instance) { |
|||
var kanbanview = instance.web_kanban; |
|||
kanbanview.KanbanView.include({ |
|||
do_process_groups: function (groups) { |
|||
var x = [] ; |
|||
for (var i in groups) { |
|||
if (groups[i]['attributes']['value'][1] != 'Waiting for approval') { |
|||
x[i] = groups[i]; |
|||
} |
|||
|
|||
} |
|||
this._super(x); |
|||
|
|||
}, |
|||
}); |
|||
} |
@ -0,0 +1,115 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<openerp> |
|||
<data> |
|||
<record id="crm_case_form_view_lead_updated" model="ir.ui.view"> |
|||
<field name="name">Leads updated</field> |
|||
<field name="model">crm.lead</field> |
|||
<field name="inherit_id" ref="crm.crm_case_form_view_leads" /> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//field[@name='partner_id']" position="after"> |
|||
<field name="stage_previous" invisible="1" /> |
|||
<field name="stage_next" invisible="1" /> |
|||
<field name="stage_type" invisible="1" /> |
|||
</xpath> |
|||
<xpath expr="//field[@name='user_id']" position="attributes"> |
|||
<attribute name="required">1</attribute> |
|||
</xpath> |
|||
<xpath expr="//form/header/field[@name='stage_id']" position="attributes"> |
|||
<attribute name="attrs">{'invisible': [('stage_type','=','approval')]}</attribute> |
|||
</xpath> |
|||
|
|||
<xpath expr="//form/header" position="inside"> |
|||
<button name="approve_oppor" string="Approve" groups="base.group_sale_manager,base.group_sale_salesman_all_leads" |
|||
type="object" class="oe_highlight o_wow" attrs="{'invisible': [('stage_type','!=','approval')]}"/> |
|||
<button name="decline_oppor" string="Decline" groups="base.group_sale_manager,base.group_sale_salesman_all_leads" |
|||
type="object" class="oe_highlight o_wow" attrs="{'invisible': [('stage_type','!=','approval')]}"/> |
|||
|
|||
</xpath> |
|||
<xpath expr="//form/header/button[1]" position="attributes"> |
|||
<attribute name="attrs">{'invisible': [('stage_type','=','approval')]} |
|||
</attribute> |
|||
</xpath> |
|||
|
|||
<xpath expr="//group[1]/group[2]" position="before"> |
|||
<group> |
|||
<field name="previous" /> |
|||
<field name="next_stage"/> |
|||
</group> |
|||
</xpath> |
|||
|
|||
</field> |
|||
</record> |
|||
|
|||
<record id="crm_case_form_view_opport_updated" model="ir.ui.view"> |
|||
<field name="name">Opportunity updated</field> |
|||
<field name="model">crm.lead</field> |
|||
<field name="inherit_id" ref="crm.crm_case_form_view_oppor" /> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//field[@name='partner_id']" position="after"> |
|||
<field name="stage_previous" invisible="1" /> |
|||
<field name="stage_next" invisible="1" /> |
|||
<field name="stage_type" invisible="1" /> |
|||
</xpath> |
|||
<xpath expr="//field[@name='user_id']" position="attributes"> |
|||
<attribute name="required">1</attribute> |
|||
</xpath> |
|||
|
|||
<xpath expr="//form/header/field[@name='stage_id']" position="attributes"> |
|||
<attribute name="attrs">{'invisible': [('stage_type','=','approval')]}</attribute> |
|||
</xpath> |
|||
|
|||
|
|||
<xpath expr="//form/header" position="inside"> |
|||
<button name="approve_oppor" string="Approve" groups="base.group_sale_manager,base.group_sale_salesman_all_leads" |
|||
type="object" class="oe_highlight o_wow" attrs="{'invisible': [('stage_type','!=','approval')]}"/> |
|||
<button name="decline_oppor" string="Decline" groups="base.group_sale_manager,base.group_sale_salesman_all_leads" |
|||
type="object" class="oe_highlight o_wow" attrs="{'invisible': [('stage_type','!=','approval')]}" /> |
|||
|
|||
</xpath> |
|||
<xpath expr="//form/header/button[1]" position="attributes"> |
|||
<attribute name="attrs">{'invisible': [('stage_type','=','approval')]}</attribute> |
|||
</xpath> |
|||
|
|||
<xpath expr="//group[1]/group[2]" position="before"> |
|||
<group> |
|||
<field name="previous" /> |
|||
<field name="next_stage"/> |
|||
</group> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="crm_case_stage_updated" model="ir.ui.view"> |
|||
<field name="name">Stages Updated</field> |
|||
<field name="model">crm.case.stage</field> |
|||
<field name="inherit_id" ref="crm.crm_case_stage_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//field[@name='on_change']" position="after"> |
|||
<field name="stage_order" /> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="action_waiting_approval_window" model="ir.actions.act_window"> |
|||
<field name="name">Waiting</field> |
|||
<field name="res_model">crm.lead</field> |
|||
<field name="view_type">form</field> |
|||
<field name="view_mode">tree,form</field> |
|||
</record> |
|||
|
|||
|
|||
<record id="action_waiting_approval" model="ir.actions.server"> |
|||
<field name="name">Waiting</field> |
|||
<field name="type">ir.actions.server</field> |
|||
<field name="res_model">crm.lead</field> |
|||
<field name="model_id" ref="model_crm_lead"/> |
|||
<field name="view_type">form</field> |
|||
<field name="view_mode">tree,form</field> |
|||
<field name="state">code</field> |
|||
<field name="code">action = self.get_approvals(cr, uid, context=context)</field> |
|||
</record> |
|||
|
|||
<menuitem name="Waiting for approval" id="waiting_approval" action="action_waiting_approval" parent="base.menu_sales" /> |
|||
|
|||
</data> |
|||
</openerp> |
@ -0,0 +1,21 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
<record id="base.group_sale_manager" model="res.groups"> |
|||
<field name="name">CEO/Head of Business strategy</field> |
|||
<field name="implied_ids" eval="[(4, ref('base.group_sale_salesman'))]"/> |
|||
</record> |
|||
<record id="base.group_sale_salesman_all_leads" model="res.groups"> |
|||
<field name="name">Head Of Sales</field> |
|||
<field name="category_id" ref="base.module_category_sales_management"/> |
|||
<field name="implied_ids" eval="[(4, ref('base.group_sale_salesman'))]"/> |
|||
<field name="comment">the user will have access to all records of everyone in the sales application.</field> |
|||
</record> |
|||
<record id="base.group_sale_salesman" model="res.groups"> |
|||
<field name="name">SalesPerson</field> |
|||
<field name="category_id" ref="base.module_category_sales_management"/> |
|||
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/> |
|||
<field name="comment">the user will have access to his own data in the sales application.</field> |
|||
</record> |
|||
</data> |
|||
</openerp> |
@ -0,0 +1,12 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
<template id="assets_backend" name="hide_stage_kanban" inherit_id="web.assets_backend"> |
|||
<xpath expr="." position="inside"> |
|||
|
|||
<script type="text/javascript" src="/crm_drag_back_permission/static/src/js/hide_stage.js"></script> |
|||
|
|||
</xpath> |
|||
</template> |
|||
</data> |
|||
</openerp> |
Loading…
Reference in new issue