diff --git a/low_sale_report/README.rst b/low_sale_report/README.rst new file mode 100644 index 000000000..ecf94ce5a --- /dev/null +++ b/low_sale_report/README.rst @@ -0,0 +1,44 @@ +.. 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 + +Low Sales Report +================ +* The tool to control poorly performing product + +Configuration +============= +* No additional configurations needed + +Company +------- +* `Cybrosys Techno Solutions `__ + +License +------- +Affero General Public License v3.0 (AGPL v3) +(https://www.gnu.org/licenses/agpl-3.0-standalone.html) + +Credits +------- +* Developer: (V17) Junaidul Ansar M , Contact: odoo@cybrosys.com + (V18) Raveena Vijayan V , Contact: 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 +========== +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit https://www.cybrosys.com + +Further information +=================== +HTML Description: ``__ diff --git a/low_sale_report/__init__.py b/low_sale_report/__init__.py new file mode 100644 index 000000000..17ea7656f --- /dev/null +++ b/low_sale_report/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Raveena V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from . import controllers +from . import models +from . import report +from . import wizard diff --git a/low_sale_report/__manifest__.py b/low_sale_report/__manifest__.py new file mode 100644 index 000000000..be096f4e7 --- /dev/null +++ b/low_sale_report/__manifest__.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Raveena V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +{ + 'name': "Low Sales Report", + 'version': '18.0.1.0.0', + 'category': 'Sale', + 'summary': 'The tool to control poorly performing product', + 'description': 'Efficiently manage and analyze low sales with this module,' + 'offering customizable criteria, flexible reporting ' + 'periods, and versatile presentation options in Odoo or ' + 'Excel. Tailor your analysis by filtering specific product' + 'categories or sales teams, and choose between ' + 'template-wide insights or focus on individual product ' + 'variants for a comprehensive understanding of ' + 'under performing products.', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'depends': ['sale_management', 'crm', 'product', 'mail'], + 'data': [ + 'security/ir.model.access.csv', + 'views/res_config_settings_view.xml', + 'report/low_sale_pivot_view_report_view.xml', + 'wizard/low_sale_report_views.xml' + ], + 'assets': { + 'web.assets_backend': [ + 'low_sale_report/static/src/js/low_sale_xlsx_report.js', + ], + }, + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/low_sale_report/controllers/__init__.py b/low_sale_report/controllers/__init__.py new file mode 100644 index 000000000..665464a44 --- /dev/null +++ b/low_sale_report/controllers/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Raveena V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from . import low_sale_report diff --git a/low_sale_report/controllers/low_sale_report.py b/low_sale_report/controllers/low_sale_report.py new file mode 100644 index 000000000..8c12705db --- /dev/null +++ b/low_sale_report/controllers/low_sale_report.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Raveena V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +import json +from odoo import http +from odoo.http import content_disposition, request +from odoo.http import serialize_exception as _serialize_exception +from odoo.tools import html_escape + + +class XLSXReportController(http.Controller): + """This controller defines a route for generating and serving XLSX reports. + The route '/sale_low_xlsx_reports' accepts POST requests and returns an + XLSX report based on the provided model, options, output format, and report + name.""" + @http.route('/sale_low_xlsx_reports', type='http', + auth='user', methods=['POST'], csrf=False) + def get_report_xlsx(self, model, options, output_format, report_name): + """Generate and serve an XLSX report.""" + 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_low_sale_xlsx_report(options, response) + response.set_cookie('fileToken', token) + return response + except Exception as e: + se = _serialize_exception(e) + error = { + 'code': 200, + 'message': 'Odoo Server Error', + 'data': se + } + return request.make_response(html_escape(json.dumps(error))) diff --git a/low_sale_report/doc/RELEASE_NOTES.md b/low_sale_report/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..07c2c0984 --- /dev/null +++ b/low_sale_report/doc/RELEASE_NOTES.md @@ -0,0 +1,7 @@ +## Module + +#### 02.11.2024 +#### Version 18.0.1.0.0 +##### ADD + +- Initial Commit for Low Sales Report diff --git a/low_sale_report/models/__init__.py b/low_sale_report/models/__init__.py new file mode 100644 index 000000000..941867641 --- /dev/null +++ b/low_sale_report/models/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Raveena V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from . import res_config_settings diff --git a/low_sale_report/models/res_config_settings.py b/low_sale_report/models/res_config_settings.py new file mode 100644 index 000000000..85ee72c61 --- /dev/null +++ b/low_sale_report/models/res_config_settings.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Raveena V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + """Adding a new fields to res_config_settings model for filtering the + low sales report""" + _inherit = "res.config.settings" + + product_type = fields.Selection( + [('variant', 'By product variant'), + ('template', 'By product templates')], string="Report Type", + help='Which sale to take into account: Product templates in general' + ' or variants?', + config_parameter='low_sale_report.product_type') + analysed_period = fields.Selection( + [('last_month', 'Last Month'), + ('last_3', 'Last 3 Month'), ('last_6', 'Last 6 Month'), + ('last_12', 'Last 12 Month')], string='Analysed Period', + help='Define the which period should be analysed by default.', + config_parameter='low_sale_report.analysed_period') + absolute_qty = fields.Float(string='Absolute Quantity', + help='Define a default critical level for ' + 'sales.', + config_parameter='low_sale_report.absolute_qty') diff --git a/low_sale_report/report/__init__.py b/low_sale_report/report/__init__.py new file mode 100644 index 000000000..c9ab6f9cf --- /dev/null +++ b/low_sale_report/report/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Raveena V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from . import low_sale_pivot_view_report diff --git a/low_sale_report/report/low_sale_pivot_view_report.py b/low_sale_report/report/low_sale_pivot_view_report.py new file mode 100644 index 000000000..b089f1ad1 --- /dev/null +++ b/low_sale_report/report/low_sale_pivot_view_report.py @@ -0,0 +1,130 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Raveena V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from odoo import fields, models + + +class LowSalePivotViewReport(models.Model): + """Pivot view report""" + _name = 'low.sale.pivot.view.report' + _description = 'LowSale Pivot View Report' + + categ_id = fields.Many2one( + comodel_name='product.category', string="Product Category", + readonly=True, help='Category id of the product') + product_id = fields.Many2one( + comodel_name='product.product', string="Product Variant", readonly=True, + help='Product_product model id') + product_tmpl_id = fields.Many2one( + comodel_name='product.template', string="Product", readonly=True, + help='Product_template model id') + product_uom_qty = fields.Float(string="Sold quantity", readonly=True, + help='Total count of the quantity to sold') + company_id = fields.Many2one('res.company', store=True, + copy=False, string="Company", + default=lambda + self: self.env.user.company_id.id, + help='Company id for the reference of the' + ' monetary field') + currency_id = fields.Many2one('res.currency', string="Currency", + related='company_id.currency_id', + default=lambda + self: self.env.user.company_id.currency_id.id, + help='Currency id for the reference of the ' + 'monetary field') + price_total = fields.Monetary(string="Total", readonly=True, + help='Total price of the product sold') + + def get_data(self, low_sale_report): + """Fetching the data for the pivot view and the Excel report using + the sql query""" + conditions = [] + filters = [] + if low_sale_report['analysed_period_start'] and low_sale_report[ + 'analysed_period_end']: + filters.append(f"o.date_order BETWEEN '" + f"{low_sale_report['analysed_period_start']}" + f"' AND '" + f"{low_sale_report['analysed_period_end']}'") + if low_sale_report['absolute_qty'] > 0: + conditions.append( + f"COALESCE(SUM(CASE WHEN o.state = 'sale' THEN " + f"l.product_uom_qty ELSE 0 END), 0) <= " + f"{low_sale_report['absolute_qty']}") + if low_sale_report['category']: + filters.append( + "t.categ_id = %s" % int(low_sale_report['category'][0])) + if low_sale_report['sale_team']: + filters.append( + "o.team_id = %s" % int(low_sale_report['sale_team'][0])) + if low_sale_report['product_type'] == 'variant': + query = """ + SELECT + p.id AS product_id, + COALESCE(SUM(CASE WHEN o.state = 'sale' THEN + l.product_uom_qty ELSE 0 END), 0) AS + total_sold_quantity, + COALESCE(SUM(CASE WHEN o.state = 'sale' THEN + l.price_total ELSE 0 END), 0) AS price_total, + t.name->>'en_US' AS product_name + FROM + product_product p + LEFT JOIN + product_template t ON p.product_tmpl_id = t.id + LEFT JOIN + sale_order_line l ON p.id = l.product_id + LEFT JOIN + sale_order o ON l.order_id = o.id + """ + ('WHERE ' + ' AND '.join(filters) if + filters else '') + """ + GROUP BY + p.id, t.name + """ + ('HAVING ' + ' AND '.join(conditions) if + conditions else '') + """ + """ + else: + query = """ + SELECT + t.id AS product_tmpl_id, + COALESCE(SUM(CASE WHEN o.state = 'sale' THEN + l.product_uom_qty ELSE 0 END), 0) AS + total_sold_quantity, + COALESCE(SUM(CASE WHEN o.state = 'sale' THEN + l.price_total ELSE 0 END), 0) AS price_total, + t.name->>'en_US' AS product_name + FROM + product_template t + LEFT JOIN + product_product p ON t.id = p.product_tmpl_id + LEFT JOIN + sale_order_line l ON p.id = l.product_id + LEFT JOIN + sale_order o ON l.order_id = o.id + """ + ('WHERE ' + ' AND '.join(filters) if + filters else '') + """ + GROUP BY + t.id, t.name + """ + ('HAVING ' + ' AND '.join(conditions) if + conditions else '') + """ + """ + self.env.cr.execute(query) + test = self.env.cr.fetchall() + return test diff --git a/low_sale_report/report/low_sale_pivot_view_report_view.xml b/low_sale_report/report/low_sale_pivot_view_report_view.xml new file mode 100644 index 000000000..37641014f --- /dev/null +++ b/low_sale_report/report/low_sale_pivot_view_report_view.xml @@ -0,0 +1,30 @@ + + + + + low.sale.pivot.view.report.view.pivot.variant + low.sale.pivot.view.report + + + + + + + + + + + low.sale.pivot.view.report.view.pivot.template + + low.sale.pivot.view.report + + + + + + + + + diff --git a/low_sale_report/security/ir.model.access.csv b/low_sale_report/security/ir.model.access.csv new file mode 100644 index 000000000..561c837b7 --- /dev/null +++ b/low_sale_report/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_low_sale_report_user,access.low.sale.report.user,model_low_sale_report,base.group_user,1,1,1,1 +access_low_sale_pivot_view_report_user,access.low.sale.pivot.view.report.user,model_low_sale_pivot_view_report,base.group_user,1,1,1,1 diff --git a/low_sale_report/static/description/assets/cybro-icon.png b/low_sale_report/static/description/assets/cybro-icon.png new file mode 100644 index 000000000..06e73e11d Binary files /dev/null and b/low_sale_report/static/description/assets/cybro-icon.png differ diff --git a/low_sale_report/static/description/assets/cybro-odoo.png b/low_sale_report/static/description/assets/cybro-odoo.png new file mode 100644 index 000000000..ed02e07a4 Binary files /dev/null and b/low_sale_report/static/description/assets/cybro-odoo.png differ diff --git a/low_sale_report/static/description/assets/h2.png b/low_sale_report/static/description/assets/h2.png new file mode 100644 index 000000000..0bfc4707d Binary files /dev/null and b/low_sale_report/static/description/assets/h2.png differ diff --git a/low_sale_report/static/description/assets/icons/arrows-repeat.svg b/low_sale_report/static/description/assets/icons/arrows-repeat.svg new file mode 100644 index 000000000..1d7efabc5 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/arrows-repeat.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/banner-1.png b/low_sale_report/static/description/assets/icons/banner-1.png new file mode 100644 index 000000000..c180db172 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/banner-1.png differ diff --git a/low_sale_report/static/description/assets/icons/banner-2.svg b/low_sale_report/static/description/assets/icons/banner-2.svg new file mode 100644 index 000000000..e606d97d9 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/banner-2.svg @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/banner-bg.png b/low_sale_report/static/description/assets/icons/banner-bg.png new file mode 100644 index 000000000..a8238d3c0 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/banner-bg.png differ diff --git a/low_sale_report/static/description/assets/icons/banner-bg.svg b/low_sale_report/static/description/assets/icons/banner-bg.svg new file mode 100644 index 000000000..b1378103e --- /dev/null +++ b/low_sale_report/static/description/assets/icons/banner-bg.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/banner-call.svg b/low_sale_report/static/description/assets/icons/banner-call.svg new file mode 100644 index 000000000..96c687e81 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/banner-call.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/low_sale_report/static/description/assets/icons/banner-mail.svg b/low_sale_report/static/description/assets/icons/banner-mail.svg new file mode 100644 index 000000000..cbf0d158d --- /dev/null +++ b/low_sale_report/static/description/assets/icons/banner-mail.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/low_sale_report/static/description/assets/icons/banner-pattern.svg b/low_sale_report/static/description/assets/icons/banner-pattern.svg new file mode 100644 index 000000000..9c1c7e101 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/banner-pattern.svg @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/banner-promo.svg b/low_sale_report/static/description/assets/icons/banner-promo.svg new file mode 100644 index 000000000..d52791b11 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/banner-promo.svg @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/brand-pair.svg b/low_sale_report/static/description/assets/icons/brand-pair.svg new file mode 100644 index 000000000..d8db7fc1e --- /dev/null +++ b/low_sale_report/static/description/assets/icons/brand-pair.svg @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/check.png b/low_sale_report/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/low_sale_report/static/description/assets/icons/check.png differ diff --git a/low_sale_report/static/description/assets/icons/chevron.png b/low_sale_report/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/chevron.png differ diff --git a/low_sale_report/static/description/assets/icons/close-icon.svg b/low_sale_report/static/description/assets/icons/close-icon.svg new file mode 100644 index 000000000..df8cce37a --- /dev/null +++ b/low_sale_report/static/description/assets/icons/close-icon.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/low_sale_report/static/description/assets/icons/cogs.png b/low_sale_report/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/cogs.png differ diff --git a/low_sale_report/static/description/assets/icons/collabarate-icon.svg b/low_sale_report/static/description/assets/icons/collabarate-icon.svg new file mode 100644 index 000000000..dd4e10518 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/collabarate-icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/low_sale_report/static/description/assets/icons/consultation.png b/low_sale_report/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/low_sale_report/static/description/assets/icons/consultation.png differ diff --git a/low_sale_report/static/description/assets/icons/cybro-logo.png b/low_sale_report/static/description/assets/icons/cybro-logo.png new file mode 100644 index 000000000..ff4b78220 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/cybro-logo.png differ diff --git a/low_sale_report/static/description/assets/icons/down.svg b/low_sale_report/static/description/assets/icons/down.svg new file mode 100644 index 000000000..f21c36271 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/down.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/low_sale_report/static/description/assets/icons/ecom-black.png b/low_sale_report/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/ecom-black.png differ diff --git a/low_sale_report/static/description/assets/icons/education-black.png b/low_sale_report/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/low_sale_report/static/description/assets/icons/education-black.png differ diff --git a/low_sale_report/static/description/assets/icons/faq.png b/low_sale_report/static/description/assets/icons/faq.png new file mode 100644 index 000000000..4250b5b81 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/faq.png differ diff --git a/low_sale_report/static/description/assets/icons/feature-icon.svg b/low_sale_report/static/description/assets/icons/feature-icon.svg new file mode 100644 index 000000000..fa0ea6850 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/feature-icon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/feature.png b/low_sale_report/static/description/assets/icons/feature.png new file mode 100644 index 000000000..ac7a785c0 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/feature.png differ diff --git a/low_sale_report/static/description/assets/icons/gear.svg b/low_sale_report/static/description/assets/icons/gear.svg new file mode 100644 index 000000000..0cc66b6ea --- /dev/null +++ b/low_sale_report/static/description/assets/icons/gear.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/hero.gif b/low_sale_report/static/description/assets/icons/hero.gif new file mode 100644 index 000000000..ea9aeef3d Binary files /dev/null and b/low_sale_report/static/description/assets/icons/hero.gif differ diff --git a/low_sale_report/static/description/assets/icons/hire-odoo.svg b/low_sale_report/static/description/assets/icons/hire-odoo.svg new file mode 100644 index 000000000..e1ac089b0 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/hire-odoo.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/hotel-black.png b/low_sale_report/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/low_sale_report/static/description/assets/icons/hotel-black.png differ diff --git a/low_sale_report/static/description/assets/icons/license.png b/low_sale_report/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/low_sale_report/static/description/assets/icons/license.png differ diff --git a/low_sale_report/static/description/assets/icons/life-ring-icon.svg b/low_sale_report/static/description/assets/icons/life-ring-icon.svg new file mode 100644 index 000000000..3ae6e1d89 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/life-ring-icon.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/lifebuoy.png b/low_sale_report/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/low_sale_report/static/description/assets/icons/lifebuoy.png differ diff --git a/low_sale_report/static/description/assets/icons/mail.svg b/low_sale_report/static/description/assets/icons/mail.svg new file mode 100644 index 000000000..1eedde695 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/mail.svg @@ -0,0 +1,3 @@ + + + diff --git a/low_sale_report/static/description/assets/icons/manufacturing-black.png b/low_sale_report/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/low_sale_report/static/description/assets/icons/manufacturing-black.png differ diff --git a/low_sale_report/static/description/assets/icons/notes.png b/low_sale_report/static/description/assets/icons/notes.png new file mode 100644 index 000000000..ee5e95404 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/notes.png differ diff --git a/low_sale_report/static/description/assets/icons/notification icon.svg b/low_sale_report/static/description/assets/icons/notification icon.svg new file mode 100644 index 000000000..053189973 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/notification icon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/odoo-consultancy.svg b/low_sale_report/static/description/assets/icons/odoo-consultancy.svg new file mode 100644 index 000000000..e05f65bde --- /dev/null +++ b/low_sale_report/static/description/assets/icons/odoo-consultancy.svg @@ -0,0 +1,4 @@ + + + + diff --git a/low_sale_report/static/description/assets/icons/odoo-licencing.svg b/low_sale_report/static/description/assets/icons/odoo-licencing.svg new file mode 100644 index 000000000..2606c88b0 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/odoo-licencing.svg @@ -0,0 +1,3 @@ + + + diff --git a/low_sale_report/static/description/assets/icons/odoo-logo.png b/low_sale_report/static/description/assets/icons/odoo-logo.png new file mode 100644 index 000000000..0e4d0eb5a Binary files /dev/null and b/low_sale_report/static/description/assets/icons/odoo-logo.png differ diff --git a/low_sale_report/static/description/assets/icons/patter.svg b/low_sale_report/static/description/assets/icons/patter.svg new file mode 100644 index 000000000..25c9c0a8f --- /dev/null +++ b/low_sale_report/static/description/assets/icons/patter.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/pattern1.png b/low_sale_report/static/description/assets/icons/pattern1.png new file mode 100644 index 000000000..09ab0fb2d Binary files /dev/null and b/low_sale_report/static/description/assets/icons/pattern1.png differ diff --git a/low_sale_report/static/description/assets/icons/pos-black.png b/low_sale_report/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/pos-black.png differ diff --git a/low_sale_report/static/description/assets/icons/puzzle-piece-icon.svg b/low_sale_report/static/description/assets/icons/puzzle-piece-icon.svg new file mode 100644 index 000000000..3e9ad9373 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/puzzle-piece-icon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/puzzle.png b/low_sale_report/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/puzzle.png differ diff --git a/low_sale_report/static/description/assets/icons/replace-icon.svg b/low_sale_report/static/description/assets/icons/replace-icon.svg new file mode 100644 index 000000000..d0e3a7af1 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/replace-icon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/restaurant-black.png b/low_sale_report/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/restaurant-black.png differ diff --git a/low_sale_report/static/description/assets/icons/screenshot-main.png b/low_sale_report/static/description/assets/icons/screenshot-main.png new file mode 100644 index 000000000..575f8e676 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/screenshot-main.png differ diff --git a/low_sale_report/static/description/assets/icons/screenshot.png b/low_sale_report/static/description/assets/icons/screenshot.png new file mode 100644 index 000000000..cef272529 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/screenshot.png differ diff --git a/low_sale_report/static/description/assets/icons/service-black.png b/low_sale_report/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/low_sale_report/static/description/assets/icons/service-black.png differ diff --git a/low_sale_report/static/description/assets/icons/skype-fill.svg b/low_sale_report/static/description/assets/icons/skype-fill.svg new file mode 100644 index 000000000..c17423639 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/skype-fill.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/skype.png b/low_sale_report/static/description/assets/icons/skype.png new file mode 100644 index 000000000..51b409fb3 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/skype.png differ diff --git a/low_sale_report/static/description/assets/icons/skype.svg b/low_sale_report/static/description/assets/icons/skype.svg new file mode 100644 index 000000000..df3dad39b --- /dev/null +++ b/low_sale_report/static/description/assets/icons/skype.svg @@ -0,0 +1,3 @@ + + + diff --git a/low_sale_report/static/description/assets/icons/star-1.svg b/low_sale_report/static/description/assets/icons/star-1.svg new file mode 100644 index 000000000..7e55ab162 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/star-1.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/star-2.svg b/low_sale_report/static/description/assets/icons/star-2.svg new file mode 100644 index 000000000..5ae9f507a --- /dev/null +++ b/low_sale_report/static/description/assets/icons/star-2.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/support.png b/low_sale_report/static/description/assets/icons/support.png new file mode 100644 index 000000000..4f18b8b82 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/support.png differ diff --git a/low_sale_report/static/description/assets/icons/test-1 - Copy.png b/low_sale_report/static/description/assets/icons/test-1 - Copy.png new file mode 100644 index 000000000..f6a902663 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/test-1 - Copy.png differ diff --git a/low_sale_report/static/description/assets/icons/test-1.png b/low_sale_report/static/description/assets/icons/test-1.png new file mode 100644 index 000000000..0908add2b Binary files /dev/null and b/low_sale_report/static/description/assets/icons/test-1.png differ diff --git a/low_sale_report/static/description/assets/icons/test-2.png b/low_sale_report/static/description/assets/icons/test-2.png new file mode 100644 index 000000000..4671fe91e Binary files /dev/null and b/low_sale_report/static/description/assets/icons/test-2.png differ diff --git a/low_sale_report/static/description/assets/icons/trading-black.png b/low_sale_report/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/trading-black.png differ diff --git a/low_sale_report/static/description/assets/icons/training.png b/low_sale_report/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/low_sale_report/static/description/assets/icons/training.png differ diff --git a/low_sale_report/static/description/assets/icons/translate.svg b/low_sale_report/static/description/assets/icons/translate.svg new file mode 100644 index 000000000..af9c8a1aa --- /dev/null +++ b/low_sale_report/static/description/assets/icons/translate.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/update.png b/low_sale_report/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/low_sale_report/static/description/assets/icons/update.png differ diff --git a/low_sale_report/static/description/assets/icons/user.png b/low_sale_report/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/low_sale_report/static/description/assets/icons/user.png differ diff --git a/low_sale_report/static/description/assets/icons/video.png b/low_sale_report/static/description/assets/icons/video.png new file mode 100644 index 000000000..576705b17 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/video.png differ diff --git a/low_sale_report/static/description/assets/icons/whatsapp.png b/low_sale_report/static/description/assets/icons/whatsapp.png new file mode 100644 index 000000000..d513a5356 Binary files /dev/null and b/low_sale_report/static/description/assets/icons/whatsapp.png differ diff --git a/low_sale_report/static/description/assets/icons/wrench-icon.svg b/low_sale_report/static/description/assets/icons/wrench-icon.svg new file mode 100644 index 000000000..174b5a465 --- /dev/null +++ b/low_sale_report/static/description/assets/icons/wrench-icon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/low_sale_report/static/description/assets/icons/wrench.png b/low_sale_report/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/low_sale_report/static/description/assets/icons/wrench.png differ diff --git a/low_sale_report/static/description/assets/modules/1.png b/low_sale_report/static/description/assets/modules/1.png new file mode 100644 index 000000000..738d65baf Binary files /dev/null and b/low_sale_report/static/description/assets/modules/1.png differ diff --git a/low_sale_report/static/description/assets/modules/2.png b/low_sale_report/static/description/assets/modules/2.png new file mode 100644 index 000000000..662cadcc3 Binary files /dev/null and b/low_sale_report/static/description/assets/modules/2.png differ diff --git a/low_sale_report/static/description/assets/modules/3.png b/low_sale_report/static/description/assets/modules/3.png new file mode 100644 index 000000000..0178d2964 Binary files /dev/null and b/low_sale_report/static/description/assets/modules/3.png differ diff --git a/low_sale_report/static/description/assets/modules/4.png b/low_sale_report/static/description/assets/modules/4.png new file mode 100644 index 000000000..00ebf54ad Binary files /dev/null and b/low_sale_report/static/description/assets/modules/4.png differ diff --git a/low_sale_report/static/description/assets/modules/5.png b/low_sale_report/static/description/assets/modules/5.png new file mode 100644 index 000000000..cd5fffdd6 Binary files /dev/null and b/low_sale_report/static/description/assets/modules/5.png differ diff --git a/low_sale_report/static/description/assets/modules/6.png b/low_sale_report/static/description/assets/modules/6.png new file mode 100644 index 000000000..7c67e2eec Binary files /dev/null and b/low_sale_report/static/description/assets/modules/6.png differ diff --git a/low_sale_report/static/description/assets/screenshots/ls1.png b/low_sale_report/static/description/assets/screenshots/ls1.png new file mode 100644 index 000000000..244247a96 Binary files /dev/null and b/low_sale_report/static/description/assets/screenshots/ls1.png differ diff --git a/low_sale_report/static/description/assets/screenshots/ls2.png b/low_sale_report/static/description/assets/screenshots/ls2.png new file mode 100644 index 000000000..4757697c2 Binary files /dev/null and b/low_sale_report/static/description/assets/screenshots/ls2.png differ diff --git a/low_sale_report/static/description/assets/screenshots/ls3.png b/low_sale_report/static/description/assets/screenshots/ls3.png new file mode 100644 index 000000000..3c75558cd Binary files /dev/null and b/low_sale_report/static/description/assets/screenshots/ls3.png differ diff --git a/low_sale_report/static/description/assets/screenshots/ls4.png b/low_sale_report/static/description/assets/screenshots/ls4.png new file mode 100644 index 000000000..a0dfddee6 Binary files /dev/null and b/low_sale_report/static/description/assets/screenshots/ls4.png differ diff --git a/low_sale_report/static/description/assets/screenshots/ls5.png b/low_sale_report/static/description/assets/screenshots/ls5.png new file mode 100644 index 000000000..ca3a289ac Binary files /dev/null and b/low_sale_report/static/description/assets/screenshots/ls5.png differ diff --git a/low_sale_report/static/description/assets/screenshots/ls6.png b/low_sale_report/static/description/assets/screenshots/ls6.png new file mode 100644 index 000000000..41e167115 Binary files /dev/null and b/low_sale_report/static/description/assets/screenshots/ls6.png differ diff --git a/low_sale_report/static/description/assets/y18.jpg b/low_sale_report/static/description/assets/y18.jpg new file mode 100644 index 000000000..eea1714f2 Binary files /dev/null and b/low_sale_report/static/description/assets/y18.jpg differ diff --git a/low_sale_report/static/description/banner.jpg b/low_sale_report/static/description/banner.jpg new file mode 100644 index 000000000..68bee2933 Binary files /dev/null and b/low_sale_report/static/description/banner.jpg differ diff --git a/low_sale_report/static/description/icon.png b/low_sale_report/static/description/icon.png new file mode 100644 index 000000000..8773a4887 Binary files /dev/null and b/low_sale_report/static/description/icon.png differ diff --git a/low_sale_report/static/description/index.html b/low_sale_report/static/description/index.html new file mode 100644 index 000000000..436154fb8 --- /dev/null +++ b/low_sale_report/static/description/index.html @@ -0,0 +1,1026 @@ + + + + + + Low Sales Report + + + + + + + + + + +
+
+ + + +
+
+ Community +
+
+ Enterprise +
+ + + + +
+
+ +
+
+
+
+

The Tool to Control Poorly Performing Product +

+

low sales report +

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

Key + Highlights

+
+
+
+
+ +
+
+ Own Criteria for Low Sales +
+

+ Apply the level in absolute quantity sold (in a product default units of measure).

+
+
+
+
+
+ +
+
+ Any Period for Reports +
+

+ Generate a low sales report per any period you like: for the last 3 months, for a week before New Year, by all historical data, for exactly 327 days. Set a default period and default criteria on the configuration page. +

+
+
+
+
+
+ +
+
+ Odoo Pivot and Excel Table +
+

+ Work with the report in a way you like: in Odoo or as an Excel table. +

+
+
+
+
+
+ +
+
+ Filtered Analysis +
+

+ Shrink analysis for sales of definite product categories, sales teams. +

+
+
+
+
+
+ +
+
+ Template and Specific Variants +
+

+ Work with sales for product templates in general or for specific product variants. In the former case, all template variants' sales are taken into account. +

+
+
+
+
+ +
+
+
+ Low Sales Report +

+ Are you ready to make your business more + organized? +
Improve now! +

+ +
+
+ +
+
+
+ + + + +
+
+ +
+
+
+
+ acc_bg +
+ +
+
+
+
+

+ In + + Forms +

+
+
+

+Goto Sale -> Configuration -> Settings-> Under the settings we can see the new block to setting the default values. +

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

+ Menu + + Low Sale Report. +

+
+
+

+ When install the module you can see the menu under the Sale 'Low Sale Report'. + +

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

+ Creating Report in Odoo + + Pivot View. +

+
+
+

Click the menu its open the wizard then choose filters if you want then click the 'Show in Odoo' button to print the pivot view. +

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

+ Report + + + Pivot View. +

+
+
+

+ Generates the Low Sales Report in Odoo as a pivot view. +

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

+ Export + + Excel Report +

+
+
+

+ Click the menu its open the wizard then choose filters if you want then click the 'Export as xlsx' button to print the Excel report. +

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

+ Report + + + Excel. +

+
+
+

+ Generates the Low Sales Excel Report. +

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

+ User can edit or choose the report configurations easily.

+
+ +
+
+
+
+
+
+ +
+

+ Supports Export as Excel.

+
+
+
+
+
+
+
+ +
+

+ Report can be generated based on the Product categories.

+
+ +
+
+
+
+
+
+ +
+

+ Report can be generated based on the sales teams.

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

+ Latest Release 18.0.1.0.0 +

+ + 30th November, 2024 + +
+
+
+
+
+ Add +
+
+
+
    +
  • + Initial Commit +
  • + +
+
+
+
+
+
+
+
+
+
+ + + + + + +
+

+ Our Services

+ + +
+ +
+
+ .... +
+
+ +
+ + +
+
+ + + + + + diff --git a/low_sale_report/static/src/js/low_sale_xlsx_report.js b/low_sale_report/static/src/js/low_sale_xlsx_report.js new file mode 100644 index 000000000..9d82d6739 --- /dev/null +++ b/low_sale_report/static/src/js/low_sale_xlsx_report.js @@ -0,0 +1,15 @@ +/** @odoo-module **/ +/** Xlsx report action manager */ +import { registry } from "@web/core/registry"; +import { BlockUI } from "@web/core/ui/block_ui"; +import { download } from "@web/core/network/download"; +registry.category("ir.actions.report handlers").add("xlsx", async function (action) { + if (action.report_type === 'low_sale_xlsx_download') { + BlockUI; + await download({ + url: '/sale_low_xlsx_reports', + data: action.data, + complete: () => unblockUI, + error: (error) => self.call('crash_manager', 'rpc_error', error), + }); + }}); diff --git a/low_sale_report/views/res_config_settings_view.xml b/low_sale_report/views/res_config_settings_view.xml new file mode 100644 index 000000000..7a2c73384 --- /dev/null +++ b/low_sale_report/views/res_config_settings_view.xml @@ -0,0 +1,25 @@ + + + + + res.config.settings.view.form.inherit.low.sale.report + res.config.settings + + + + + + + + + + + + + + + + + + diff --git a/low_sale_report/wizard/__init__.py b/low_sale_report/wizard/__init__.py new file mode 100644 index 000000000..665464a44 --- /dev/null +++ b/low_sale_report/wizard/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Raveena V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from . import low_sale_report diff --git a/low_sale_report/wizard/low_sale_report.py b/low_sale_report/wizard/low_sale_report.py new file mode 100644 index 000000000..d6324f0ea --- /dev/null +++ b/low_sale_report/wizard/low_sale_report.py @@ -0,0 +1,211 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Raveena V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +import io +import json +from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError +from odoo.tools import json_default +from dateutil.relativedelta import relativedelta +try: + from odoo.tools.misc import xlsxwriter +except ImportError: + import xlsxwriter + + +class LowSaleReport(models.TransientModel): + """Its define as the sale low performance product details in pivot view and + the Excel report.""" + _name = 'low.sale.report' + _description = 'Low Sale Report' + + product_type = fields.Selection( + [('variant', 'By product variant'), + ('template', 'By product templates')], string="Report Type", + help='Which sale to take into account: Product templates in general' + ' or variants?', required=True) + analysed_period_start = fields.Date(string='Period under analysis', + help='If not chosen, all product sale' + ' will be analysed') + analysed_period_end = fields.Date(string='Period under analysis', + help='If not chosen, all product sale' + ' will be analysed', + default=fields.Date.today()) + absolute_qty = fields.Float(string='Critical Level(Absolute Quantity)', + help='Which sale level are considered to be' + ' low(in default unit of measurement) ', + required=True) + category = fields.Many2one('product.category', + string='Product Categories', + help='If not chosen, all product categories ' + 'wil be analysed') + sale_team = fields.Many2one('crm.team', + help='If not chosen, all the sale team will' + ' be analysed', string='Sales Teams') + + def action_pivot_low_sale_report(self): + """Exporting the low sale report as the pivot view format in odoo""" + low_sale_report = { + 'product_type': self.product_type, + 'analysed_period_start': self.analysed_period_start, + 'analysed_period_end': self.analysed_period_end, + 'absolute_qty': self.absolute_qty, + 'category': self.category, + 'sale_team': self.sale_team + } + pivot_data = self.env['low.sale.pivot.view.report'].get_data( + low_sale_report) + if not pivot_data: + raise ValidationError( + _("No data was found for the specified criteria")) + pivot_records = [] + for data in pivot_data: + values = { + 'price_total': data[2], + 'product_uom_qty': data[1] + } + if self.product_type == 'variant': + values['product_id'] = data[0] + view_id = self.env.ref( + 'low_sale_report.' + 'low_sale_pivot_view_report_view_pivot_variant').id + else: + values['product_tmpl_id'] = data[0] + view_id = self.env.ref( + 'low_sale_report.' + 'low_sale_pivot_view_report_view_pivot_template').id + pivot_data_records = self.env['low.sale.pivot.view.report'].create( + values) + pivot_records.append(pivot_data_records.id) + return { + 'name': 'Low Sale Pivot View Report', + 'type': 'ir.actions.act_window', + 'res_model': 'low.sale.pivot.view.report', + 'view_mode': 'pivot', + 'view_id': view_id, + 'domain': [('id', 'in', pivot_records)], + } + + def action_excel_low_sale_report(self): + """Exporting the low sale report as the Excel view format in odoo""" + self.ensure_one() + data = {'ids': self.env.context.get('active_ids', []), + 'model': self.env.context.get('active_model', 'ir.ui.menu'), + 'form': self.read( + ['product_type', 'analysed_period_start', + 'analysed_period_end', 'absolute_qty', + 'category', 'sale_team'])[0]} + return { + 'type': 'ir.actions.report', + 'data': {'model': 'low.sale.report', + 'options': json.dumps(data, default=json_default), + 'output_format': 'xlsx', + 'report_name': 'Low Sale Report', + }, + 'report_type': 'low_sale_xlsx_download' + } + + def get_low_sale_xlsx_report(self, options, response): + """Generate the Excel report based on the provided options and write it + to the response.""" + output = io.BytesIO() + workbook = xlsxwriter.Workbook(output, {'in_memory': True}) + data = {'form': options['form'], 'model': 'ir.ui.menu', 'ids': []} + data['form']['used_context'] = { + 'product_type': options['form']['product_type'], + 'analysed_period_start': options['form']['analysed_period_start'], + 'analysed_period_end': options['form']['analysed_period_end'], + 'absolute_qty': options['form']['absolute_qty'], + 'active_model': None, + 'active_ids': None, + 'active_id': None, + 'category': options['form']['category'], + 'sale_team': options['form']['sale_team'], + } + form_data = data['form'] + fetch_datas = self.env['low.sale.pivot.view.report'].get_data(form_data) + if not fetch_datas: + raise ValidationError( + _("No data was found for the specified criteria.")) + worksheet = workbook.add_worksheet() + name_formate = workbook.add_format( + {'bold': True, 'align': 'center', 'valign': 'vcenter', 'border': 1, + 'bg_color': '#D3D3D3', 'font_size': 16}) + format2 = workbook.add_format( + {'font_size': 12, 'bold': True, 'bg_color': '#D3D3D3'}) + rows = 0 + cols = 0 + worksheet.merge_range(rows, cols, rows + 1, cols + 3, + 'Low Sale Report', name_formate) + worksheet.set_column('B:B', 35) + worksheet.set_column('C:C', 15) + worksheet.set_column('D:D', 15) + worksheet.write('A4', "ID", format2) + worksheet.write('B4', "Product", format2) + worksheet.write('C4', "Sold Quantity", format2) + worksheet.write('D4', "Revenue", format2) + # Write data to the worksheet + row_num = 5 + cols_num = 0 + for rec in fetch_datas: + worksheet.write(row_num, cols_num, rec[0]) + worksheet.write(row_num, cols_num + 1, rec[3]) + worksheet.write(row_num, cols_num + 2, rec[1]) + worksheet.write(row_num, cols_num + 3, rec[2]) + row_num += 1 + # Close the workbook + workbook.close() + # Seek to the beginning of the BytesIO buffer + output.seek(0) + # Stream the Excel file to the response + response.stream.write(output.read()) + output.close() + + @api.model + def default_get(self, fields): + """Prefilling the wizard data into the settings field values""" + res = super().default_get(fields) + # Fetch configuration parameters from ResConfigSettings + config_params = self.env['ir.config_parameter'].sudo() + # Prefill the values based on the configuration parameters + res['product_type'] = config_params.get_param( + 'low_sale_report.product_type', default='variant') + res['absolute_qty'] = config_params.get_param( + 'low_sale_report.absolute_qty', default=0.0) + end_date = res.get('analysed_period_end') + if end_date: + if (config_params.get_param('low_sale_report.analysed_period') == + 'last_month'): + start_date = end_date - relativedelta(days=30) + elif (config_params.get_param('low_sale_report.analysed_period') == + 'last_3'): + start_date = end_date - relativedelta(months=3) + elif (config_params.get_param('low_sale_report.analysed_period') == + 'last_6'): + start_date = end_date - relativedelta(months=6) + elif (config_params.get_param('low_sale_report.analysed_period') == + 'last_12'): + start_date = end_date - relativedelta(months=12) + else: + # Default to last_month if no valid option is selected + start_date = end_date - relativedelta(months=12) + res['analysed_period_start'] = start_date + return res diff --git a/low_sale_report/wizard/low_sale_report_views.xml b/low_sale_report/wizard/low_sale_report_views.xml new file mode 100644 index 000000000..377913a71 --- /dev/null +++ b/low_sale_report/wizard/low_sale_report_views.xml @@ -0,0 +1,51 @@ + + + + + low.sale.report.view.form + low.sale.report + +
+ + + + + + + + + +
+
+
+
+
+ + + Low Sale Report + ir.actions.act_window + low.sale.report + form + new + + + +