Browse Source

Initial Commit

pull/81/head
SHEREEF PT 8 years ago
parent
commit
601fb63113
  1. 14
      crm_won_lost_report/README.rst
  2. 25
      crm_won_lost_report/__init__.py
  3. 44
      crm_won_lost_report/__openerp__.py
  4. 24
      crm_won_lost_report/models/__init__.py
  5. 46
      crm_won_lost_report/models/crm_won_lost_report.py
  6. 26
      crm_won_lost_report/report/__init__.py
  7. 193
      crm_won_lost_report/report/crm_won_lost_report.py
  8. 3
      crm_won_lost_report/security/ir.model.access.csv
  9. BIN
      crm_won_lost_report/static/description/banner.jpg
  10. BIN
      crm_won_lost_report/static/description/icon.png
  11. 79
      crm_won_lost_report/static/description/index.html
  12. BIN
      crm_won_lost_report/static/description/report_xls.png
  13. 46
      crm_won_lost_report/views/new_menu_view.xml

14
crm_won_lost_report/README.rst

@ -0,0 +1,14 @@
CRM Won/Lost Leads XLS Report
=============================
This module will generate crm leads won/lost xls report.
Sales->Report -> Won/Lost Reports
Credits
=======
Cybrosys Techno Solutions
Author
------
* Cybrosys <www.cybrosys.com>

