Browse Source

[ADD]Initial Commit

pull/29/head
SHEREEF PT 8 years ago
parent
commit
8ec6c3f9eb
  1. 24
      sales_team_parent/__init__.py
  2. 41
      sales_team_parent/__manifest__.py
  3. 25
      sales_team_parent/models/__init__.py
  4. 133
      sales_team_parent/models/crm_target.py
  5. 59
      sales_team_parent/models/crm_target_team.py
  6. 3
      sales_team_parent/security/ir.model.access.csv
  7. BIN
      sales_team_parent/static/description/banner.jpg
  8. BIN
      sales_team_parent/static/description/cybro_logo.png
  9. BIN
      sales_team_parent/static/description/icon.png
  10. 103
      sales_team_parent/static/description/index.html
  11. BIN
      sales_team_parent/static/description/parent-team.png
  12. BIN
      sales_team_parent/static/description/salesman-target.png
  13. BIN
      sales_team_parent/static/description/team-target.png
  14. 16
      sales_team_parent/views/parent_team.xml
  15. 76
      sales_team_parent/views/sales_man_target.xml
  16. 16
      sales_team_parent/views/sales_team_target.xml

24
sales_team_parent/__init__.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# Author: Cybrosys Technologies(<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

41
sales_team_parent/__manifest__.py

@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# Author: Cybrosys Technologies(<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': 'Parent Team & Targets',
'version': '10.0.1.0.0',
'category': 'Sales',
'summary': 'Sales Team Targets and Parent Teams',
'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions',
'website': 'http://www.cybrosys.com',
'depends': ['crm', 'sale'],
'images': ['static/description/banner.jpg'],
'data': [
'views/parent_team.xml',
'views/sales_man_target.xml',
'views/sales_team_target.xml',
'security/ir.model.access.csv',
],
'installable': True,
'auto_install': False,
}

25
sales_team_parent/models/__init__.py

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# Author: Cybrosys Technologies(<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 crm_target
import crm_target_team

133
sales_team_parent/models/crm_target.py

@ -0,0 +1,133 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# Author: Cybrosys Technologies(<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 datetime import datetime
from dateutil import relativedelta
from odoo import models, fields, api
from odoo.tools.translate import _
class CrmTeam(models.Model):
_name = "crm.target"
def get_currency(self):
return self.env.user.company_id.currency_id.id
name = fields.Char(string='Name', required=True)
user_id = fields.Many2one('res.users', 'Sales Person', required=True)
sales_team = fields.Many2one('crm.team', string='Sales Team')
target_amount = fields.Float('Target')
date_from = fields.Date("Starting date", required=True)
date_to = fields.Date("Ending date", required=True)
duration = fields.Integer(default=1)
currency_id = fields.Many2one('res.currency', store=True, string='Currency', readonly=True, default=lambda self: self.get_currency())
@api.onchange('user_id')
def onchange_salesman(self):
team_ids = self.env['crm.team'].search([])
dates = fields.Date
for team_id in team_ids:
for member_id in team_id.member_ids:
if self.user_id == member_id:
self.sales_team = team_id.id
@api.onchange('date_from', 'date_to')
def get_duration(self):
if self.date_from and self.date_to:
r = relativedelta.relativedelta(datetime.strptime(self.date_to, "%Y-%m-%d"), datetime.strptime(self.date_from, "%Y-%m-%d"))
t_day = datetime.strptime(self.date_to, "%Y-%m-%d").day
t_month = datetime.strptime(self.date_to, "%Y-%m-%d").month
t_year = datetime.strptime(self.date_to, "%Y-%m-%d").year
f_day = datetime.strptime(self.date_from, "%Y-%m-%d").day
f_month = datetime.strptime(self.date_from, "%Y-%m-%d").month
f_year = datetime.strptime(self.date_from, "%Y-%m-%d").year
if t_year < f_year:
self.date_from = None
self.date_to = None
return {
'warning': {
'title': _('Warning!'),
'message': _('Please check the date'),
}
}
elif t_year == f_year and t_month < f_month:
self.date_to = None
self.date_from = None
return {
'warning': {
'title': _('Warning!'),
'message': _('Please check the date'),
}
}
elif t_year == f_year and t_month == f_month and t_day < f_day:
self.date_to = None
self.date_from = None
return {
'warning': {
'title': _('Warning!'),
'message': _('Please check the date'),
}
}
self.duration = r.months if r.months > 0 else 1
def action_your_target(self):
tree_res = self.env['ir.model.data'].get_object_reference('sales_team_parent', 'sales_target_tree_view')
x = self.env['ir.model.data'].get_object_reference('sales_team_parent', 'action_crm_sales_target_act')
tree_id = tree_res and tree_res[1] or False
form_res = self.env['ir.model.data'].get_object_reference('sales_team_parent', 'sales_target_form_view')
form_id = form_res and form_res[1] or False
user_obj = self.env['res.users']
u_id = user_obj.browse([self._uid])
obj_target = self.env['crm.target'].search([])
if u_id.has_group('sales_team.group_sale_salesman_all_leads') and u_id.has_group(
'sales_team.group_sale_salesman') and u_id.has_group('sales_team.group_sale_manager'):
obj_target_list = obj_target.ids
else:
obj_target_list = []
if obj_target:
for obj in obj_target.ids:
print obj
if self.env['crm.target'].browse([obj]).user_id.id == self._uid:
obj_target_list.append(obj)
return {
'model': 'ir.actions.act_window',
'name': 'Target',
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'crm.target',
'views': [(tree_id, 'tree'), (form_id, 'form')],
'domain': [('id', 'in', obj_target_list)],
'id': x[1],
}

