diff --git a/top_selling_product_report/README.rst b/top_selling_product_report/README.rst new file mode 100644 index 000000000..8a38d42dc --- /dev/null +++ b/top_selling_product_report/README.rst @@ -0,0 +1,17 @@ +Top/Least Selling Product Report v12 +==================================== +Top Selling and Least Selling Product Reports + +Installation +============ + - www.odoo.com/documentation/12.0/setup/install.html + - Install our custom addon + +Configuration +============= + + No additional configurations needed + +Credits +======= + Developer: Ajmal JK @ cybrosys, Contact: odoo@cybrosys.com diff --git a/top_selling_product_report/__init__.py b/top_selling_product_report/__init__.py new file mode 100644 index 000000000..acc7f6ee3 --- /dev/null +++ b/top_selling_product_report/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +from . import wizard +from . import report diff --git a/top_selling_product_report/__manifest__.py b/top_selling_product_report/__manifest__.py new file mode 100644 index 000000000..5d4af6c37 --- /dev/null +++ b/top_selling_product_report/__manifest__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +{ + 'name': 'Top/Least Selling Product Report', + 'version': '12.0.1.0.0', + 'summary': 'Top Selling and Least Selling Product Reports', + 'description': 'Top Selling Products,Fast Moving Products,Most Selling Products,Top Growing Products,Least Selling Products,', + 'author': 'Cybrosys Techno solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'depends': ['base','sale_management','stock','sale'], + 'category': 'Sale', + 'demo': [], + 'data': ['wizard/top_selling_wizard.xml', + 'report/top_selling_report.xml', + 'report/top_selling_report_template.xml'], + 'installable': True, + 'images': ['static/description/banner.png'], + 'qweb': [], + 'license': 'AGPL-3', + 'demo': [], + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/top_selling_product_report/doc/RELEASE_NOTES.md b/top_selling_product_report/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..df45066de --- /dev/null +++ b/top_selling_product_report/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 20.04.2019 +#### Version 12.0.1.0.0 +##### ADD +- Initial commit for Top Selling Product Report diff --git a/top_selling_product_report/report/__init__.py b/top_selling_product_report/report/__init__.py new file mode 100644 index 000000000..a9221e3e5 --- /dev/null +++ b/top_selling_product_report/report/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import top_selling_report diff --git a/top_selling_product_report/report/top_selling_report.py b/top_selling_product_report/report/top_selling_report.py new file mode 100644 index 000000000..2afd9e7e1 --- /dev/null +++ b/top_selling_product_report/report/top_selling_report.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- +from odoo import models +from datetime import timedelta, datetime, date +from dateutil.relativedelta import relativedelta +import dateutil.relativedelta + + +class CustomReport(models.AbstractModel): + _name = "report.top_selling_product_report.top_selling_reports" + + def _get_report_values(self, docids, data=None): + + limit_value = data['period'] if data['period'] else None + date_option = data['date'] + date_selected_from = None + date_selected = None + date_selected_to = None + other_details = {} + + company_id = data['company'] + warehouse_id = data['warehouse'] + + from_date = date.today() - dateutil.relativedelta.relativedelta(years=100) + to_date = date.today() + dateutil.relativedelta.relativedelta(days=1) + + if date_option == 'days': + + from_date = date.today() - dateutil.relativedelta.relativedelta(days=11) + to_date = date.today() + dateutil.relativedelta.relativedelta(days=1) + date_selected = "Last 10 Days" + + elif date_option == 'last_month': + + date_limit = date.today() - dateutil.relativedelta.relativedelta(months=1) + from_date = date_limit.replace(day=1) + to_date = (date_limit + relativedelta(months=1, day=1)) - timedelta(1) + date_selected = "Last Month" + + elif date_option == 'curr_month': + + from_date = date.today().replace(day=1) + to_date = date.today() + dateutil.relativedelta.relativedelta(days=1) + date_selected = "Current Month" + + elif date_option == 'last_year': + + date_limit = date.today() - dateutil.relativedelta.relativedelta(years=1) + from_date = date_limit.replace(day=1) + to_date = (date_limit + relativedelta(months=12, day=1)) - timedelta(1) + date_selected = "Last Year" + + elif date_option == 'curr_year': + + date_limit = date.today() - dateutil.relativedelta.relativedelta(years=1) + from_date = date.today().replace(month=1,day=1) + to_date = date.today() + dateutil.relativedelta.relativedelta(days=1) + date_selected = "Current Year" + + elif date_option == 'select_period': + + from_date = data['from_date'] + to_date = data['to_date'] + date_selected_from = from_date + date_selected_to = to_date + + other_details.update({ + + 'limit': limit_value, + 'least': data['least'], + 'range': date_selected, + 'date_selected_from': date_selected_from, + 'date_selected_to': date_selected_to , + }) + + cr = self._cr + order = 'asc' if data['least'] else 'desc' + company_id = str(tuple(company_id)) if len(company_id) > 1 else "("+str(company_id[0])+")" + warehouse_id = str(tuple(warehouse_id)) if len(warehouse_id) > 1 else "("+str(warehouse_id[0])+")" + limit_clause = " limit'%s'"%limit_value if limit_value else "" + + query = ("""select sl.name as product_name,sum(product_uom_qty),pu.name from sale_order_line sl + JOIN sale_order so ON sl.order_id = so.id + JOIN uom_uom pu on sl.product_uom = pu.id + where so.date_order::DATE >= '%s'::DATE and + so.date_order::DATE <= '%s'::DATE and + sl.state = 'sale' and so.company_id in %s + and so.warehouse_id in %s + group by sl.name,pu.name order by sum %s""" % (from_date, to_date, company_id, warehouse_id, order)) + limit_clause + cr.execute(query) + dat = cr.dictfetchall() + + return{ + 'data': dat, + 'other': other_details, + } + diff --git a/top_selling_product_report/report/top_selling_report.xml b/top_selling_product_report/report/top_selling_report.xml new file mode 100644 index 000000000..cc31fb6d7 --- /dev/null +++ b/top_selling_product_report/report/top_selling_report.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/top_selling_product_report/report/top_selling_report_template.xml b/top_selling_product_report/report/top_selling_report_template.xml new file mode 100644 index 000000000..c64f9c4a9 --- /dev/null +++ b/top_selling_product_report/report/top_selling_report_template.xml @@ -0,0 +1,95 @@ + + + + + + \ No newline at end of file diff --git a/top_selling_product_report/static/description/banner.png b/top_selling_product_report/static/description/banner.png new file mode 100644 index 000000000..1582a676d Binary files /dev/null and b/top_selling_product_report/static/description/banner.png differ diff --git a/top_selling_product_report/static/description/icon.png b/top_selling_product_report/static/description/icon.png new file mode 100644 index 000000000..dfb3f133e Binary files /dev/null and b/top_selling_product_report/static/description/icon.png differ diff --git a/top_selling_product_report/static/description/index.html b/top_selling_product_report/static/description/index.html new file mode 100644 index 000000000..c9147305c --- /dev/null +++ b/top_selling_product_report/static/description/index.html @@ -0,0 +1,359 @@ + +
+
+

+ Top/Least Selling Product Report +

+

+ Top Selling and Least Selling Product Reports +

+
+ Cybrosys Technologies +
+ +
+ cybrosys technologies
+
+
+
+ +
+
+

+ Overview +

+

+ This module helps in generating top selling and least selling product pdf reports. One can generate top/least selling product report + according to the company and warehouse for range of period. +

+
+
+ +
+
+

+ Features +

+

+ + Generates top/least selling product report. +

+

+ + Generates reports for certain time periods. +

+

+ + Report for a range of product. +

+
+
+ +
+
+

+ Screenshots +

+

+       When you install this module, an extra menu named Top/Least Selling Product is created. +

+
+ +
+

+ + Go to Sales --> Reporting --> Top/Least Selling Product.
+       A wizard will be opened once the user clicks on it..
+ + Choose companies and warehouses for generating report.
+ + Select a time period from 'Top Selling product of' selection field.
+ + Select 'Least Selling Product' to generate least selling product report.
+

+
+ +
+

+ +       Click the button Print to least selling product report in PDF format.
+

+
+ +
+

+ + For 'Top selling product report' deselect 'Least Selling Product'.
+       Click the button Print to get top selling product report in PDF format.
+

+
+ +
+
+
+
+
+ cybrosys technologies +
+
+ +
+
+

+ Our Services +

+
+
+ +
+ + + +
+

+ + Odoo Customization + +

+ +
+
+ +
+ + + +
+

+ + Odoo Implementation +

+ +
+
+ +
+ + + +
+

+ + Odoo Integration + +

+ +
+
+ +
+ + + +
+

+ + Odoo Support +

+ +
+
+ +
+ + + +
+

+ + Hire Odoo Developers +

+ +
+
+
+
+
+
+

+ Our Industries +

+
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Trading + +

+

+ Easily procure and sell your products. +

+
+ +
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Manufacturing +

+

+ Plan, track and schedule your operations. +

+
+ +
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Restaurant +

+

+ Run your bar or restaurant methodical. +

+
+ +
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + POS +

+

+ Easy configuring and convivial selling. +

+
+ +
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + E-commerce & Website +

+

+ Mobile friendly, awe-inspiring product pages. +

+
+
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Hotel Management +

+

+ An all-inclusive hotel management application. +

+
+
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Education +

+

+ A Collaborative platform for educational management. +

+
+
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Service Management +

+

+ Keep track of services and invoice accordingly. +

+
+
+
+
+
+
+ +
diff --git a/top_selling_product_report/static/description/top-selling-product-report1.gif b/top_selling_product_report/static/description/top-selling-product-report1.gif new file mode 100644 index 000000000..5f0ffc499 Binary files /dev/null and b/top_selling_product_report/static/description/top-selling-product-report1.gif differ diff --git a/top_selling_product_report/static/description/top-selling-product-report2.jpg b/top_selling_product_report/static/description/top-selling-product-report2.jpg new file mode 100644 index 000000000..03fafbcb4 Binary files /dev/null and b/top_selling_product_report/static/description/top-selling-product-report2.jpg differ diff --git a/top_selling_product_report/static/description/top-selling-product-report3.png b/top_selling_product_report/static/description/top-selling-product-report3.png new file mode 100644 index 000000000..9d1e77189 Binary files /dev/null and b/top_selling_product_report/static/description/top-selling-product-report3.png differ diff --git a/top_selling_product_report/static/description/top-selling-product-report4.png b/top_selling_product_report/static/description/top-selling-product-report4.png new file mode 100644 index 000000000..8b6b514d1 Binary files /dev/null and b/top_selling_product_report/static/description/top-selling-product-report4.png differ diff --git a/top_selling_product_report/wizard/__init__.py b/top_selling_product_report/wizard/__init__.py new file mode 100644 index 000000000..8810af38d --- /dev/null +++ b/top_selling_product_report/wizard/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import top_selling_wizard diff --git a/top_selling_product_report/wizard/top_selling_wizard.py b/top_selling_product_report/wizard/top_selling_wizard.py new file mode 100644 index 000000000..2b24b516b --- /dev/null +++ b/top_selling_product_report/wizard/top_selling_wizard.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +from odoo import fields, api, models + + +class TopSellingWizard(models.TransientModel): + + _name = 'top.selling' + + from_date = fields.Date(string='From') + to_date = fields.Date(string='To') + date = fields.Selection([('days', 'Last 10 Days'), ('curr_month', 'Current Month'), ('last_month', 'Last Month'), + ('curr_year', 'Current Year'), ('last_year', 'Last Year'), ('select_period', 'Select Period')], + string="Top Selling product of", default='days') + period = fields.Char(string="Products Range", help="Enter number of products in report.") + least = fields.Boolean(string="Least Selling Product", default=False) + company = fields.Many2many('res.company', default=lambda self: self.env.user.company_id, string="Company") + warehouse = fields.Many2many('stock.warehouse', string="Warehouse") + + @api.multi + def print_report(self): + + company_id = [] + warehouse_id = [] + + if self.company: + for val in self.company: + company_id.append(val.id) + else: + company = self.env['res.company'].search([]) + for val in company: + company_id.append(val.id) + + if self.warehouse: + for val in self.warehouse: + warehouse_id.append(val.id) + else: + warehouse = self.env['stock.warehouse'].search([]) + for val in warehouse: + warehouse_id.append(val.id) + + data = {'date': self.date, 'period': self.period, 'least': self.least, 'from_date': self.from_date, + 'to_date': self.to_date, 'company': company_id, 'warehouse': warehouse_id} + + return self.env.ref('top_selling_product_report.top_selling_pdf').report_action(self, data=data) diff --git a/top_selling_product_report/wizard/top_selling_wizard.xml b/top_selling_product_report/wizard/top_selling_wizard.xml new file mode 100644 index 000000000..a5d5e5b2f --- /dev/null +++ b/top_selling_product_report/wizard/top_selling_wizard.xml @@ -0,0 +1,51 @@ + + + + + Top/Least Selling Products + top.selling + +
+ + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + Top/Least Selling Products + top.selling + form + form + new + + + +
\ No newline at end of file