diff --git a/crm_kit/README.rst b/crm_kit/README.rst new file mode 100755 index 000000000..1b86d443d --- /dev/null +++ b/crm_kit/README.rst @@ -0,0 +1,46 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +CRM Kit +======= +Complete CRM Kit for odoo17. + +Configuration +============= +* No additional configurations needed + +Company +------- +* `Cybrosys Techno Solutions `__ + +License +------- +General Public License, Version 3 (AGPL v3). +(https://www.gnu.org/licenses/agpl-3.0-standalone.html) + +Credits +------- +* Developer: (V17) Bhagyadev KP +* odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Maintainer +========== +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. +For support and more information, please visit `Our Website `__ + +Further information +=================== +HTML Description: ``__ diff --git a/crm_kit/__init__.py b/crm_kit/__init__.py new file mode 100644 index 000000000..ca859654a --- /dev/null +++ b/crm_kit/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Bhagyadev KP (odoo@cybrosys.com) +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################ +from . import controllers +from . import models +from . import wizard + diff --git a/crm_kit/__manifest__.py b/crm_kit/__manifest__.py new file mode 100644 index 000000000..fb70416e8 --- /dev/null +++ b/crm_kit/__manifest__.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Bhagyadev KP (odoo@cybrosys.com) +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################ +{ + "name": "CRM Kit", + "version": '17.0.1.0.0', + "category": 'Sales', + 'summary': """Complete CRM Kit for odoo 17""", + 'description': """Complete CRM Kit for odoo 17, CRM, CRM dashboard, + crm commission, commission plan, crm features""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + "depends": ['sale_management', 'crm', 'crm_dashboard'], + "data": [ + 'security/ir.model.access.csv', + 'views/crm_commission_views.xml', + 'views/crm_team_views.xml', + 'views/res_users_views.xml', + 'wizard/commission_report_views.xml', + ], + 'assets': { + 'web.assets_backend': [ + 'crm_kit/static/src/js/action_manager.js', + ], + }, + 'images': [ + 'static/description/banner.png', + ], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/crm_kit/controllers/__init__.py b/crm_kit/controllers/__init__.py new file mode 100644 index 000000000..dad785a4e --- /dev/null +++ b/crm_kit/controllers/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Bhagyadev KP (odoo@cybrosys.com) +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################ +from . import crm_kit diff --git a/crm_kit/controllers/crm_kit.py b/crm_kit/controllers/crm_kit.py new file mode 100644 index 000000000..8ac181bc6 --- /dev/null +++ b/crm_kit/controllers/crm_kit.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Bhagyadev KP (odoo@cybrosys.com) +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################ +import json +from odoo import http +from odoo.http import content_disposition, request +from odoo.tools import html_escape + + +class XLSXReportController(http.Controller): + @http.route('/xlsx_reports', type='http', auth='user', methods=['POST'], csrf=False) + def get_report_xlsx(self, model, options, output_format, report_name, **kw): + """ + Generate an XLSX report based on the provided data and return it as a response. + """ + uid = request.session.uid + report_obj = request.env[model].with_user(uid) + options = json.loads(options) + token = 'dummy-because-api-expects-one' + try: + if output_format == 'xlsx': + response = request.make_response( + None, + headers=[ + ('Content-Type', 'application/vnd.ms-excel'), + ('Content-Disposition', content_disposition(report_name + '.xlsx')) + ] + ) + report_obj.get_xlsx_report(options, response) + response.set_cookie('fileToken', token) + return response + except Exception as e: + se = http.serialize_exception(e) + error = { + 'code': 200, + 'message': 'Odoo Server Error', + 'data': se + } + return request.make_response(html_escape(json.dumps(error))) diff --git a/crm_kit/doc/RELEASE_NOTES.md b/crm_kit/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..d82a1b7ed --- /dev/null +++ b/crm_kit/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 20.01.2024 +#### Version 17.0.1.0.0 +#### ADD +- Initial commit for CRM Kit diff --git a/crm_kit/models/__init__.py b/crm_kit/models/__init__.py new file mode 100644 index 000000000..149580597 --- /dev/null +++ b/crm_kit/models/__init__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Bhagyadev KP (odoo@cybrosys.com) +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################ +from . import commision_graduated +from . import commision_product +from . import crm_commision +from . import crm_team +from . import res_users + diff --git a/crm_kit/models/commision_graduated.py b/crm_kit/models/commision_graduated.py new file mode 100644 index 000000000..77c5a8530 --- /dev/null +++ b/crm_kit/models/commision_graduated.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Bhagyadev KP (odoo@cybrosys.com) +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################ +from odoo import exceptions +from odoo import api, fields, models, _ + + +class CommissionGraduated(models.Model): + """ + This class represents Commission Revenue Graduated Wise. + """ + _name = 'commission.graduated' + _description = 'Commission Revenue Graduated Wise' + + graduated_commission_rate = fields.Float(string='Commission rate (%)', + help="Graduated Commission rate") + amount_from = fields.Float(string="From Amount", help='Amount from') + amount_to = fields.Float(string="To Amount", help='Amount to') + commission_id = fields.Many2one("crm.commission", + string="Commission", + help="Commission for graduation") + sequence = fields.Integer(string='Sequence', compute='_compute_sequence', + store=True, help="sequence") + + @api.depends('commission_id') + def _compute_sequence(self): + """ + Add a sequence + """ + number = 1 + seq = self.mapped('commission_id') + for rule in seq.revenue_grd_comm_ids: + rule.sequence = number + number += 1 + + @api.constrains("amount_from", "amount_to") + def _check_amounts(self): + """ + Check the validity of 'amount_from' and 'amount_to' values. + + :raise exceptions.ValidationError: If 'amount_to' is less than + 'amount_from'. + :return: None + """ + for rec in self: + if rec.amount_to < rec.amount_from: + raise exceptions.ValidationError( + _("The From Amount limit cannot be greater than To Amount.") + ) diff --git a/crm_kit/models/commision_product.py b/crm_kit/models/commision_product.py new file mode 100644 index 000000000..c9caa42b7 --- /dev/null +++ b/crm_kit/models/commision_product.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Bhagyadev KP (odoo@cybrosys.com) +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################ +from odoo import fields, models + + +class CommissionProduct(models.Model): + """ + This class represents Commission Product Wise. + + This model is used to define commission rates and maximum commission amounts + for different products. + """ + _name = 'commission.product' + _description = 'Commission Product Wise' + + user_id = fields.Many2one('res.users') + category_id = fields.Many2one('product.category', string='Product Category', + help="Category of the product") + product_id = fields.Many2one('product.product', string='Product', + domain="[('categ_id', '=', category_id)]", + help="Product") + percentage = fields.Float(string='Rate in Percentage (%)', + help="Rate in percentage") + amount = fields.Monetary(string='Maximum Commission Amount', default=0.0, + help="Maximum Commission Amount") + currency_id = fields.Many2one("res.currency", string="Currency", + default=lambda self: + self.env.user.company_id.currency_id.id, + help="Currency") + commission_id = fields.Many2one("crm.commission", + string="Commission", help="Commission") diff --git a/crm_kit/models/crm_commision.py b/crm_kit/models/crm_commision.py new file mode 100644 index 000000000..e175063ee --- /dev/null +++ b/crm_kit/models/crm_commision.py @@ -0,0 +1,89 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Bhagyadev KP (odoo@cybrosys.com) +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################ +from odoo import exceptions +from odoo import api, fields, models, _ + + +class CrmCommission(models.Model): + """ + This class represents the Commission Plan. + """ + _name = 'crm.commission' + _description = 'CRM Commission' + _rec_name = "name" + _inherit = ['mail.thread', 'mail.activity.mixin'] + + name = fields.Char('Name', required=True, help="Name of the Commission") + active = fields.Boolean('Active', default=True, help="Active") + date_from = fields.Date(string="From Date", required=True, help="Date from") + date_to = fields.Date(string="To Date", required=True, help="Date to") + type = fields.Selection( + [('product', 'Product wise'), + ('revenue', 'Revenue wise')], string="Type", + default="product", help='Type of the commission plan') + team_id = fields.Many2one('crm.team', string='Sales Team', + help="CRM Team") + user_id = fields.Many2one('res.users', string='Salesperson', + help="Sales person") + product_comm_ids = fields.One2many('commission.product', 'commission_id', + string="Product Wise", + help='Commission Product') + straight_commission_rate = fields.Float(string='Commission rate (%)', + help='Straight Commission Rate') + revenue_grd_comm_ids = fields.One2many( + 'commission.graduated', + 'commission_id', + string="Revenue Graduated Wise", help='Revenue graduated wise') + + revenue_type = fields.Selection( + [('straight', 'Straight Commission'), + ('graduated', 'Graduated Commission')], + string="Revenue Type", help='Revenue Type') + + @api.constrains("date_from", "date_to") + def _check_date(self): + """ + Check the validity of date range. + + This method checks whether the 'date_from' is not later than 'date_to'. + + :raise exceptions.ValidationError: If 'date_from' is later than 'date_to'. + """ + for rec in self: + if rec.date_to < rec.date_from: + raise exceptions.ValidationError( + _("The From date cannot be earlier than To date.") + ) + + @api.onchange('type') + def _onchange_type(self): + """ + Handle the 'type' field change. + This method handles the 'type' field change and performs actions + accordingly. + """ + if self.type == 'revenue': + self.product_comm_ids = [(5, 0, 0)] + elif self.type == 'product': + self.revenue_type = False + self.straight_commission_rate = False + self.revenue_grd_comm_ids = [(5, 0, 0)] diff --git a/crm_kit/models/crm_team.py b/crm_kit/models/crm_team.py new file mode 100644 index 000000000..16b804cb3 --- /dev/null +++ b/crm_kit/models/crm_team.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Bhagyadev KP (odoo@cybrosys.com) +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################ +from odoo import fields, models + + +class CrmTeam(models.Model): + """ + This class inherits from 'crm.team' and add a field commission_id. + """ + _inherit = 'crm.team' + + commission_id = fields.Many2one('crm.commission', + string='Commission Plan', + help='Commission Plan') diff --git a/crm_kit/models/res_users.py b/crm_kit/models/res_users.py new file mode 100644 index 000000000..cdbcdf648 --- /dev/null +++ b/crm_kit/models/res_users.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Bhagyadev KP (odoo@cybrosys.com) +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################ +from odoo import fields, models + + +class ResUsers(models.Model): + """ + This class inherits from 'res.users' and add a field commission_id. + """ + _inherit = 'res.users' + + commission_id = fields.Many2one('crm.commission', + string='Commission Plan', + help='Commission plan') diff --git a/crm_kit/security/ir.model.access.csv b/crm_kit/security/ir.model.access.csv new file mode 100644 index 000000000..736d40ebc --- /dev/null +++ b/crm_kit/security/ir.model.access.csv @@ -0,0 +1,5 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_commission_plan_user,crm.commission.user,model_crm_commission,base.group_user,1,1,1,1 +access_commission_product_user,commission.product.user,model_commission_product,base.group_user,1,1,1,1 +access_commission_report_user,commission.report.user,model_commission_report,base.group_user,1,1,1,1 +access_commission_graduated_user,commission.graduated.user,model_commission_graduated,base.group_user,1,1,1,1 diff --git a/crm_kit/static/description/assets/icons/capture (1).png b/crm_kit/static/description/assets/icons/capture (1).png new file mode 100644 index 000000000..8824deafc Binary files /dev/null and b/crm_kit/static/description/assets/icons/capture (1).png differ diff --git a/crm_kit/static/description/assets/icons/check.png b/crm_kit/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/crm_kit/static/description/assets/icons/check.png differ diff --git a/crm_kit/static/description/assets/icons/chevron.png b/crm_kit/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/crm_kit/static/description/assets/icons/chevron.png differ diff --git a/crm_kit/static/description/assets/icons/cogs.png b/crm_kit/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/crm_kit/static/description/assets/icons/cogs.png differ diff --git a/crm_kit/static/description/assets/icons/consultation.png b/crm_kit/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/crm_kit/static/description/assets/icons/consultation.png differ diff --git a/crm_kit/static/description/assets/icons/ecom-black.png b/crm_kit/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/crm_kit/static/description/assets/icons/ecom-black.png differ diff --git a/crm_kit/static/description/assets/icons/education-black.png b/crm_kit/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/crm_kit/static/description/assets/icons/education-black.png differ diff --git a/crm_kit/static/description/assets/icons/hotel-black.png b/crm_kit/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/crm_kit/static/description/assets/icons/hotel-black.png differ diff --git a/crm_kit/static/description/assets/icons/img.png b/crm_kit/static/description/assets/icons/img.png new file mode 100644 index 000000000..70197f477 Binary files /dev/null and b/crm_kit/static/description/assets/icons/img.png differ diff --git a/crm_kit/static/description/assets/icons/license.png b/crm_kit/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/crm_kit/static/description/assets/icons/license.png differ diff --git a/crm_kit/static/description/assets/icons/lifebuoy.png b/crm_kit/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/crm_kit/static/description/assets/icons/lifebuoy.png differ diff --git a/crm_kit/static/description/assets/icons/manufacturing-black.png b/crm_kit/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/crm_kit/static/description/assets/icons/manufacturing-black.png differ diff --git a/crm_kit/static/description/assets/icons/photo-capture.png b/crm_kit/static/description/assets/icons/photo-capture.png new file mode 100644 index 000000000..06c111758 Binary files /dev/null and b/crm_kit/static/description/assets/icons/photo-capture.png differ diff --git a/crm_kit/static/description/assets/icons/pos-black.png b/crm_kit/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/crm_kit/static/description/assets/icons/pos-black.png differ diff --git a/crm_kit/static/description/assets/icons/puzzle.png b/crm_kit/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/crm_kit/static/description/assets/icons/puzzle.png differ diff --git a/crm_kit/static/description/assets/icons/restaurant-black.png b/crm_kit/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/crm_kit/static/description/assets/icons/restaurant-black.png differ diff --git a/crm_kit/static/description/assets/icons/service-black.png b/crm_kit/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/crm_kit/static/description/assets/icons/service-black.png differ diff --git a/crm_kit/static/description/assets/icons/trading-black.png b/crm_kit/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/crm_kit/static/description/assets/icons/trading-black.png differ diff --git a/crm_kit/static/description/assets/icons/training.png b/crm_kit/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/crm_kit/static/description/assets/icons/training.png differ diff --git a/crm_kit/static/description/assets/icons/update.png b/crm_kit/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/crm_kit/static/description/assets/icons/update.png differ diff --git a/crm_kit/static/description/assets/icons/user.png b/crm_kit/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/crm_kit/static/description/assets/icons/user.png differ diff --git a/crm_kit/static/description/assets/icons/wrench.png b/crm_kit/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/crm_kit/static/description/assets/icons/wrench.png differ diff --git a/crm_kit/static/description/assets/misc/Cybrosys R.png b/crm_kit/static/description/assets/misc/Cybrosys R.png new file mode 100644 index 000000000..da4058087 Binary files /dev/null and b/crm_kit/static/description/assets/misc/Cybrosys R.png differ diff --git a/crm_kit/static/description/assets/misc/categories.png b/crm_kit/static/description/assets/misc/categories.png new file mode 100644 index 000000000..bedf1e0b1 Binary files /dev/null and b/crm_kit/static/description/assets/misc/categories.png differ diff --git a/crm_kit/static/description/assets/misc/check-box.png b/crm_kit/static/description/assets/misc/check-box.png new file mode 100644 index 000000000..42caf24b9 Binary files /dev/null and b/crm_kit/static/description/assets/misc/check-box.png differ diff --git a/crm_kit/static/description/assets/misc/compass.png b/crm_kit/static/description/assets/misc/compass.png new file mode 100644 index 000000000..d5fed8faa Binary files /dev/null and b/crm_kit/static/description/assets/misc/compass.png differ diff --git a/crm_kit/static/description/assets/misc/corporate.png b/crm_kit/static/description/assets/misc/corporate.png new file mode 100644 index 000000000..2eb13edbf Binary files /dev/null and b/crm_kit/static/description/assets/misc/corporate.png differ diff --git a/crm_kit/static/description/assets/misc/customer-support.png b/crm_kit/static/description/assets/misc/customer-support.png new file mode 100644 index 000000000..79efc72ed Binary files /dev/null and b/crm_kit/static/description/assets/misc/customer-support.png differ diff --git a/crm_kit/static/description/assets/misc/cybrosys-logo.png b/crm_kit/static/description/assets/misc/cybrosys-logo.png new file mode 100644 index 000000000..cc3cc0ccf Binary files /dev/null and b/crm_kit/static/description/assets/misc/cybrosys-logo.png differ diff --git a/crm_kit/static/description/assets/misc/email.svg b/crm_kit/static/description/assets/misc/email.svg new file mode 100644 index 000000000..15291cdc3 --- /dev/null +++ b/crm_kit/static/description/assets/misc/email.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crm_kit/static/description/assets/misc/features.png b/crm_kit/static/description/assets/misc/features.png new file mode 100644 index 000000000..b41769f77 Binary files /dev/null and b/crm_kit/static/description/assets/misc/features.png differ diff --git a/crm_kit/static/description/assets/misc/logo.png b/crm_kit/static/description/assets/misc/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/crm_kit/static/description/assets/misc/logo.png differ diff --git a/crm_kit/static/description/assets/misc/phone.svg b/crm_kit/static/description/assets/misc/phone.svg new file mode 100644 index 000000000..b7bd7f251 --- /dev/null +++ b/crm_kit/static/description/assets/misc/phone.svg @@ -0,0 +1,3 @@ + + + diff --git a/crm_kit/static/description/assets/misc/pictures.png b/crm_kit/static/description/assets/misc/pictures.png new file mode 100644 index 000000000..56d255fe9 Binary files /dev/null and b/crm_kit/static/description/assets/misc/pictures.png differ diff --git a/crm_kit/static/description/assets/misc/pie-chart.png b/crm_kit/static/description/assets/misc/pie-chart.png new file mode 100644 index 000000000..426e05244 Binary files /dev/null and b/crm_kit/static/description/assets/misc/pie-chart.png differ diff --git a/crm_kit/static/description/assets/misc/right-arrow.png b/crm_kit/static/description/assets/misc/right-arrow.png new file mode 100644 index 000000000..730984a06 Binary files /dev/null and b/crm_kit/static/description/assets/misc/right-arrow.png differ diff --git a/crm_kit/static/description/assets/misc/star (1) 2.svg b/crm_kit/static/description/assets/misc/star (1) 2.svg new file mode 100644 index 000000000..5ae9f507a --- /dev/null +++ b/crm_kit/static/description/assets/misc/star (1) 2.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/crm_kit/static/description/assets/misc/star.png b/crm_kit/static/description/assets/misc/star.png new file mode 100644 index 000000000..2eb9ab29f Binary files /dev/null and b/crm_kit/static/description/assets/misc/star.png differ diff --git a/crm_kit/static/description/assets/misc/support (1) 1.svg b/crm_kit/static/description/assets/misc/support (1) 1.svg new file mode 100644 index 000000000..7d37a8f30 --- /dev/null +++ b/crm_kit/static/description/assets/misc/support (1) 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/crm_kit/static/description/assets/misc/support-email.svg b/crm_kit/static/description/assets/misc/support-email.svg new file mode 100644 index 000000000..eb70370d6 --- /dev/null +++ b/crm_kit/static/description/assets/misc/support-email.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/crm_kit/static/description/assets/misc/support.png b/crm_kit/static/description/assets/misc/support.png new file mode 100644 index 000000000..4f18b8b82 Binary files /dev/null and b/crm_kit/static/description/assets/misc/support.png differ diff --git a/crm_kit/static/description/assets/misc/tick-mark.svg b/crm_kit/static/description/assets/misc/tick-mark.svg new file mode 100644 index 000000000..2dbb40187 --- /dev/null +++ b/crm_kit/static/description/assets/misc/tick-mark.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/crm_kit/static/description/assets/misc/whatsapp 1.svg b/crm_kit/static/description/assets/misc/whatsapp 1.svg new file mode 100644 index 000000000..0bfaf8fc6 --- /dev/null +++ b/crm_kit/static/description/assets/misc/whatsapp 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/crm_kit/static/description/assets/misc/whatsapp.png b/crm_kit/static/description/assets/misc/whatsapp.png new file mode 100644 index 000000000..d513a5356 Binary files /dev/null and b/crm_kit/static/description/assets/misc/whatsapp.png differ diff --git a/crm_kit/static/description/assets/misc/whatsapp.svg b/crm_kit/static/description/assets/misc/whatsapp.svg new file mode 100644 index 000000000..b618aea1d --- /dev/null +++ b/crm_kit/static/description/assets/misc/whatsapp.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crm_kit/static/description/assets/modules/1.jpg b/crm_kit/static/description/assets/modules/1.jpg new file mode 100644 index 000000000..08bbafeb6 Binary files /dev/null and b/crm_kit/static/description/assets/modules/1.jpg differ diff --git a/crm_kit/static/description/assets/modules/2.png b/crm_kit/static/description/assets/modules/2.png new file mode 100644 index 000000000..a1209a01f Binary files /dev/null and b/crm_kit/static/description/assets/modules/2.png differ diff --git a/crm_kit/static/description/assets/modules/3.jpg b/crm_kit/static/description/assets/modules/3.jpg new file mode 100644 index 000000000..3d171226b Binary files /dev/null and b/crm_kit/static/description/assets/modules/3.jpg differ diff --git a/crm_kit/static/description/assets/modules/4.jpg b/crm_kit/static/description/assets/modules/4.jpg new file mode 100644 index 000000000..1f3f2e27f Binary files /dev/null and b/crm_kit/static/description/assets/modules/4.jpg differ diff --git a/crm_kit/static/description/assets/modules/5.jpg b/crm_kit/static/description/assets/modules/5.jpg new file mode 100644 index 000000000..0db717519 Binary files /dev/null and b/crm_kit/static/description/assets/modules/5.jpg differ diff --git a/crm_kit/static/description/assets/modules/6.jpg b/crm_kit/static/description/assets/modules/6.jpg new file mode 100644 index 000000000..cd62a577c Binary files /dev/null and b/crm_kit/static/description/assets/modules/6.jpg differ diff --git a/crm_kit/static/description/assets/screenshots/1.png b/crm_kit/static/description/assets/screenshots/1.png new file mode 100644 index 000000000..c57950811 Binary files /dev/null and b/crm_kit/static/description/assets/screenshots/1.png differ diff --git a/crm_kit/static/description/assets/screenshots/10.png b/crm_kit/static/description/assets/screenshots/10.png new file mode 100644 index 000000000..90a804ced Binary files /dev/null and b/crm_kit/static/description/assets/screenshots/10.png differ diff --git a/crm_kit/static/description/assets/screenshots/11.png b/crm_kit/static/description/assets/screenshots/11.png new file mode 100644 index 000000000..6b6a59d55 Binary files /dev/null and b/crm_kit/static/description/assets/screenshots/11.png differ diff --git a/crm_kit/static/description/assets/screenshots/2.png b/crm_kit/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..0b1027e8d Binary files /dev/null and b/crm_kit/static/description/assets/screenshots/2.png differ diff --git a/crm_kit/static/description/assets/screenshots/3.png b/crm_kit/static/description/assets/screenshots/3.png new file mode 100644 index 000000000..6b79fca20 Binary files /dev/null and b/crm_kit/static/description/assets/screenshots/3.png differ diff --git a/crm_kit/static/description/assets/screenshots/4.png b/crm_kit/static/description/assets/screenshots/4.png new file mode 100644 index 000000000..6d54d92c8 Binary files /dev/null and b/crm_kit/static/description/assets/screenshots/4.png differ diff --git a/crm_kit/static/description/assets/screenshots/5.png b/crm_kit/static/description/assets/screenshots/5.png new file mode 100644 index 000000000..748872ed7 Binary files /dev/null and b/crm_kit/static/description/assets/screenshots/5.png differ diff --git a/crm_kit/static/description/assets/screenshots/6.png b/crm_kit/static/description/assets/screenshots/6.png new file mode 100644 index 000000000..7dc745360 Binary files /dev/null and b/crm_kit/static/description/assets/screenshots/6.png differ diff --git a/crm_kit/static/description/assets/screenshots/7.png b/crm_kit/static/description/assets/screenshots/7.png new file mode 100644 index 000000000..236cd8838 Binary files /dev/null and b/crm_kit/static/description/assets/screenshots/7.png differ diff --git a/crm_kit/static/description/assets/screenshots/8.png b/crm_kit/static/description/assets/screenshots/8.png new file mode 100644 index 000000000..dcf9cdaab Binary files /dev/null and b/crm_kit/static/description/assets/screenshots/8.png differ diff --git a/crm_kit/static/description/assets/screenshots/9.png b/crm_kit/static/description/assets/screenshots/9.png new file mode 100644 index 000000000..730bba9ea Binary files /dev/null and b/crm_kit/static/description/assets/screenshots/9.png differ diff --git a/crm_kit/static/description/assets/screenshots/hero.gif b/crm_kit/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..8d50bd5ba Binary files /dev/null and b/crm_kit/static/description/assets/screenshots/hero.gif differ diff --git a/crm_kit/static/description/banner.png b/crm_kit/static/description/banner.png new file mode 100644 index 000000000..514861fdb Binary files /dev/null and b/crm_kit/static/description/banner.png differ diff --git a/crm_kit/static/description/icon.png b/crm_kit/static/description/icon.png new file mode 100644 index 000000000..24f87e344 Binary files /dev/null and b/crm_kit/static/description/icon.png differ diff --git a/crm_kit/static/description/index.html b/crm_kit/static/description/index.html new file mode 100644 index 000000000..7185919df --- /dev/null +++ b/crm_kit/static/description/index.html @@ -0,0 +1,1033 @@ + + + + + + + Odoo App 3 Index + + + + + + + + +
+
+
+
+
+ +
+
+
+ Community +
+
+ Enterprise +
+
+ Odoo.sh +
+
+
+
+
+
+

+ CRM Kit

+

+ Complete CRM Kit for odoo17. +

+
+ +
+
+
+
+
+

+ Key Highlights +

+
+
+
+
+
+ +
+
+

+ Craft Custom Commission to Salesperson and Sales + Team

+
+
+
+
+
+
+ +
+
+

+ Draft Commissions Based on Revenue and + Respective Product

+
+
+
+
+
+
+ +
+
+

+ Define Commission Based on Product Category

+
+
+
+
+
+
+ +
+
+

+ Informative Commission Plan Report

+
+
+
+
+
+
+ +
+
+

+ Upcoming and Recent Scheduled Activity + Monitoring

+
+
+
+
+
+
+ +
+
+

+ Year to Date Bar Graph

+
+
+
+
+
+
+ +
+
+

+ Opportunity Lost Reason Management

+
+
+
+
+
+
+ +
+
+

+ Top Deals and Monthly Revenue Goals

+
+
+
+
+
+
+ +
+
+

+ Clickable Dashboard Cards

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

+ Clickable Dashboard Card

+
+
+
+
+
+
+ +
+
+

+ Commission Plan based on Product + Category

+

The + Commission Plan Creation window can be + accessed from the Commission Plan window and + while selecting the Type the Product Wise + options can be selected. Further, the + Product Categories with respect to the + respective Product Category based Commission + Plan can be defined.

+
+
+
+
+
+
+ +
+
+

+ Revenue-based Commission Plan: Straight + Revenue Commission Plan.

+

The second + form of Commission Plan in the Odoo CRM Kit + where the Sales Revenue and its percentage + calculation will be provided as Commission + to the Salesperson. + While Creating a Straight Revenue Commission + plan the Commission type can be selected as + Straight Commission. Further, the commission + rate can be defined under the Straight + Revenue Commission tab.

+
+
+
+
+
+
+ +
+
+

+ Revenue-based Commission Plan: Graduated + Revenue Commission Plan.

+

While + Creating a Graduated Revenue Commission Plan + the Commission type can be selected as + Graduated Commission. Further, the + commission rate can be defined under the + Graduated Revenue Commission tab.

+
+
+
+
+
+
+ +
+
+

+ Assigning Commission Plan for + Salesperson.

+

In the CRM + Kit under the respective Salesperson + description tab, there will be a dedicated + tab the Commission Plan where the respective + Commission Plan with respect to the + operation can be defined. +

+
+
+
+
+
+
+ +
+
+

+ Assigning Commission Plan for Sales + Team.

+

In the CRM + Kit under the respective sales team + description tab, there will be a dedicated + tab the Commission Plan where the respective + Commission Plan with respect to the + operation can be defined. +

+
+
+
+
+
+
+ +
+
+

+ Print the Commission Plan Report in XLSX + Format.

+

The CRM Kit + also holds an advanced operations feature + where the Admins, as well as every User, can + take the Print out of the Commission Plan + Reports based on their need and for the + period of operations that are required. The + Reports can be generated in XLSX formats and + can be saved based on the need. To take the + printout of the Commission Plan Report you + should go to the Reporting tab of the CRM + KIt and further select the Commission Plan + menu and select the Required entries and + Click to Print XLS. +

+
+
+
+
+
+
+ +
+
+

+ Year to Date Chart and Lead Analysis

+

A dedicated + insight will be provided with the help of + the Funnel Chart on the Leads with + indications as New, Qualified, Proposition, + and Won. The Donut graph based on the + monthly Lead operation will provide a clear + picture of the monthly Lead operations. + Additionally, the Activity Donut graph will + describe the activity analysis on the leads. +

+
+
+
+
+
+
+ +
+
+

+ Set custom targets for Salesperson

+

For each of + the individual Salespersons, you will be + able to set dedicated Targets using the CRM + Kit. This will ensure that the Salesperson + is motivated to keep with the business. The + Targets can be set under the Settings tab > + User Settings > Below the access right tab. +

+
+
+
+
+
+
+ +
+
+

+ Top deals and Monthly Goal Gauge.

+

The Top + Deals listing will help the Salespersons to + promote them easily without moving to the + sales module. Moreover, the Top Deals can be + listed out based on the custom ones which + are being defined. The Monthly Goal Gauge + will provide insight on the targets and the + achievement rate of each of the Salesperson. +

+
+
+
+
+
+
+ +
+
+

+ Dashboard View of the User

+

The Admin, + as well as the User who has access to the + CRM Kit, can function the various operations + with it and each of the Users and the Admin + have a separate CRM Dashboard based on the + operational authorization. The Following + screenshot depicts the User view of the CRM + Dashboard. Here the information relating to + the respective user and their operations + will be only depicted and the ones which the + respective User has authorization to can be + modified. +

+
+
+
+
+
+
+
    +
  • + Activity + monitoring. +
  • +
  • + Year to + date + bar graph target field in user settings. +
  • +
  • + Top deals + and + monthly revenue goals. +
  • +
  • + The users + will + have different authorization based on + the employment level. +
  • + +
+
+
+
+
+
+
Version + 17.0.1.0.0|Released on:20th January 2024 +
+

+ Initial Commit for CRM Kit.

+
+
+
+
+
+
+
+

+ Related Products

+
+
+ +
+
+

+ Our Services

+ +
+
+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Customization

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Implementation

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Support

+
+
+
+
+
+
+ service-icon +
+
+

Hire + Odoo Developer

+
+
+
+
+ +
+
+ service-icon +
+
+

Odoo + Integration

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Migration

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Consultancy

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Implementation

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Licensing Consultancy

+
+
+
+
+
+
+

+ Our Industries

+ +
+
+
+
+
+
+ +

Trading

+

Easily procure and sell your products

+
+
+
+
+ +

POS

+

Easy configuration and convivial experience

+
+
+
+
+ +

+ Education

+

A platform for educational management

+
+
+
+
+ +

+ Manufacturing

+

Plan, track and schedule your operations

+
+
+
+
+ +

E-commerce & + Website

+

Mobile friendly, awe-inspiring product pages

+
+
+
+
+ +

Service + Management

+

Keep track of services and invoice

+
+
+
+
+ +

+ Restaurant

+

Run your bar or restaurant methodically

+
+
+
+
+ +

Hotel + Management

+

An all-inclusive hotel management application

+
+
+
+
+
+
+

+ Support

+
+
+
+
+
+
+
+ +
+ Need + Help? +

Got + questions or need help? Get in touch.

+
odoo@cybrosys.com +
+
+
+
+
+
+
+
+ +
+ WhatsApp +

Say hi to + us on WhatsApp!

+
+91 + 99456767686 +
+
+
+
+
+
+
+
+
+ + + + + + diff --git a/crm_kit/static/src/js/action_manager.js b/crm_kit/static/src/js/action_manager.js new file mode 100644 index 000000000..c03484d71 --- /dev/null +++ b/crm_kit/static/src/js/action_manager.js @@ -0,0 +1,19 @@ +/** @odoo-module **/ +import { registry } from "@web/core/registry"; +import { BlockUI } from "@web/core/ui/block_ui"; +import { download } from "@web/core/network/download"; + +/** +This handler is responsible for generating XLSX reports. +*/ +registry.category("ir.actions.report handlers").add("xlsx", async function (action) { + if (action.report_type === 'xlsx') { + BlockUI; + await download({ + url: '/xlsx_reports', + data: action.data, + complete: () => unblockUI, + error: (error) => self.call('crash_manager', 'rpc_error', error), + }); + } +}); diff --git a/crm_kit/views/crm_commission_views.xml b/crm_kit/views/crm_commission_views.xml new file mode 100644 index 000000000..2500396fa --- /dev/null +++ b/crm_kit/views/crm_commission_views.xml @@ -0,0 +1,101 @@ + + + + + crm.commission.view.tree + crm.commission + + + + + + + + + + crm.commission.view.form + crm.commission + +
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+
+
+
+ + + CRM Commission Plan + ir.actions.act_window + crm.commission + tree,form + +

+ Create New Commission Plan! +

+
+
+ + +
diff --git a/crm_kit/views/crm_team_views.xml b/crm_kit/views/crm_team_views.xml new file mode 100644 index 000000000..3627e84ea --- /dev/null +++ b/crm_kit/views/crm_team_views.xml @@ -0,0 +1,14 @@ + + + + + crm.team.view.form.inherit.crm.kit + crm.team + + + + + + + + diff --git a/crm_kit/views/res_users_views.xml b/crm_kit/views/res_users_views.xml new file mode 100644 index 000000000..17e2eabc3 --- /dev/null +++ b/crm_kit/views/res_users_views.xml @@ -0,0 +1,28 @@ + + + + + res.users.view.inherit.form.crm.kit + res.users + + + + + + + + + + Sales Persons + ir.actions.act_window + res.users + [('share','=',False)] + tree,kanban,form + + + + diff --git a/crm_kit/wizard/__init__.py b/crm_kit/wizard/__init__.py new file mode 100644 index 000000000..06c746b0f --- /dev/null +++ b/crm_kit/wizard/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Bhagyadev KP (odoo@cybrosys.com) +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################ +from . import commission_report diff --git a/crm_kit/wizard/commission_report.py b/crm_kit/wizard/commission_report.py new file mode 100644 index 000000000..92dd0ac5a --- /dev/null +++ b/crm_kit/wizard/commission_report.py @@ -0,0 +1,375 @@ + # -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Bhagyadev KP (odoo@cybrosys.com) +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################ +import io +import json +from odoo import api, fields, models +from odoo.tools import date_utils +from odoo.exceptions import ValidationError + +try: + from odoo.tools.misc import xlsxwriter +except ImportError: + import xlsxwriter + + +class CommissionReport(models.TransientModel): + """ + Commission Report wizard + """ + _name = 'commission.report' + _description = 'Commission Report Wizard' + + date_from = fields.Date(string="From Date", help="Date from which") + date_to = fields.Date(string="To Date", help="Date to") + salesperson_ids = fields.Many2many('res.users', string='Salesperson', + domain="[('share','=',False)]", + help="Salesperson") + sales_team_ids = fields.Many2many('crm.team', string='Sales Team', + help="Sales team") + date = fields.Date(string='Date', default=fields.Date.context_today, + help="Date") + is_sales_person = fields.Boolean(default=False, string="Is sales person", + help="Is sales person") + is_sales_team = fields.Boolean(default=False, string="Is sales team", + help="Is sales team") + + @api.onchange('salesperson_ids') + def onchange_salesperson_ids(self): + """Function for hide a field base on values""" + self.is_sales_person = True if self.salesperson_ids else False + + @api.onchange('sales_team_ids') + def onchange_sales_team_ids(self): + self.is_sales_team = True if self.sales_team_ids else False + + @api.constrains('sales_team_ids', 'salesperson_ids') + def sales_team_constrains(self): + """Function for showing validation error""" + for rec in self: + if self.sales_team_ids: + if not rec.sales_team_ids.member_ids: + raise ValidationError( + "Selected Sales Team haven't any Salespersons") + if not self.sales_team_ids.member_ids.commission_id and \ + not self.sales_team_ids.commission_id: + raise ValidationError( + "Selected Sales Team haven't any Commission Plan") + elif self.salesperson_ids and not rec.salesperson_ids.commission_id: + raise ValidationError( + "Selected Salesperson haven't any Commission Plan") + + def action_print_xls_report(self): + """Function for printing xlsx report""" + # sales person's condition starts here # + user_sale_orders = self.env['sale.order'].search([ + ('user_id', 'in', self.salesperson_ids.ids)]) + user_sale_orders_dict = {} + total_list = [] + commission_list = [] + user_commission_name = [] + user_commission_salesperson = [] + user_obj = user_sale_orders.mapped('user_id').sorted(key=lambda d: d.id) + for user in user_obj: + user_sale_orders_dict.update({ + user: user_sale_orders.filtered(lambda l: l.user_id == user) + }) + for user, user_sale_orders in user_sale_orders_dict.items(): + commission_id = user.commission_id + if not commission_id: + continue + filtered_order_lines = user_sale_orders.filtered( + lambda l: self.date_from <= l.date_order.date( + ) <= self.date_to and l.date_order.date() >= commission_id.date_from + ).mapped('order_line') + filtered_order_lines_commission_total = sum( + filtered_order_lines.mapped('price_subtotal')) + + if commission_id.type == 'product': + commission_products = commission_id.product_comm_ids.product_id + prod_commission = filtered_order_lines.filtered( + lambda l: l.product_id in commission_products) + for rule in commission_id.product_comm_ids.filtered( + lambda l: l.product_id in prod_commission.mapped( + 'product_id')): + product_order_line = prod_commission.filtered( + lambda l: l.product_id == rule.product_id) + total_price = sum( + product_order_line.mapped('price_subtotal')) + product_commission = (total_price * rule.percentage) / 100 + total_list.append(total_price) + user_commission_name.append(commission_id.name) + user_commission_salesperson.append(user.name) + commission_list.append(rule.amount) if ( + product_commission > rule.amount) \ + else commission_list.append(product_commission) + + if commission_id.type == 'revenue' and ( + commission_id.revenue_type == 'graduated'): + for rule in commission_id.revenue_grd_comm_ids: + if rule.amount_from <= filtered_order_lines_commission_total < rule.amount_to: + graduated_commission = (filtered_order_lines_commission_total + * rule.graduated_commission_rate) / 100 + commission_list.append(graduated_commission) + user_commission_name.append(commission_id.name) + user_commission_salesperson.append(user.name) + total_list.append(filtered_order_lines_commission_total) + + if commission_id.type == 'revenue' and ( + commission_id.revenue_type == 'straight'): + straight_commission = (filtered_order_lines_commission_total + * commission_id.straight_commission_rate) / 100 + commission_list.append(straight_commission) + user_commission_name.append(commission_id.name) + user_commission_salesperson.append(user.name) + total_list.append(filtered_order_lines_commission_total) + # sales person's condition ends here # + + if not self.sales_team_ids and not self.salesperson_ids: + self.sales_team_ids = self.env['crm.team'].search([]) + + # sales team's condition starts here # + team_wizard_persons = self.sales_team_ids.member_ids + team_sale_orders = self.env['sale.order'].search( + [('user_id', 'in', team_wizard_persons.ids)]) + team_sale_orders_dict = {} + commission_total = [] + commission = [] + commission_name = [] + commission_salesperson = [] + commission_sales_team = [] + team_obj = team_sale_orders.mapped('user_id').sorted(key=lambda d: d.id) + for team_user in team_obj: + team_sale_orders_dict.update({ + team_user: team_sale_orders.filtered( + lambda l: l.user_id == team_user) + }) + for team_user, team_sale_orders in team_sale_orders_dict.items(): + commissions_id = team_user.commission_id if team_user.commission_id \ + else team_user.sale_team_id.commission_id + if commissions_id: + filtered_order_lines = team_sale_orders.filtered( + lambda l: self.date_from <= l.date_order.date( + ) <= self.date_to and l.date_order.date() >= commissions_id.date_from + ).mapped('order_line') + filtered_order_lines_commission_total = sum( + filtered_order_lines.mapped('price_subtotal')) + if commissions_id.type == 'product': + commission_products = commissions_id.product_comm_ids.product_id + prod_commission = filtered_order_lines.filtered( + lambda l: l.product_id in commission_products) + for rules in commissions_id.product_comm_ids.filtered( + lambda l: l.product_id in prod_commission.mapped( + 'product_id')): + product_order_line = prod_commission.filtered( + lambda l: l.product_id == rules.product_id) + total_price = sum( + product_order_line.mapped('price_subtotal')) + product_commission = (total_price * rules.percentage) / 100 + commission_total.append(total_price) + commission_name.append(commissions_id.name) + commission_salesperson.append(team_user.name) + commission_sales_team.append( + team_user.sale_team_id.name) + commission.append(rules.amount) if ( + product_commission > rules.amount) \ + else commission.append(product_commission) + + if commissions_id.type == 'revenue' and ( + commissions_id.revenue_type == 'graduated'): + for rules in commissions_id.revenue_grd_comm_ids: + if rules.amount_from <= filtered_order_lines_commission_total \ + < rules.amount_to: + graduated_commission = (filtered_order_lines_commission_total + * rules.graduated_commission_rate) / 100 + commission.append(graduated_commission) + commission_name.append(commissions_id.name) + commission_salesperson.append(team_user.name) + commission_sales_team.append( + team_user.sale_team_id.name) + commission_total.append( + filtered_order_lines_commission_total) + + if commissions_id.type == 'revenue' and ( + commissions_id.revenue_type == 'straight'): + straight_commission = (filtered_order_lines_commission_total + * commissions_id.straight_commission_rate) / 100 + commission.append(straight_commission) + commission_name.append(commissions_id.name) + commission_salesperson.append(team_user.name) + commission_sales_team.append(team_user.sale_team_id.name) + commission_total.append( + filtered_order_lines_commission_total) + # sales team's condition ends here # + + data = { + 'model_id': self.id, + 'date': self.date, + 'date_from': self.date_from, + 'date_to': self.date_to, + 'sales_team_ids': self.sales_team_ids.ids, + 'salesperson_ids': self.salesperson_ids.ids, + 'commission_list': commission_list, + 'total_list': total_list, + 'commission': commission, + 'commission_total': commission_total, + 'commission_name': commission_name, + 'commission_salesperson': commission_salesperson, + 'commission_sales_team': commission_sales_team, + 'user_commission_name': user_commission_name, + 'user_commission_salesperson': user_commission_salesperson, + } + return { + 'type': 'ir.actions.report', + 'data': { + 'model': 'commission.report', + 'options': json.dumps(data, default=date_utils.json_default), + 'output_format': 'xlsx', + 'report_name': 'Commission Plan xlsx report'}, + 'report_type': 'xlsx' + } + + def get_xlsx_report(self, data, response): + """get_xlsx_report function""" + date = data['date'] + team = data['sales_team_ids'] + user = data['salesperson_ids'] + commission_list = data['commission_list'] + total_list = data['total_list'] + commission = data['commission'] + commission_total = data['commission_total'] + commission_name = data['commission_name'] + commission_salesperson = data['commission_salesperson'] + commission_sales_team = data['commission_sales_team'] + user_commission_name = data['user_commission_name'] + user_commission_salesperson = data['user_commission_salesperson'] + + output = io.BytesIO() + workbook = xlsxwriter.Workbook(output, {'in_memory': True}) + sheet = workbook.add_worksheet() + head = workbook.add_format({'align': 'center', 'bold': True, + 'font_size': '15px', 'valign': 'vcenter'}) + format1 = workbook.add_format({'align': 'left', 'font_size': '12px'}) + format2 = workbook.add_format({'align': 'right', 'font_size': '12x'}) + format3 = workbook.add_format( + {'align': 'right', 'font_size': '12x', 'bold': True}) + heading = workbook.add_format({'align': 'left', 'bold': True, + 'font_size': '12px', + 'valign': 'vcenter'}) + date_format = workbook.add_format( + {'num_format': 'dd/mm/yy', 'align': 'left', 'font_size': '10px'}) + + sheet.merge_range('A2:B2', "Printed Date: " + date, date_format) + sheet.write('A4', 'No.', heading) + sheet.set_column(5, 1, 25) + sheet.set_row(0, 25) + row = 5 + col = 0 + index = 1 + if user: + sheet.merge_range('A1:E1', 'COMMISSION PLAN REPORT', head) + sheet.write('D2', 'Date From: ' + data['date_from'], date_format) + sheet.write('E2', 'Date To: ' + data['date_to'], date_format) + + sheet.write('B4', 'Sale Persons', heading) + sheet.write('C4', 'Commission Plan Name', heading) + sheet.write('D4', 'Total Revenue', heading) + sheet.write('E4', 'Commission Amount', heading) + + for data in user_commission_salesperson: + sheet.write(row, col + 0, index, format2) + sheet.write(row, col + 1, data, format1) + row += 1 + index += 1 + + row = 5 + col = 0 + for data in user_commission_name: + sheet.write(row, col + 2, data, format1) + row += 1 + + row = 5 + col = 0 + for data in total_list: + sheet.write(row, col + 3, round(data, 2), format2) + row += 1 + + row = 5 + col = 0 + for data in commission_list: + sheet.write(row, col + 4, round(data, 2), format2) + row += 1 + + sheet.write(row + 1, col + 2, 'Total', format3) + sheet.write(row + 1, col + 3, round(sum(total_list), 2), format2) + sheet.write(row + 1, col + 4, round(sum(commission_list), 2), + format2) + + elif team: + sheet.merge_range('A1:F1', 'COMMISSION PLAN REPORT', head) + sheet.write('E2', 'Date From: ' + data['date_from'], date_format) + sheet.write('F2', 'Date To: ' + data['date_to'], date_format) + + sheet.write('B4', 'Sales Teams', heading) + sheet.write('C4', 'Sales Person', heading) + sheet.write('D4', 'Commission Plan Name', heading) + sheet.write('E4', 'Total Revenue', heading) + sheet.write('F4', 'Commission Amount', heading) + + for data in commission_sales_team: + sheet.write(row, col + 0, index, format2) + sheet.write(row, col + 1, data, format1) + row += 1 + index += 1 + + row = 5 + col = 0 + for data in commission_salesperson: + sheet.write(row, col + 2, data, format1) + row += 1 + + row = 5 + col = 0 + for data in commission_name: + sheet.write(row, col + 3, data, format1) + row += 1 + + row = 5 + col = 0 + for data in commission_total: + sheet.write(row, col + 4, round(data, 2), format2) + row += 1 + + row = 5 + col = 0 + for data in commission: + sheet.write(row, col + 5, round(data, 2), format2) + row += 1 + + sheet.write(row + 1, col + 3, 'Total:', format3) + sheet.write(row + 1, col + 4, round(sum(commission_total), 2), + format2) + sheet.write(row + 1, col + 5, round(sum(commission), 2), format2) + + workbook.close() + output.seek(0) + response.stream.write(output.read()) + output.close() diff --git a/crm_kit/wizard/commission_report_views.xml b/crm_kit/wizard/commission_report_views.xml new file mode 100644 index 000000000..be8693b05 --- /dev/null +++ b/crm_kit/wizard/commission_report_views.xml @@ -0,0 +1,47 @@ + + + + + commission.report.view.form + commission.report + form + +
+ + + + + + + + + + + + + + +
+
+
+
+
+ + + Commission Report + commission.report + form + + new + + + +