59
sales_team_parent/models/crm_target_team.py

@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# Author: Cybrosys Technologies(<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 odoo import models, fields, api
class CrmTeam(models.Model):
_inherit = 'crm.team'
def get_currency(self):
return self.env.user.company_id.currency_id.id
team_target = fields.Float(string='Team Target', compute="compute_team_target")
parent_team = fields.Many2one('crm.team', string='Parent Team', copy=False)
currency_id = fields.Many2one('res.currency', store=True, string='Currency', readonly=True, default=lambda self: self.get_currency())
@api.one
def compute_team_target(self):
total = 0
childs = self.get_childs(self.id)
childs += self
for team in childs:
for member_id in team.member_ids:
target = team.env['crm.target'].search([('user_id', '=', member_id.id)])
if target:
for t in target:
total += t.target_amount
team.team_target = total
return
def get_childs(self, team_id):
child_teams = self.search([('parent_team.id', '=', team_id)])
if child_teams:
for team in child_teams:
child_teams += self.get_childs(team.id)
return child_teams

3
sales_team_parent/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_target_sale_salesman,crm.target,model_crm_target,sales_team.group_sale_salesman_all_leads,1,0,0,0
access_crm_target_sale_manager,crm.target.manager,model_crm_target,sales_team.group_sale_salesman,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_crm_target_sale_salesman crm.target model_crm_target sales_team.group_sale_salesman_all_leads 1 0 0 0
3 access_crm_target_sale_manager crm.target.manager model_crm_target sales_team.group_sale_salesman 1 0 0 0

BIN
sales_team_parent/static/description/banner.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
sales_team_parent/static/description/cybro_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
sales_team_parent/static/description/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

103
sales_team_parent/static/description/index.html

@ -0,0 +1,103 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">Parent Team</h2>
<h3 class="oe_slogan">..Parent Team and Targets..</h3>
<h4 class="oe_slogan">Cybrosys Technologies , www.cybrosys.com</h4>
<div>
<p class='oe_mt32' style="text-align: center;">
This module by Cybrosys Technologies introduces the parent team - child team concept. We can also assign
targets to each salesperson.
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<h2 style="color:#875A7B;">Features</h2>
<div class="oe_span6 text-justify oe_mt32">
<p class="oe_mb32" style="margin-left:48px;">
&#x261B; Create parent team or child team for an existing sales team.
</p>
<p class="oe_mb32" style="margin-left:48px;">
&#x261B; Admin can assign targets to salesperson.
</p>
<p class="oe_mb32" style="margin-left:48px;">
&#x261B; View team target.
</p>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h3 class="oe_slogan">Create parent team.</h3>
<div class="oe_demo oe_screenshot">
<img src="parent-team.png">
</div>
<p class="oe_mt32" style="margin-left:48px;">
Go to Sales -> Configuration -> Sales Team. Select a team and assign a parent for that team. The parent-child relation
between sales teams will be useful in many situations. For example, the leader of parent team has power over it's child teams.
The parent team leader will be able to access his child team's targets.
</p>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h3 class="oe_slogan">Assign target to salesperson.</h3>
<div class="oe_demo oe_screenshot">
<img src="salesman-target.png">
</div>
<p class="oe_mt32" style="margin-left:48px;">
Go to Sales -> Configuration -> Salesman Target and assign targets to salesperson. Only administrator can
assign targets. Salesperson can view his targets only.
Head of sale can view all the targets of his team members and admin can see all the targets. </p>
<p class="oe_mt32" style="margin-left:48px;">
We can assign time duration for each target. When we enter the starting date and ending date of a target,
if it is not valid, the system will take care of it and informs us. The targets will always be in company currency.
</p>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h3 class="oe_slogan">Team target.</h3>
<div class="oe_demo oe_screenshot">
<img src="team-target.png">
</div>
<p class="oe_mt32" style="margin-left:48px;">
The total team target will be the sum of targets of it's members and it's child teams.
</p>
</div>
</div>
</section>
<section class="oe_container oe_dark" style="padding-top: 153px;">
<h2 class="oe_slogan" style="margin-top:20px;" >Need Any Help?</h2>
<div class="oe_slogan" style="margin-top:10px !important;">
<div>
<a class="btn btn-primary btn-lg mt8"
style="color: #FFFFFF !important;border-radius: 0;" 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;border-radius: 0;"
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;border-radius: 0;"
href="http://www.cybrosys.com/odoo-customization-and-installation/"><i
class="fa fa-check-square"></i> Request Customization </a>
</div>
<br>
<img src="cybro_logo.png" style="width: 190px; margin-bottom: 20px;" class="center-block">
<div>
<a href="https://twitter.com/cybrosys" target="_blank"><i class="fa fa-2x fa-twitter" style="color:white;background: #00a0d1;width:35px;"></i></a></td>
<a href="https://www.linkedin.com/company/cybrosys-technologies-pvt-ltd" target="_blank"><i class="fa fa-2x fa-linkedin" style="color:white;background: #31a3d6;width:35px;padding-left: 3px;"></i></a></td>
<a href="https://www.facebook.com/cybrosystechnologies" target="_blank"><i class="fa fa-2x fa-facebook" style="color:white;background: #3b5998;width:35px;padding-left: 8px;"></i></a></td>
<a href="https://plus.google.com/106641282743045431892/about" target="_blank"><i class="fa fa-2x fa-google-plus" style="color:white;background: #c53c2c;width:35px;padding-left: 3px;"></i></a></td>
<a href="https://in.pinterest.com/cybrosys" target="_blank"><i class="fa fa-2x fa-pinterest" style="color:white;background: #ac0f18;width:35px;padding-left: 3px;"></i></a></td>
</div>
</div>
</section>