25
crm_won_lost_report/__init__.py

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2016-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Niyas Raphy(<https://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 <https://www.gnu.org/licenses/>.
#
##############################################################################
import models
import report

44
crm_won_lost_report/__openerp__.py

@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2016-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Niyas Raphy(<https://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 <https://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': "CRM Won/Lost XLS Report",
'version': '9.0.1.0.0',
"category": "Sales",
'summary': """Generate CRM XLS Report of Won/Lost Leads""",
'description': """Generate CRM XLS Report of Won/Lost leads""",
'author': "Cybrosys Techno Solutions",
'company': "Cybrosys Techno Solutions",
'website': "https://www.cybrosys.com",
'depends': ['base', 'crm', 'report_xlsx'],
'data': [
'views/new_menu_view.xml',
'security/ir.model.access.csv',
],
'images': ['static/description/banner.jpg'],
'license': 'LGPL-3',
'installable': True,
'auto_install': False,
'application': False,
}

24
crm_won_lost_report/models/__init__.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2016-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Niyas Raphy(<https://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 <https://www.gnu.org/licenses/>.
#
##############################################################################
import crm_won_lost_report

46
crm_won_lost_report/models/crm_won_lost_report.py

@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2016-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Niyas Raphy(<https://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 <https://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields
class ResUsers(models.Model):
_inherit = 'res.users'
user_ref_ids = fields.Many2many('res.users', 'ref2', 'ref1', 'sales_person', string="User", invisible=1)
class CrmReport(models.TransientModel):
_name = 'crm.won.lost.report'
sales_person = fields.Many2many('res.users', 'ref1', 'ref2', 'user_ref_ids', string="Sales Persons")
start_date = fields.Date('Start Date')
end_date = fields.Date('End Date', default=fields.Date.today)
def print_xls_report(self, cr, uid, ids, context=None):
data = self.read(cr, uid, ids)[0]
return {'type': 'ir.actions.report.xml',
'report_name': 'crm_won_lost_report.report_crm_won_lost_report.xlsx',
'datas': data
}

26
crm_won_lost_report/report/__init__.py

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2016-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Niyas Raphy(<https://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 <https://www.gnu.org/licenses/>.
#
##############################################################################
import crm_won_lost_report

193
crm_won_lost_report/report/crm_won_lost_report.py

@ -0,0 +1,193 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2016-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Niyas Raphy(<https://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 <https://www.gnu.org/licenses/>.
#
##############################################################################
from time import gmtime, strftime
from openerp.addons.report_xlsx.report.report_xlsx import ReportXlsx
class CrmReportWonLost(ReportXlsx):
def generate_xlsx_report(self, workbook, data, lines):
current_date = strftime("%Y-%m-%d", gmtime())
logged_users = self.env['res.users'].search([('id', '=', data['create_uid'][0])])
sheet = workbook.add_worksheet()
format1 = workbook.add_format({'font_size': 16, 'align': 'vcenter', 'bg_color': '#D3D3D3', 'bold': True})
format3 = workbook.add_format({'font_size': 10, 'bold': True})
format4 = workbook.add_format({'font_size': 10})
format5 = workbook.add_format({'font_size': 10, 'bg_color': '#FFFFFF'})
format7 = workbook.add_format({'font_size': 12, 'bg_color': '#eaeae1'})
format8 = workbook.add_format({'font_size': 10, 'bg_color': '#D3D3D3'})
format9 = workbook.add_format({'font_size': 10, 'align': 'vcenter', 'bg_color': '#ff1a1a', 'bold': True})
format10 = workbook.add_format({'font_size': 10, 'bg_color': '#00ff00'})
format11 = workbook.add_format({'font_size': 10, 'bg_color': '#ff0000'})
justify = workbook.add_format({'right': True, 'left': True, 'font_size': 12})
format3.set_align('center')
justify.set_align('justify')
format1.set_align('center')
sheet.merge_range('A1:B1', logged_users.company_id.name, format5)
sheet.merge_range('A2:M2', logged_users.company_id.street, format5)
sheet.write('A3', logged_users.company_id.city, format5)
sheet.merge_range('B3:N3', logged_users.company_id.zip, format5)
sheet.merge_range('A4:B4', logged_users.company_id.state_id.name, format5)
sheet.merge_range('A5:B5', logged_users.company_id.country_id.name, format5)
sheet.merge_range('M1:N1', logged_users.company_id.rml_header1, format5)
sheet.write('M4', "From Date:", format5)
if data['start_date']:
sheet.write('N4', data['start_date'], format5)
else:
sheet.write('N4', '', format5)
sheet.write('M5', 'To Date:', format5)
if data['end_date']:
sheet.write('N5', data['end_date'], format5)
else:
sheet.write('N5', current_date, format5)
sheet.merge_range(0, 2, 4, 11, "", format5)
sheet.merge_range(1, 2, 2, 13, "", format5)
sheet.merge_range(1, 6, 4, 8, "", format5)
irow = 5
icol = 0
sheet.merge_range(irow, icol, irow+2, icol + 13, 'CRM WON/LOST REPORT', format1)
sheet.merge_range('A9:B9', "Sales Person", format7)
sheet.write('C9', "Status", format7)
sheet.merge_range('D9:G9', "Lead Name", format7)
sheet.write('H9', "Exp. Rev", format7)
sheet.merge_range('I9:K9', "Reason", format7)
sheet.merge_range('L9:N9', "Internal Note", format7)
sales_person = []
if data['sales_person']:
for user_sales in data['sales_person']:
sales_person.append(user_sales)
else:
res_users = self.env['res.users'].search([])
for users in res_users:
sales_person.append(users.id)
irow = 8
icol = 0
for person in sales_person:
lost_list = []
sale_users = self.env['res.users'].search([('id', '=', person)])
lost_leads = self.env['crm.lead'].search([('active', '=', False)])
if data['start_date'] and data['end_date']:
crm_stages = self.env['crm.lead'].search([('user_id', '=', person),
('date_closed', '>=', data['start_date']),
('date_closed', '<=', data['end_date'])])
for lost in lost_leads:
if lost.user_id.id == person:
if lost.create_date >= data['start_date'] and lost.create_date < data['end_date']:
lost_list.append(lost.id)
elif data['start_date'] and not data['end_date']:
crm_stages = self.env['crm.lead'].search([('user_id', '=', person),
('date_closed', '>=', data['start_date'])])
for lost in lost_leads:
if lost.user_id.id == person:
if lost.create_date >= data['start_date']:
lost_list.append(lost.id)
elif not data['start_date'] and data['end_date']:
crm_stages = self.env['crm.lead'].search([('user_id', '=', person),
('date_closed', '<=', data['end_date'])])
for lost in lost_leads:
if lost.user_id.id == person:
if lost.create_date < data['end_date']:
lost_list.append(lost.id)
else:
crm_stages = self.env['crm.lead'].search([('user_id', '=', person)])
for lost in lost_leads:
if lost.user_id.id == person:
lost_list.append(lost.id)
if crm_stages or lost_list:
irow += 1
sheet.merge_range(irow, icol, irow, icol + 1, sale_users.partner_id.name, format8)
sheet.write(irow, icol + 2, '', format8)
sheet.merge_range(irow, icol+3, irow, icol + 6, '', format8)
sheet.write(irow, icol + 7, '', format8)
sheet.merge_range(irow, icol + 8, irow, icol+10, '', format8)
sheet.merge_range(irow, icol + 11, irow, icol + 13, '', format8)
won_list = []
for stages in crm_stages:
if stages.active and stages.date_closed:
won_list.append(stages.id)
if won_list:
irow += 1
icol = 0
sheet.merge_range(irow, icol, irow, icol + 1, '', format3)
sheet.write(irow, icol + 2, 'Won', format10)
sheet.merge_range(irow, icol + 3, irow, icol + 6, '', format3)
sheet.write(irow, icol + 7, '', format3)
sheet.merge_range(irow, icol + 8, irow, icol + 10, '', format3)
sheet.merge_range(irow, icol + 11, irow, icol + 13, '', format3)
for won_leads in won_list:
lead_won = self.env['crm.lead'].search([('id', '=', won_leads)])
irow += 1
icol = 0
sheet.merge_range(irow, icol, irow, icol + 1, '', format3)
sheet.write(irow, icol + 2, '', format3)
sheet.merge_range(irow, icol + 3, irow, icol + 6, lead_won.name, format4)
if lead_won.planned_revenue:
sheet.write(irow, icol + 7, lead_won.planned_revenue, format4)
else:
sheet.write(irow, icol + 7, '', format4)
sheet.merge_range(irow, icol + 8, irow, icol + 10, '', format4)
if lead_won.description:
sheet.merge_range(irow, icol + 11, irow, icol + 13, lead_won.description, format4)
else:
sheet.merge_range(irow, icol + 11, irow, icol + 13, '', format4)
if lost_list:
irow += 1
icol = 0
sheet.merge_range(irow, icol, irow, icol + 1, '', format3)
sheet.write(irow, icol + 2, 'Lost', format11)
sheet.merge_range(irow, icol + 3, irow, icol + 6, '', format3)
sheet.write(irow, icol + 7, '', format3)
sheet.merge_range(irow, icol + 8, irow, icol + 10, '', format3)
sheet.merge_range(irow, icol + 11, irow, icol + 13, '', format3)
all_lead_lost = self.env['crm.lead'].search([('active', '=', False)])
for lost_leads in all_lead_lost:
if lost_leads.lost_reason:
get_lost_reason = self.env['crm.lost.reason'].search([('id', '=', lost_leads.lost_reason.id)])
reason_lost = get_lost_reason.name
if lost_leads.id in lost_list:
irow += 1
icol = 0
sheet.merge_range(irow, icol, irow, icol + 1, '', format3)
sheet.write(irow, icol + 2, '', format3)
sheet.merge_range(irow, icol + 3, irow, icol + 6, lost_leads.name, format4)
if lost_leads.planned_revenue:
sheet.write(irow, icol + 7, lost_leads.planned_revenue, format4)
else:
sheet.write(irow, icol + 7, '', format4)
if lost_leads.lost_reason:
sheet.merge_range(irow, icol + 8, irow, icol + 10, reason_lost, format4)
else:
sheet.merge_range(irow, icol + 8, irow, icol + 10, '', format4)
if lost_leads.description:
sheet.merge_range(irow, icol + 11, irow, icol + 13, lost_leads.description, format4)
else:
sheet.merge_range(irow, icol + 11, irow, icol + 13, '', format4)
if not won_list and not lost_list:
sheet.merge_range(irow + 1, icol, irow + 2, icol + 13, 'No Won/Lost Leads', format9)
irow += 2
sheet.merge_range(irow + 1, icol, irow + 2, icol + 13, '', format1)
CrmReportWonLost('report.crm_won_lost_report.report_crm_won_lost_report.xlsx', 'crm.won.lost.report')

3
crm_won_lost_report/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_won_lost_report,access.crm.report,model_crm_won_lost_report,base.group_sale_manager,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_crm_won_lost_report access.crm.report model_crm_won_lost_report base.group_sale_manager 1 1 1 1

BIN
crm_won_lost_report/static/description/banner.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

BIN
crm_won_lost_report/static/description/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

79
crm_won_lost_report/static/description/index.html

@ -0,0 +1,79 @@
<section class="oe_container">
<div class="oe_spaced">
<h2 class="oe_slogan">CRM WON/LOST XLS REPORT</h2>
<h3 class="oe_slogan">This Module generate won / lost XLS report for the CRM leads .</h3>
<h4 class="oe_slogan" style="font-size: 23px;">Author : Cybrosys Techno Solutions , www.cybrosys.com</h4>
</div>
<div class="oe_spaced" style="padding-left:65px;">
<h4>Features:</h4>
<div>
<span style="color:green;"> &#9745; </span> XLS report<br/>
<span style="color:green;"> &#9745; </span> In report, filters like sales person, start date and end date is added<br/>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_picture">
<h3 class="oe_slogan">Overview</h3>
<p class="oe_mt32">
Currently in Odoo there is no won / lost XLS report for the CRM leads. This module will add such a feature so that
it will be easy to distinguish each sales person's perfomance based on his/her won and lost leads
</p>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h3 class="oe_slogan">Report</h3>
<div class="" style="text-align: center">
<p>
You can take the report from,
<h4>Sales-> Report -> Won/Lost Reports</h4>
<p>
</div>
<div class="oe_span12">
<div class="" style="text-align: center">
<p>
Sample Report
<p>
</div>
<div class="oe_row_img oe_centered">
<img class="oe_picture oe_screenshot" style="border:10px solid white;" src="report_xls.png">
</div>
</div>
<br>
</div>
</section>
<section class="oe_container oe_dark">
<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="https://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="https://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="https://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
crm_won_lost_report/static/description/report_xls.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

46
crm_won_lost_report/views/new_menu_view.xml

@ -0,0 +1,46 @@
<?xml version="1.0"?>
<openerp>
<data>
<report
id="partner_xlsx"
model="crm.won.lost.report"
string="Won/Lost Report"
report_type="xlsx"
name="crm_won_lost_report.report_crm_won_lost_report.xlsx"
file="crm_won_lost_report.report_crm_won_lost_report.xlsx"
attachment_use="False"
/>
<record id="view_crm_won_lost_report" model="ir.ui.view">
<field name="name">CRM Report</field>
<field name="model">crm.won.lost.report</field>
<field name="arch" type="xml">
<form string="Choose your details">
<group>
<group>
<field name="sales_person" widget="many2many_tags" style="width: 40%%" />
</group>
<group>
<field name="start_date" />
<field name="end_date" />
</group>
</group>
<footer>
<button name="print_xls_report" string="Print Report" type="object" class="oe_highlight" />
or
<button string="Cancel" class="oe_link" special="cancel" groups="base.group_sale_manager"/>
</footer>
</form>
</field>
</record>
<record id="action_crm_won_lost_report" model="ir.actions.act_window">
<field name="name">WON / LOST Report</field>
<field name="res_model">crm.won.lost.report</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_crm_won_lost_report"/>
<field name="target">new</field>
</record>
<menuitem id="crm_won_lost_report_menu" name="WON / LOST Report" parent="base.menu_sale_report" action="action_crm_won_lost_report" groups="base.group_sale_manager"/>
</data>
</openerp>
Loading…
Cancel
Save