diff --git a/colour_code_project/__openerp__.py b/colour_code_project/__openerp__.py index 9c6d56e49..32a55de00 100644 --- a/colour_code_project/__openerp__.py +++ b/colour_code_project/__openerp__.py @@ -22,7 +22,7 @@ { 'name': "Automatic Colour Code for Task", 'summary': """Automatic Colour Code for Task Based on Project""", - 'author': "Cybrosys Technologies", + 'author': "Cybrosys Techno Solutions", 'website': "http://www.cybrosys.com", 'category': 'Project', 'version': '1.0', diff --git a/colour_code_project/__openerp__.py~ b/colour_code_project/__openerp__.py~ index 6906773af..9c6d56e49 100644 --- a/colour_code_project/__openerp__.py~ +++ b/colour_code_project/__openerp__.py~ @@ -6,7 +6,6 @@ # Author: Nilmar Shereef() # 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. # diff --git a/crm_drag_back_permission/__init__.py b/crm_drag_back_permission/__init__.py new file mode 100644 index 000000000..b2462eb50 --- /dev/null +++ b/crm_drag_back_permission/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2009-TODAY Cybrosys Technologies(). +# Author: Nilmar Shereef() +# 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 . +# +############################################################################## +import models diff --git a/crm_drag_back_permission/__openerp__.py b/crm_drag_back_permission/__openerp__.py new file mode 100644 index 000000000..feaaf47bf --- /dev/null +++ b/crm_drag_back_permission/__openerp__.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2009-TODAY Cybrosys Technologies(). +# Author: Nilmar Shereef() +# 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 . +# +############################################################################## +{ + '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, +} diff --git a/crm_drag_back_permission/models/__init__.py b/crm_drag_back_permission/models/__init__.py new file mode 100644 index 000000000..f65017551 --- /dev/null +++ b/crm_drag_back_permission/models/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2009-TODAY Cybrosys Technologies(). +# Author: Nilmar Shereef() +# 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 . +# +############################################################################## +import update_kanban_record + + diff --git a/crm_drag_back_permission/models/update_kanban_record.py b/crm_drag_back_permission/models/update_kanban_record.py new file mode 100644 index 000000000..77fec0108 --- /dev/null +++ b/crm_drag_back_permission/models/update_kanban_record.py @@ -0,0 +1,136 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2009-TODAY Cybrosys Technologies(). +# Author: Nilmar Shereef() +# 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 . +# +############################################################################## +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.") + + + + + diff --git a/crm_drag_back_permission/security/ir.model.access.csv b/crm_drag_back_permission/security/ir.model.access.csv new file mode 100644 index 000000000..768541c58 --- /dev/null +++ b/crm_drag_back_permission/security/ir.model.access.csv @@ -0,0 +1,4 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_crm_case_stage,crm.case.stage,model_crm_case_stage,base.group_sale_salesman,1,1,1,1 +access_crm_case_stage_head,crm.case.stage,model_crm_case_stage,base.group_sale_salesman_all_leads,1,1,1,1 + diff --git a/crm_drag_back_permission/static/description/banner.jpg b/crm_drag_back_permission/static/description/banner.jpg new file mode 100644 index 000000000..590a4015d Binary files /dev/null and b/crm_drag_back_permission/static/description/banner.jpg differ diff --git a/crm_drag_back_permission/static/description/icon.png b/crm_drag_back_permission/static/description/icon.png new file mode 100644 index 000000000..c2fcd1632 Binary files /dev/null and b/crm_drag_back_permission/static/description/icon.png differ diff --git a/crm_drag_back_permission/static/description/image1.png b/crm_drag_back_permission/static/description/image1.png new file mode 100644 index 000000000..bac1f45a3 Binary files /dev/null and b/crm_drag_back_permission/static/description/image1.png differ diff --git a/crm_drag_back_permission/static/description/image2.png b/crm_drag_back_permission/static/description/image2.png new file mode 100644 index 000000000..dd1e96b23 Binary files /dev/null and b/crm_drag_back_permission/static/description/image2.png differ diff --git a/crm_drag_back_permission/static/description/image3.png b/crm_drag_back_permission/static/description/image3.png new file mode 100644 index 000000000..7d048104c Binary files /dev/null and b/crm_drag_back_permission/static/description/image3.png differ diff --git a/crm_drag_back_permission/static/description/image5.png b/crm_drag_back_permission/static/description/image5.png new file mode 100644 index 000000000..50e5159f9 Binary files /dev/null and b/crm_drag_back_permission/static/description/image5.png differ diff --git a/crm_drag_back_permission/static/description/index.html b/crm_drag_back_permission/static/description/index.html new file mode 100644 index 000000000..be30b971d --- /dev/null +++ b/crm_drag_back_permission/static/description/index.html @@ -0,0 +1,93 @@ +
+
+

CRM Kanban Drag Back

+

Permission for Back Drag in CRM Kanban view

+

Author : Cybrosys Techno Solutions , www.cybrosys.com

+
+
+
+ This module restricts some users to drag leads backwards in sales pipeline without permission. +
+
+ +
+
+
+ +
+
+
+

+ Go to Settings -> Configuration -> Sales, and enable the 'Manage Sales Teams' option + under the Sales Teams. +

+
+
+
+ +
+
+
+

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

+
+
+
+ +
+
+
+

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

+
+
+ +
+
+ +
+
+
+
+
+
+

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

+
+
+
+ +
+
+
+
+ +
+

Need Any Help?

+ +
+ + + diff --git a/crm_drag_back_permission/static/src/js/hide_stage.js b/crm_drag_back_permission/static/src/js/hide_stage.js new file mode 100644 index 000000000..ccd5988d7 --- /dev/null +++ b/crm_drag_back_permission/static/src/js/hide_stage.js @@ -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); + + }, + }); +} \ No newline at end of file diff --git a/crm_drag_back_permission/views/crm_lead_update.xml b/crm_drag_back_permission/views/crm_lead_update.xml new file mode 100644 index 000000000..aa3ddeaec --- /dev/null +++ b/crm_drag_back_permission/views/crm_lead_update.xml @@ -0,0 +1,115 @@ + + + + + Leads updated + crm.lead + + + + + + + + + 1 + + + {'invisible': [('stage_type','=','approval')]} + + + +