diff --git a/product_profit_report/README.rst b/product_profit_report/README.rst new file mode 100644 index 000000000..605190ccb --- /dev/null +++ b/product_profit_report/README.rst @@ -0,0 +1,40 @@ +Product Profit Report v11 +========================= + +Product wise profit report. + +Depends +======= +[sale_management, account_invoicing] addon Odoo + +Tech +==== +* [Python] - Models +* [XML] - Odoo views + +Installation +============ +- www.odoo.com/documentation/11.0/setup/install.html +- Install our custom addon + + +Bug Tracker +=========== +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Credits +======= +* Cybrosys Techno Solutions + +Author +------ + +Developer: Faslu Rahman @ cybrosys, odoo@cybrosys.com + Akhilesh N S @ cybrosys, odoo@cybrosys.com + +Maintainer +---------- + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit https://www.cybrosys.com. diff --git a/product_profit_report/__init__.py b/product_profit_report/__init__.py new file mode 100644 index 000000000..a1e27b033 --- /dev/null +++ b/product_profit_report/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +from . import wizard +from . import models diff --git a/product_profit_report/__manifest__.py b/product_profit_report/__manifest__.py new file mode 100644 index 000000000..1ff70b8a8 --- /dev/null +++ b/product_profit_report/__manifest__.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies(). +# Author: Akhilesh N S & Faslu Rahman +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +{ + 'name': 'Product Profit Report', + 'version': '11.0.1.0.0', + 'summary': 'Product wise profit reposrt', + 'category': 'Accounting', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'depends': [ + 'sale_management', 'account_invoicing', + ], + 'data': [ + 'wizard/product_profit_report_wizard_view.xml', + 'views/product_profit_report_pdf_report.xml', + 'views/product_profit_report_report.xml', + 'security/ir.model.access.csv', + + ], + 'license': 'AGPL-3', + 'images': ['static/description/banner.png'], + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/product_profit_report/doc/RELEASE_NOTES.md b/product_profit_report/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..75b08bdd5 --- /dev/null +++ b/product_profit_report/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 09.04.2019 +#### Version 11.0.1.0.0 +##### ADD +- Initial commit for Product Profit Report. diff --git a/product_profit_report/models/__init__.py b/product_profit_report/models/__init__.py new file mode 100644 index 000000000..e33e036db --- /dev/null +++ b/product_profit_report/models/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import product_profit_report_render_file diff --git a/product_profit_report/models/product_profit_report_render_file.py b/product_profit_report/models/product_profit_report_render_file.py new file mode 100644 index 000000000..3b53a851c --- /dev/null +++ b/product_profit_report/models/product_profit_report_render_file.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- +import datetime +import logging +from odoo import api, models, _ + +_logger = logging.getLogger(__name__) + + +class ReportRender(models.AbstractModel): + _name = 'report.product_profit_report.report_product_profit_report' + _description = 'Product profit Report Render' + + @api.multi + def get_report_values(self, docid, data): + # only for pdf report + model_data = data['form'] + return self.generate_report_values(model_data) + + @api.model + def generate_report_values(self, data): + from_date = data['from_date'] + to_date = data['to_date'] + company = data['company'] + categ_id = data['categ_id'] + product_id = data['product_id'] + domain = [('invoice_id.date_invoice', '>=', from_date), + ('invoice_id.date_invoice', '<=', to_date), + ('invoice_id.state', 'in', ['open', 'paid']), + ('company_id', '=', company[0]), + ('invoice_id.type', 'in', ['out_invoice', 'out_refund'])] + if categ_id: + domain += [('product_id.categ_id.id', '=', categ_id[0])] + if product_id: + domain += [('product_id.id', '=', product_id[0])] + orders = self.env['account.invoice.line'].search(domain, order='name') + groups = {} + for order in orders: + dic_name = str(order.product_id.id) + quantity = order.quantity + price = quantity * (order.price_unit - order.discount) + expense = order.product_id.get_history_price(order.company_id.id, date=order.invoice_id.date_invoice) * quantity + if expense == 0.0: + expense = order.product_id.standard_price * quantity + if order.invoice_id.type == 'out_refund': + quantity = -quantity + price = -price + expense = -expense + profit = price - expense + if not groups.get(dic_name): + groups[dic_name] = {} + groups[dic_name].update({ + 'qty': quantity, + 'unit': order.product_id.uom_id.name, + 'sales': price, + 'expense': expense, + 'profit': profit, + 'name': order.product_id.name + }) + else: + groups[dic_name].update({ + 'qty': groups[dic_name].get('qty') + quantity, + 'sales': groups[dic_name].get('sales') + price, + 'expense': groups[dic_name].get('expense') + expense, + 'profit': groups[dic_name].get('profit') + profit + }) + + return { + 'data': data, + 'groups': groups, + 'report_date': datetime.datetime.now().strftime("%Y-%m-%d"), + } diff --git a/product_profit_report/security/ir.model.access.csv b/product_profit_report/security/ir.model.access.csv new file mode 100644 index 000000000..16e280538 --- /dev/null +++ b/product_profit_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_product_profit_report_manager,product.profit.report,model_product_profit_report_report,account.group_account_manager,1,1,1,1 +access_product_profit_report_user,product.profit.report,model_product_profit_report_report,account.group_account_user,1,0,0,0 diff --git a/product_profit_report/static/description/banner.png b/product_profit_report/static/description/banner.png new file mode 100644 index 000000000..482d27c70 Binary files /dev/null and b/product_profit_report/static/description/banner.png differ diff --git a/product_profit_report/static/description/cybro_logo.png b/product_profit_report/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/product_profit_report/static/description/cybro_logo.png differ diff --git a/product_profit_report/static/description/icon.png b/product_profit_report/static/description/icon.png new file mode 100644 index 000000000..e9d76ea5d Binary files /dev/null and b/product_profit_report/static/description/icon.png differ diff --git a/product_profit_report/static/description/index.html b/product_profit_report/static/description/index.html new file mode 100644 index 000000000..65c6c1322 --- /dev/null +++ b/product_profit_report/static/description/index.html @@ -0,0 +1,324 @@ + +
+
+