BIN
sales_team_parent/static/description/parent-team.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

BIN
sales_team_parent/static/description/salesman-target.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
sales_team_parent/static/description/team-target.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

16
sales_team_parent/views/parent_team.xml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record model="ir.ui.view" id="sales_team_form_view_extended">
<field name="name">crm.team.form</field>
<field name="model">crm.team</field>
<field name="inherit_id" ref="sales_team.crm_team_view_form"/>
<field name="arch" type="xml">
<xpath expr="//group[1]/group[2]" position="inside">
<field name="parent_team"/>
</xpath>
</field>
</record>
</data>
</odoo>

76
sales_team_parent/views/sales_man_target.xml

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record model="ir.ui.view" id="sales_target_form_view">
<field name="name">crm.target.form</field>
<field name="model">crm.target</field>
<field name="arch" type="xml">
<form string="Targets">
<sheet>
<div class="oe_title">
<label for="name" string="Name" />
<h1>
<field name="name"/>
</h1>
</div>
<group>
<group>
<field name="user_id"/>
<field name="sales_team"/>
</group>
<group>
<field name="date_from"/>
<field name="date_to"/>
<field name="duration" invisible="1"/>
<field name="currency_id" invisible="1"/>
</group>
</group>
<group>
<group>
<field name="target_amount" class="oe_inline" widget='monetary' options="{'currency_field': 'currency_id'}"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record model="ir.ui.view" id="sales_target_tree_view">
<field name="name">crm.target.tree</field>
<field name="model">crm.target</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="user_id"/>
<field name="sales_team"/>
<field name="target_amount" widget='monetary' options="{'currency_field': 'currency_id'}"/>
<field name="date_from"/>
<field name="date_to"/>
</tree>
</field>
</record>
<record id="action_crm_sales_target_act" model="ir.actions.act_window">
<field name="name">Target</field>
<field name="res_model">crm.target</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<record id="action_crm_sales_target" model="ir.actions.server">
<field name="name">Targets</field>
<field name="type">ir.actions.server</field>
<field name="res_model">crm.target</field>
<field name="model_id" ref="model_crm_target"/>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="state">code</field>
<field name="code">action = model.action_your_target()</field>
</record>
<menuitem name="Target" id="main_menu_target" parent="sales_team.menu_base_partner" sequence="101" />
<menuitem name="Salesman Target" id="menu_crm_target" parent="main_menu_target" action="action_crm_sales_target"/>
</data>
</odoo>

16
sales_team_parent/views/sales_team_target.xml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record model="ir.ui.view" id="sales_team_target_form_view">
<field name="name">crm.team.target.form</field>
<field name="model">crm.team</field>
<field name="inherit_id" ref="sales_team.crm_team_view_form"/>
<field name="arch" type="xml">
<xpath expr="//group[1]/group[2]" position="inside">
<field name="currency_id" invisible="1"/>
<field name="team_target" widget='monetary' options="{'currency_field': 'currency_id'}"/>
</xpath>
</field>
</record>
</data>
</odoo>
Loading…
Cancel
Save