@ -1,46 +0,0 @@ |
|||||
.. 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 <https://cybrosys.com/>`__ |
|
||||
|
|
||||
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 <https://cybrosys.com/>`__ |
|
||||
|
|
||||
Further information |
|
||||
=================== |
|
||||
HTML Description: `<static/description/index.html>`__ |
|
@ -1,25 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
################################################################################ |
|
||||
# |
|
||||
# Cybrosys Technologies Pvt. Ltd. |
|
||||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|
||||
# 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 <https://www.gnu.org/licenses/>. |
|
||||
# |
|
||||
################################################################################ |
|
||||
from . import controllers |
|
||||
from . import models |
|
||||
from . import wizard |
|
||||
|
|
@ -1,53 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
################################################################################ |
|
||||
# |
|
||||
# Cybrosys Technologies Pvt. Ltd. |
|
||||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|
||||
# 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 <https://www.gnu.org/licenses/>. |
|
||||
# |
|
||||
################################################################################ |
|
||||
{ |
|
||||
"name": "CRM Kit", |
|
||||
"version": '17.0.1.0.1', |
|
||||
"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, |
|
||||
} |
|
@ -1,22 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
################################################################################ |
|
||||
# |
|
||||
# Cybrosys Technologies Pvt. Ltd. |
|
||||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|
||||
# 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 <https://www.gnu.org/licenses/>. |
|
||||
# |
|
||||
################################################################################ |
|
||||
from . import crm_kit |
|
@ -1,57 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
################################################################################ |
|
||||
# |
|
||||
# Cybrosys Technologies Pvt. Ltd. |
|
||||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|
||||
# 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 <https://www.gnu.org/licenses/>. |
|
||||
# |
|
||||
################################################################################ |
|
||||
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))) |
|
@ -1,11 +0,0 @@ |
|||||
## Module <crm_kit> |
|
||||
|
|
||||
#### 20.01.2024 |
|
||||
#### Version 17.0.1.0.0 |
|
||||
#### ADD |
|
||||
- Initial commit for CRM Kit |
|
||||
|
|
||||
#### 02.07.2024 |
|
||||
#### Version 17.0.1.0.1 |
|
||||
#### FIX |
|
||||
- Fixed the registry addition bug on report action manager |
|
@ -1,27 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
################################################################################ |
|
||||
# |
|
||||
# Cybrosys Technologies Pvt. Ltd. |
|
||||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|
||||
# 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 <https://www.gnu.org/licenses/>. |
|
||||
# |
|
||||
################################################################################ |
|
||||
from . import commision_graduated |
|
||||
from . import commision_product |
|
||||
from . import crm_commision |
|
||||
from . import crm_team |
|
||||
from . import res_users |
|
||||
|
|
@ -1,67 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
################################################################################ |
|
||||
# |
|
||||
# Cybrosys Technologies Pvt. Ltd. |
|
||||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|
||||
# 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 <https://www.gnu.org/licenses/>. |
|
||||
# |
|
||||
################################################################################ |
|
||||
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.") |
|
||||
) |
|
@ -1,50 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
################################################################################ |
|
||||
# |
|
||||
# Cybrosys Technologies Pvt. Ltd. |
|
||||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|
||||
# 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 <https://www.gnu.org/licenses/>. |
|
||||
# |
|
||||
################################################################################ |
|
||||
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") |
|
@ -1,89 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
################################################################################ |
|
||||
# |
|
||||
# Cybrosys Technologies Pvt. Ltd. |
|
||||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|
||||
# 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 <https://www.gnu.org/licenses/>. |
|
||||
# |
|
||||
################################################################################ |
|
||||
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)] |
|
@ -1,33 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
################################################################################ |
|
||||
# |
|
||||
# Cybrosys Technologies Pvt. Ltd. |
|
||||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|
||||
# 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 <https://www.gnu.org/licenses/>. |
|
||||
# |
|
||||
################################################################################ |
|
||||
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') |
|
@ -1,33 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
################################################################################ |
|
||||
# |
|
||||
# Cybrosys Technologies Pvt. Ltd. |
|
||||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|
||||
# 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 <https://www.gnu.org/licenses/>. |
|
||||
# |
|
||||
################################################################################ |
|
||||
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') |
|
|
Before Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 310 B |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 576 B |
Before Width: | Height: | Size: 733 B |
Before Width: | Height: | Size: 911 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 673 B |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 878 B |
Before Width: | Height: | Size: 653 B |
Before Width: | Height: | Size: 905 B |
Before Width: | Height: | Size: 839 B |
Before Width: | Height: | Size: 427 B |
Before Width: | Height: | Size: 627 B |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 988 B |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 589 B |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 565 B |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 967 B |
Before Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 95 KiB |
Before Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 164 KiB |
Before Width: | Height: | Size: 81 KiB |
Before Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 202 KiB |
Before Width: | Height: | Size: 138 KiB |
Before Width: | Height: | Size: 99 KiB |
Before Width: | Height: | Size: 101 KiB |
Before Width: | Height: | Size: 106 KiB |
Before Width: | Height: | Size: 81 KiB |
Before Width: | Height: | Size: 127 KiB |
Before Width: | Height: | Size: 111 KiB |
Before Width: | Height: | Size: 148 KiB |
Before Width: | Height: | Size: 115 KiB |
Before Width: | Height: | Size: 103 KiB |
Before Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 2.3 KiB |
@ -1,19 +0,0 @@ |
|||||
/** @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("crm_kit.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), |
|
||||
}); |
|
||||
} |
|
||||
}); |
|
@ -1,101 +0,0 @@ |
|||||
<?xml version="1.0" encoding="UTF-8" ?> |
|
||||
<odoo> |
|
||||
<!-- crm commission tree view--> |
|
||||
<record id="crm_commission_view_tree" model="ir.ui.view"> |
|
||||
<field name="name">crm.commission.view.tree</field> |
|
||||
<field name="model">crm.commission</field> |
|
||||
<field name="arch" type="xml"> |
|
||||
<tree> |
|
||||
<field name="name"/> |
|
||||
<field name="type"/> |
|
||||
</tree> |
|
||||
</field> |
|
||||
</record> |
|
||||
<!-- crm commission form view--> |
|
||||
<record id="crm_commission_view_form" model="ir.ui.view"> |
|
||||
<field name="name">crm.commission.view.form</field> |
|
||||
<field name="model">crm.commission</field> |
|
||||
<field name="arch" type="xml"> |
|
||||
<form> |
|
||||
<sheet> |
|
||||
<div class="oe_title"> |
|
||||
<h1> |
|
||||
<field name="name" readonly="1"/> |
|
||||
</h1> |
|
||||
</div> |
|
||||
<group> |
|
||||
<group> |
|
||||
<field name="name"/> |
|
||||
<field name="date_from"/> |
|
||||
<field name="date_to"/> |
|
||||
</group> |
|
||||
<group> |
|
||||
<field name="active"/> |
|
||||
<field name="type"/> |
|
||||
<field name="revenue_type" |
|
||||
invisible="type == 'product'"/> |
|
||||
</group> |
|
||||
</group> |
|
||||
<notebook> |
|
||||
<page string="Product Wise" |
|
||||
invisible="type != 'product'"> |
|
||||
<field name="product_comm_ids"> |
|
||||
<tree editable="Top" create="1" multi_edit="1"> |
|
||||
<field name="category_id" |
|
||||
style="width:20%%"/> |
|
||||
<field name="product_id" |
|
||||
style="width:20%%"/> |
|
||||
<field name="percentage" |
|
||||
style="width:50%%"/> |
|
||||
<field name="amount" style="width:50%%"/> |
|
||||
</tree> |
|
||||
</field> |
|
||||
</page> |
|
||||
<page string="Straight Revenue Commission" |
|
||||
invisible="type == 'product' or not revenue_type or revenue_type == 'graduated'"> |
|
||||
<group> |
|
||||
<field name="straight_commission_rate" |
|
||||
string="Commission rate (%)" |
|
||||
invisible="type == 'product' or not revenue_type or revenue_type == 'graduated'"/> |
|
||||
</group> |
|
||||
</page> |
|
||||
<page string="Graduated Revenue Commission" |
|
||||
invisible="type == 'product' or not revenue_type or revenue_type == 'straight'"> |
|
||||
<field name="revenue_grd_comm_ids"> |
|
||||
<tree editable="Top" create="1" multi_edit="1"> |
|
||||
<field name="sequence"/> |
|
||||
<field name="amount_from"/> |
|
||||
<field name="amount_to"/> |
|
||||
<field name="graduated_commission_rate"/> |
|
||||
</tree> |
|
||||
</field> |
|
||||
</page> |
|
||||
</notebook> |
|
||||
</sheet> |
|
||||
<div class="oe_chatter"> |
|
||||
<field name="message_follower_ids"/> |
|
||||
<field name="activity_ids"/> |
|
||||
<field name="message_ids"/> |
|
||||
</div> |
|
||||
</form> |
|
||||
</field> |
|
||||
</record> |
|
||||
<!-- Commission Plan record Action--> |
|
||||
<record id="action_commission_plan" model="ir.actions.act_window"> |
|
||||
<field name="name">CRM Commission Plan</field> |
|
||||
<field name="type">ir.actions.act_window</field> |
|
||||
<field name="res_model">crm.commission</field> |
|
||||
<field name="view_mode">tree,form</field> |
|
||||
<field name="help" type="html"> |
|
||||
<p class="o_view_nocontent_smiling_face"> |
|
||||
Create New Commission Plan! |
|
||||
</p> |
|
||||
</field> |
|
||||
</record> |
|
||||
<!-- Commission plans Menu--> |
|
||||
<menuitem id="crm_menu_commission_plan" |
|
||||
name="Commission Plans" |
|
||||
parent="crm.crm_menu_config" |
|
||||
action="action_commission_plan" |
|
||||
sequence="13"/> |
|
||||
</odoo> |
|
@ -1,14 +0,0 @@ |
|||||
<?xml version="1.0" encoding="UTF-8" ?> |
|
||||
<odoo> |
|
||||
<!-- Inheriting crm_team form view--> |
|
||||
<record id="crm_team_view_form" model="ir.ui.view"> |
|
||||
<field name="name">crm.team.view.form.inherit.crm.kit</field> |
|
||||
<field name="model">crm.team</field> |
|
||||
<field name="inherit_id" ref="sales_team.crm_team_view_form"/> |
|
||||
<field name="arch" type="xml"> |
|
||||
<field name="alias_contact" position="after"> |
|
||||
<field name="commission_id"/> |
|
||||
</field> |
|
||||
</field> |
|
||||
</record> |
|
||||
</odoo> |
|
@ -1,28 +0,0 @@ |
|||||
<?xml version="1.0" encoding="UTF-8" ?> |
|
||||
<odoo> |
|
||||
<!-- Inheriting res_users form view--> |
|
||||
<record id="view_users_simple_form" model="ir.ui.view"> |
|
||||
<field name="name">res.users.view.inherit.form.crm.kit</field> |
|
||||
<field name="model">res.users</field> |
|
||||
<field name="inherit_id" ref="base.view_users_simple_form"/> |
|
||||
<field name="arch" type="xml"> |
|
||||
<field name="mobile" position="after"> |
|
||||
<field name="commission_id"/> |
|
||||
</field> |
|
||||
</field> |
|
||||
</record> |
|
||||
<!-- res_users action--> |
|
||||
<record id="action_crm_salespersons" model="ir.actions.act_window"> |
|
||||
<field name="name">Sales Persons</field> |
|
||||
<field name="type">ir.actions.act_window</field> |
|
||||
<field name="res_model">res.users</field> |
|
||||
<field name="domain">[('share','=',False)]</field> |
|
||||
<field name="view_mode">tree,kanban,form</field> |
|
||||
</record> |
|
||||
<!-- Sales Person menu--> |
|
||||
<menuitem id="crm_menu_sales_persons" |
|
||||
name="Sales Persons" |
|
||||
parent="crm.crm_menu_config" |
|
||||
action="action_crm_salespersons" |
|
||||
sequence="6"/> |
|
||||
</odoo> |
|
@ -1,22 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
################################################################################ |
|
||||
# |
|
||||
# Cybrosys Technologies Pvt. Ltd. |
|
||||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|
||||
# 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 <https://www.gnu.org/licenses/>. |
|
||||
# |
|
||||
################################################################################ |
|
||||
from . import commission_report |
|
@ -1,375 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
################################################################################ |
|
||||
# |
|
||||
# Cybrosys Technologies Pvt. Ltd. |
|
||||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|
||||
# 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 <https://www.gnu.org/licenses/>. |
|
||||
# |
|
||||
################################################################################ |
|
||||
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() |
|
@ -1,47 +0,0 @@ |
|||||
<?xml version="1.0" encoding="UTF-8" ?> |
|
||||
<odoo> |
|
||||
<!-- Commission report form view--> |
|
||||
<record id="commission_report_view_form" model="ir.ui.view"> |
|
||||
<field name="name">commission.report.view.form</field> |
|
||||
<field name="model">commission.report</field> |
|
||||
<field name="type">form</field> |
|
||||
<field name="arch" type="xml"> |
|
||||
<form> |
|
||||
<sheet> |
|
||||
<group> |
|
||||
<group> |
|
||||
<field name="date_from" required="1"/> |
|
||||
<field name="date_to" required="1"/> |
|
||||
</group> |
|
||||
<group> |
|
||||
<field name="is_sales_person" invisible="True"/> |
|
||||
<field name="is_sales_team" invisible="True"/> |
|
||||
<field name="sales_team_ids" widget="many2many_tags" options="{'no_create': True}" invisible="is_sales_person == True"/> |
|
||||
<field name="salesperson_ids" widget="many2many_tags" options="{'no_create': True}" invisible="is_sales_team == True"/> |
|
||||
</group> |
|
||||
</group> |
|
||||
</sheet> |
|
||||
<footer> |
|
||||
<button name="action_print_xls_report" string="Print XLS" |
|
||||
type="object" class="oe_highlight"/> |
|
||||
<button string="Cancel" class="btn btn_default" |
|
||||
special="cancel"/> |
|
||||
</footer> |
|
||||
</form> |
|
||||
</field> |
|
||||
</record> |
|
||||
<!-- Commission Report Action--> |
|
||||
<record id="commission_reporting_action" model="ir.actions.act_window"> |
|
||||
<field name="name">Commission Report</field> |
|
||||
<field name="res_model">commission.report</field> |
|
||||
<field name="view_mode">form</field> |
|
||||
<field name="view_id" ref="commission_report_view_form"/> |
|
||||
<field name="target">new</field> |
|
||||
</record> |
|
||||
<!-- Commission Report menu--> |
|
||||
<menuitem id="commission_excel_report_root" |
|
||||
name="Commission Report " |
|
||||
parent="crm.crm_menu_report" |
|
||||
action="commission_reporting_action" |
|
||||
sequence="4"/> |
|
||||
</odoo> |
|