+ Product Profit Report +

+

+ Generate Product wise profit report +

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

+ Overview +

+

+ With this module you can generate product wise profit report. It give a clear view of which products and product mixes are cost effective. In addition to managing current results the analysis can refine product pricing strategies +

+
+ +
+ +
+
+

+ Screenshots +

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

+ Our Services +

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

+ + Odoo Support +

+ +
+ +
+
+
+
+
+

+ 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/product_profit_report/static/description/pdf_report.png b/product_profit_report/static/description/pdf_report.png new file mode 100644 index 000000000..e2e0a688b Binary files /dev/null and b/product_profit_report/static/description/pdf_report.png differ diff --git a/product_profit_report/static/description/wizard.png b/product_profit_report/static/description/wizard.png new file mode 100644 index 000000000..d97b810c1 Binary files /dev/null and b/product_profit_report/static/description/wizard.png differ diff --git a/product_profit_report/views/product_profit_report_pdf_report.xml b/product_profit_report/views/product_profit_report_pdf_report.xml new file mode 100644 index 000000000..fc0f7f981 --- /dev/null +++ b/product_profit_report/views/product_profit_report_pdf_report.xml @@ -0,0 +1,100 @@ + + + + diff --git a/product_profit_report/views/product_profit_report_report.xml b/product_profit_report/views/product_profit_report_report.xml new file mode 100644 index 000000000..27fd97d3b --- /dev/null +++ b/product_profit_report/views/product_profit_report_report.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/product_profit_report/wizard/__init__.py b/product_profit_report/wizard/__init__.py new file mode 100644 index 000000000..3616a0fd9 --- /dev/null +++ b/product_profit_report/wizard/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import product_profit_report_wizard diff --git a/product_profit_report/wizard/product_profit_report_wizard.py b/product_profit_report/wizard/product_profit_report_wizard.py new file mode 100644 index 000000000..796407e93 --- /dev/null +++ b/product_profit_report/wizard/product_profit_report_wizard.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +import datetime +from odoo import models, fields, api + + +class ProductProfitReport(models.TransientModel): + _name = "product_profit_report.report" + _description = 'Product Profit Report' + + @api.model + def _get_from_date(self): + company = self.env.user.company_id + current_date = datetime.date.today() + from_date = company.compute_fiscalyear_dates(current_date)['date_from'] + return from_date + + from_date = fields.Date(string='From Date', default=_get_from_date, required=True) + to_date = fields.Date(string='To Date', default=fields.Date.context_today, required=True) + company = fields.Many2one('res.company', string='Company', required=True, + default=lambda self: self.env.user.company_id.id) + categ_id = fields.Many2one('product.category', string='Product Category', required=False) + product_id = fields.Many2one('product.product', string='Product', required=False,) + + @api.onchange('categ_id') + def _onchange_category_products(self): + if self.categ_id: + products = self.env['product.product'].search([('categ_id', '=', self.categ_id.id)]) + return { + 'domain': {'product_id': [('id', 'in', products.ids)]} + } + + def print_pdf_report(self, data): + data = {} + data['form'] = {} + data['form'].update(self.read([])[0]) + return self.env.ref('product_profit_report.action_product_profit_report_pdf').with_context( + landscape=True).report_action(self, data=data) diff --git a/product_profit_report/wizard/product_profit_report_wizard_view.xml b/product_profit_report/wizard/product_profit_report_wizard_view.xml new file mode 100644 index 000000000..6f7627e3a --- /dev/null +++ b/product_profit_report/wizard/product_profit_report_wizard_view.xml @@ -0,0 +1,43 @@ + + + + + Product Profit Report + product_profit_report.report + +
+ + + + + + + + + + + + + +
+
+
+
+
+ + + Product Profit Report + product_profit_report.report + ir.actions.act_window + form + form + + new + + + + +
\ No newline at end of file