@ -0,0 +1,48 @@ |
|||||
|
.. image:: https://img.shields.io/badge/license-LGPL--3-green.svg |
||||
|
:target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html |
||||
|
:alt: License: LGPL-3 |
||||
|
|
||||
|
Advanced POS Reports |
||||
|
==================== |
||||
|
* Generates Various Reports From POS Screen and From Reporting Menu. |
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
* No additional configuration required |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
||||
|
|
||||
|
License |
||||
|
------- |
||||
|
Lesser General Public License, Version 3 (LGPL-3). |
||||
|
(https://www.gnu.org/licenses/lgpl-3.0-standalone.html) |
||||
|
|
||||
|
Credits |
||||
|
------- |
||||
|
* Developer: (V17) Ashwin A, |
||||
|
(V18) Busthana Shirin |
||||
|
* 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 |
||||
|
========== |
||||
|
.. 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>`__ |
@ -0,0 +1,24 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from . import models |
||||
|
from . import report |
||||
|
from . import wizard |
@ -0,0 +1,96 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
{ |
||||
|
'name': 'Advanced POS Reports', |
||||
|
'version': '18.0.1.0.0', |
||||
|
'category': 'Point of Sale', |
||||
|
'summary': """Generates various reports from POS screen and reporting |
||||
|
menu""", |
||||
|
'description': """Generates various reports like, top |
||||
|
selling products / categories / customers report, ongoing sessions report |
||||
|
under reporting menu.""", |
||||
|
'author': 'Cybrosys Techno Solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer': 'Cybrosys Techno Solutions', |
||||
|
'website': 'https://www.cybrosys.com', |
||||
|
'depends': ['point_of_sale'], |
||||
|
'data': [ |
||||
|
'security/ir.model.access.csv', |
||||
|
'wizard/advanced_pos_reports_wizard.xml', |
||||
|
'wizard/pos_sale_ongoing_views.xml', |
||||
|
'wizard/pos_sale_top_selling_views.xml', |
||||
|
'report/advanced_pos_reports.xml', |
||||
|
'report/pos_ongoing_session_templates.xml', |
||||
|
'report/pos_top_selling_categories_templates.xml', |
||||
|
'report/pos_top_selling_customers_templates.xml', |
||||
|
'report/pos_top_selling_products_templates.xml', |
||||
|
], |
||||
|
'assets': { |
||||
|
'point_of_sale._assets_pos': [ |
||||
|
'advanced_pos_reports/static/src/js/Category.js', |
||||
|
'advanced_pos_reports/static/src/js/CategoryPopup.js', |
||||
|
'advanced_pos_reports/static/src/js/CategoryReceipt.js', |
||||
|
'advanced_pos_reports/static/src/js/CategoryReceiptPopup.js', |
||||
|
'advanced_pos_reports/static/src/xml/Category_templates.xml', |
||||
|
'advanced_pos_reports/static/src/xml/CategoryPopup_templates.xml', |
||||
|
'advanced_pos_reports/static/src/xml/CategoryReceipt_templates.xml', |
||||
|
'advanced_pos_reports/static/src/xml/CategoryReceiptPopup_templates.xml', |
||||
|
'advanced_pos_reports/static/src/js/Location.js', |
||||
|
'advanced_pos_reports/static/src/js/LocationPopup.js', |
||||
|
'advanced_pos_reports/static/src/js/LocationReceipt.js', |
||||
|
'advanced_pos_reports/static/src/js/LocationReceiptPopup.js', |
||||
|
'advanced_pos_reports/static/src/xml/Location_templates.xml', |
||||
|
'advanced_pos_reports/static/src/xml/LocationPopup_templates.xml', |
||||
|
'advanced_pos_reports/static/src/xml/LocationReceipt_templates.xml', |
||||
|
'advanced_pos_reports/static/src/xml/LocationReceiptPopup_templates.xml', |
||||
|
'advanced_pos_reports/static/src/js/Order.js', |
||||
|
'advanced_pos_reports/static/src/js/OrderPopup.js', |
||||
|
'advanced_pos_reports/static/src/js/OrderReceipt.js', |
||||
|
'advanced_pos_reports/static/src/js/OrderReceiptPopup.js', |
||||
|
'advanced_pos_reports/static/src/xml/Order_templates.xml', |
||||
|
'advanced_pos_reports/static/src/xml/OrderPopup_templates.xml', |
||||
|
'advanced_pos_reports/static/src/xml/OrderReceipt_templates.xml', |
||||
|
'advanced_pos_reports/static/src/xml/OrderReceiptPopup_templates.xml', |
||||
|
'advanced_pos_reports/static/src/js/Payment.js', |
||||
|
'advanced_pos_reports/static/src/js/PaymentPopup.js', |
||||
|
'advanced_pos_reports/static/src/js/PaymentReceipt.js', |
||||
|
'advanced_pos_reports/static/src/js/PaymentReceiptPopup.js', |
||||
|
'advanced_pos_reports/static/src/xml/Payment_templates.xml', |
||||
|
'advanced_pos_reports/static/src/xml/PaymentPopup_templates.xml', |
||||
|
'advanced_pos_reports/static/src/xml/PaymentReceipt_templates.xml', |
||||
|
'advanced_pos_reports/static/src/xml/PaymentReceiptPopup_templates.xml', |
||||
|
'advanced_pos_reports/static/src/js/Product.js', |
||||
|
'advanced_pos_reports/static/src/js/ProductPopup.js', |
||||
|
'advanced_pos_reports/static/src/js/ProductReceipt.js', |
||||
|
'advanced_pos_reports/static/src/js/ProductReceiptPopup.js', |
||||
|
'advanced_pos_reports/static/src/xml/Product_templates.xml', |
||||
|
'advanced_pos_reports/static/src/xml/ProductPopup_templates.xml', |
||||
|
'advanced_pos_reports/static/src/xml/ProductReceipt_templates.xml', |
||||
|
'advanced_pos_reports/static/src/xml/ProductReceiptPopup_templates.xml' |
||||
|
], |
||||
|
}, |
||||
|
'images': ['static/description/banner.jpg'], |
||||
|
'license': 'LGPL-3', |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'application': False, |
||||
|
} |
@ -0,0 +1,6 @@ |
|||||
|
## Module <advanced_pos_reports> |
||||
|
|
||||
|
#### 25.10.2024 |
||||
|
#### Version 18.0.1.0.0 |
||||
|
##### ADD |
||||
|
- Initial Commit for Advanced POS Reports |
@ -0,0 +1,24 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from . import pos_config |
||||
|
from . import pos_order |
||||
|
from . import pos_payment |
@ -0,0 +1,70 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from odoo import api, models |
||||
|
|
||||
|
|
||||
|
class PosConfig(models.Model): |
||||
|
"""Inheriting pos config to get location summary""" |
||||
|
_inherit = 'pos.config' |
||||
|
|
||||
|
def get_location_summary(self, location_id): |
||||
|
"""Function to get location details""" |
||||
|
location_quant = self.env['stock.quant'].search( |
||||
|
[('location_id', '=', int(location_id))]) |
||||
|
location_summary = [] |
||||
|
for quant in location_quant.filtered( |
||||
|
lambda x: x.product_id.available_in_pos): |
||||
|
location_summary.append({ |
||||
|
'product_id': quant.product_id.id, |
||||
|
'product': quant.product_id.name, |
||||
|
'quantity': quant.available_quantity, |
||||
|
}) |
||||
|
return location_summary |
||||
|
|
||||
|
|
||||
|
class PosSession(models.Model): |
||||
|
"""Inheriting pos config to get location summary""" |
||||
|
_inherit = 'pos.session' |
||||
|
|
||||
|
@api.model |
||||
|
def _load_pos_data_models(self, config_id): |
||||
|
data = super()._load_pos_data_models(config_id) |
||||
|
data += ['stock.location'] |
||||
|
return data |
||||
|
|
||||
|
|
||||
|
class StockLocation(models.Model): |
||||
|
"""Inheriting pos config to get location summary""" |
||||
|
_inherit = 'stock.location' |
||||
|
|
||||
|
@api.model |
||||
|
def _load_pos_data_fields(self, config_id): |
||||
|
return ['id', 'name'] |
||||
|
|
||||
|
def _load_pos_data(self, data): |
||||
|
fields = self._load_pos_data_fields(data['pos.config']['data'][0]['id']) |
||||
|
domain = [('usage', '=', 'internal')] |
||||
|
return { |
||||
|
'data': self.search_read(domain, fields, |
||||
|
load=False) if domain is not False else [], |
||||
|
'fields': fields, |
||||
|
} |
@ -0,0 +1,72 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from odoo import models |
||||
|
|
||||
|
|
||||
|
class PosOrder(models.Model): |
||||
|
"""Get details from pos order""" |
||||
|
_inherit = 'pos.order' |
||||
|
|
||||
|
def get_category_summary(self, order_ids): |
||||
|
"""Function to get category details""" |
||||
|
categories = [] |
||||
|
if order_ids: |
||||
|
self.env.cr.execute("""SELECT category.name,category.id, sum(price_subtotal_incl) as amount, sum(qty) as qty |
||||
|
FROM pos_order_line AS line |
||||
|
INNER JOIN product_product AS product ON line.product_id = product.id |
||||
|
INNER JOIN product_template AS template ON product.product_tmpl_id = template.id |
||||
|
INNER JOIN pos_category_product_template_rel as categ ON product.product_tmpl_id = categ.product_template_id |
||||
|
INNER JOIN pos_category AS category ON categ.pos_category_id = category.id WHERE line.order_id IN %s GROUP BY category.name,category.id """, |
||||
|
(tuple(order_ids),)) |
||||
|
categories = self.env.cr.dictfetchall() |
||||
|
return categories |
||||
|
|
||||
|
def get_product_summary(self, order_ids): |
||||
|
"""Function to get product details""" |
||||
|
product_summary = [] |
||||
|
if order_ids: |
||||
|
self.env.cr.execute(""" |
||||
|
SELECT product.id, template.name, product.default_code as code, |
||||
|
sum(qty) as qty |
||||
|
FROM product_product AS product, |
||||
|
pos_order_line AS line, product_template AS template |
||||
|
WHERE product.id = line.product_id AND |
||||
|
template.id = product.product_tmpl_id |
||||
|
AND line.order_id IN %s |
||||
|
GROUP BY product.id, template.name, template.default_code |
||||
|
""", (tuple(order_ids),)) |
||||
|
product_summary = self.env.cr.dictfetchall() |
||||
|
return product_summary |
||||
|
|
||||
|
def get_order_summary(self, order_ids): |
||||
|
"""Function to get order details""" |
||||
|
orders = self.env["pos.order"].browse(order_ids) |
||||
|
order_summary = [] |
||||
|
for order in orders: |
||||
|
order_summary.append( |
||||
|
{'order_name': order.name, |
||||
|
'state': dict(self._fields['state'].selection).get( |
||||
|
order.state), |
||||
|
'date_order': order.date_order.date(), |
||||
|
'amount_total': order.amount_total, |
||||
|
'id': order.id}) |
||||
|
return order_summary |
@ -0,0 +1,42 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from odoo import models |
||||
|
|
||||
|
|
||||
|
class PosPayment(models.Model): |
||||
|
"""Get payment details of pos session""" |
||||
|
_inherit = 'pos.payment' |
||||
|
|
||||
|
def get_payment_summary(self, order_ids): |
||||
|
"""Function to get payment details""" |
||||
|
payments_summary = [] |
||||
|
if order_ids: |
||||
|
self.env.cr.execute(""" |
||||
|
SELECT method.name,method.id, sum(amount) total |
||||
|
FROM pos_payment AS payment, |
||||
|
pos_payment_method AS method |
||||
|
WHERE payment.payment_method_id = method.id |
||||
|
AND payment.id IN %s |
||||
|
GROUP BY method.name,method.id |
||||
|
""", (tuple(order_ids),)) |
||||
|
payments_summary = self.env.cr.dictfetchall() |
||||
|
return payments_summary |
@ -0,0 +1,25 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from . import pos_ongoing_session_report |
||||
|
from . import pos_top_selling_categories_report |
||||
|
from . import pos_top_selling_customers_report |
||||
|
from . import pos_top_selling_products_report |
@ -0,0 +1,31 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<odoo> |
||||
|
<!-- Action for pos ongoing sessions report --> |
||||
|
<record id="pos_ongoing_session_report" model="ir.actions.report"> |
||||
|
<field name="name">Ongoing Sessions</field> |
||||
|
<field name="model">report.advanced_pos_reports.report_pos_ongoing_session</field> |
||||
|
<field name="report_type">qweb-pdf</field> |
||||
|
<field name="report_name">advanced_pos_reports.report_pos_ongoing_session</field> |
||||
|
</record> |
||||
|
<!-- Action for pos top-selling products report--> |
||||
|
<record id="pos_top_selling_products_report" model="ir.actions.report"> |
||||
|
<field name="name">Top Selling Products Report</field> |
||||
|
<field name="model">report.advanced_pos_reports.report_pos_top_selling_products</field> |
||||
|
<field name="report_type">qweb-pdf</field> |
||||
|
<field name="report_name">advanced_pos_reports.report_pos_top_selling_products</field> |
||||
|
</record> |
||||
|
<!-- Action for pos top-selling categories report--> |
||||
|
<record id="pos_top_selling_category_report" model="ir.actions.report"> |
||||
|
<field name="name">Top Selling Categories Report</field> |
||||
|
<field name="model">report.advanced_pos_reports.report_pos_top_selling_categories</field> |
||||
|
<field name="report_type">qweb-pdf</field> |
||||
|
<field name="report_name">advanced_pos_reports.report_pos_top_selling_categories</field> |
||||
|
</record> |
||||
|
<!-- Action for pos top-selling customers report--> |
||||
|
<record id="pos_top_selling_customer_report" model="ir.actions.report"> |
||||
|
<field name="name">Top Selling Customers Report</field> |
||||
|
<field name="model">report.advanced_pos_reports.report_pos_top_selling_customers</field> |
||||
|
<field name="report_type">qweb-pdf</field> |
||||
|
<field name="report_name">advanced_pos_reports.report_pos_top_selling_customers</field> |
||||
|
</record> |
||||
|
</odoo> |
@ -0,0 +1,110 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from odoo import api, fields, models |
||||
|
|
||||
|
|
||||
|
class ReportPosOngoingSession(models.AbstractModel): |
||||
|
"""Generate ongoing session report of pos""" |
||||
|
_name = 'report.advanced_pos_reports.report_pos_ongoing_session' |
||||
|
_description = "Ongoing POS Session Report" |
||||
|
|
||||
|
def get_ongoing_sessions_details(self, session_ids=False): |
||||
|
"""Function to get ongoing session details""" |
||||
|
if session_ids: |
||||
|
sessions = self.env['pos.session'].search( |
||||
|
[('state', '=', 'opened'), |
||||
|
('id', 'in', session_ids)]) |
||||
|
amount_total_without_tax = 0 |
||||
|
amount_total_tax = 0 |
||||
|
amount_total_return = 0 |
||||
|
orders = [] |
||||
|
for session in sessions: |
||||
|
for order in session.order_ids.filtered( |
||||
|
lambda x: x.state in ['paid', 'done', 'invoiced']): |
||||
|
orders.append(order.id) |
||||
|
currency = order.currency_id |
||||
|
amount_tax = currency.round(sum( |
||||
|
order._amount_line_tax(line, order.fiscal_position_id) |
||||
|
for line in order.lines)) |
||||
|
amount_untaxed = currency.round( |
||||
|
sum(line.price_subtotal for line in order.lines)) |
||||
|
amount_return = sum( |
||||
|
payment.amount < 0 and payment.amount or 0 for payment |
||||
|
in |
||||
|
order.payment_ids) |
||||
|
amount_total_without_tax += amount_untaxed |
||||
|
amount_total_tax += amount_tax |
||||
|
amount_total_return += amount_return |
||||
|
order_ids = self.env["pos.order"].browse(orders) |
||||
|
user_currency = self.env.company.currency_id |
||||
|
total = 0.0 |
||||
|
for order in order_ids: |
||||
|
if user_currency != order.pricelist_id.currency_id: |
||||
|
total += order.pricelist_id.currency_id._convert( |
||||
|
order.amount_total, user_currency, order.company_id, |
||||
|
order.date_order or fields.Date.today()) |
||||
|
else: |
||||
|
total += order.amount_total |
||||
|
categories = [] |
||||
|
if order_ids: |
||||
|
self.env.cr.execute(""" |
||||
|
SELECT category.name, sum(price_subtotal_incl) as amount |
||||
|
FROM pos_order_line AS line |
||||
|
INNER JOIN product_product AS product ON line.product_id = product.id |
||||
|
INNER JOIN product_template AS template ON product.product_tmpl_id = template.id |
||||
|
INNER JOIN pos_category_product_template_rel as categ ON product.product_tmpl_id = categ.product_template_id |
||||
|
INNER JOIN pos_category AS category ON categ.pos_category_id = category.id |
||||
|
WHERE line.order_id IN %s GROUP BY category.name """, (tuple(order_ids.ids),)) |
||||
|
categories = self.env.cr.dictfetchall() |
||||
|
|
||||
|
payment_ids = self.env["pos.payment"].search( |
||||
|
[('pos_order_id', 'in', order_ids.ids)]).ids |
||||
|
if payment_ids: |
||||
|
self.env.cr.execute(""" |
||||
|
SELECT method.name, sum(amount) total |
||||
|
FROM pos_payment AS payment, |
||||
|
pos_payment_method AS method |
||||
|
WHERE payment.payment_method_id = method.id |
||||
|
AND payment.id IN %s |
||||
|
GROUP BY method.name |
||||
|
""", (tuple(payment_ids),)) |
||||
|
payments = self.env.cr.dictfetchall() |
||||
|
else: |
||||
|
payments = [] |
||||
|
return { |
||||
|
'sessions': sessions, |
||||
|
'categories': categories, |
||||
|
'today': fields.Datetime.now(), |
||||
|
'total_paid': user_currency.round(total), |
||||
|
'amount_total_without_tax': amount_total_without_tax, |
||||
|
'amount_total_tax': amount_total_tax, |
||||
|
'amount_return': amount_total_return, |
||||
|
'amount_total': total, |
||||
|
'payments': payments |
||||
|
} |
||||
|
|
||||
|
@api.model |
||||
|
def _get_report_values(self, docids, data=None): |
||||
|
"""Get ongoing session report values""" |
||||
|
data = dict(data or {}) |
||||
|
data.update(self.get_ongoing_sessions_details(data['session_ids'])) |
||||
|
return data |
@ -0,0 +1,134 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8" ?> |
||||
|
<odoo> |
||||
|
<!-- Template for ongoing session report--> |
||||
|
<template id="report_pos_ongoing_session"> |
||||
|
<t t-call="web.html_container"> |
||||
|
<t t-call="web.external_layout"> |
||||
|
<div class="page"> |
||||
|
<div class="text-center"> |
||||
|
<h2>Ongoing Sessions Report</h2> |
||||
|
</div> |
||||
|
<table class="table table-lg"> |
||||
|
<tbody> |
||||
|
<tr> |
||||
|
<td>Report Date:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="today" |
||||
|
t-options='{"widget": "date"}'/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>Report Time:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="today" |
||||
|
t-options='{"widget": "datetime", "time_only": True}'/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>Session(s):</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-foreach="sessions" t-as="session"> |
||||
|
<t t-esc="session.name"/> |
||||
|
</t> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>Status:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
Opened |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>Opening Balance:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="sum(sessions.mapped('cash_register_balance_start'))" |
||||
|
t-options="{'widget': 'float', 'precision': currency_precision}"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>Sales Without Tax:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="amount_total_without_tax" |
||||
|
t-options="{'widget': 'float', 'precision': currency_precision}"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>Tax:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="amount_total_tax" |
||||
|
t-options="{'widget': 'float', 'precision': currency_precision}"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>Returns:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="amount_return" |
||||
|
t-options="{'widget': 'float', 'precision': currency_precision}"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>Total:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="amount_total" |
||||
|
t-options="{'widget': 'float', 'precision': currency_precision}"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
<center> |
||||
|
<h3>Department Sales</h3> |
||||
|
</center> |
||||
|
<table class="table table-lg"> |
||||
|
<tbody> |
||||
|
<t t-set="total" t-value="0"/> |
||||
|
<tr t-foreach='categories' t-as='category'> |
||||
|
<td> |
||||
|
<t t-esc="category['name']['en_US']"/> |
||||
|
</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="category['amount']" |
||||
|
t-options="{'widget': 'float', 'precision': currency_precision}"/> |
||||
|
</td> |
||||
|
<t t-set="total" |
||||
|
t-value="total + category['amount']"/> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>Total</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="total" |
||||
|
t-options="{'widget': 'float', 'precision': currency_precision}"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
<center> |
||||
|
<h3>Payments</h3> |
||||
|
</center> |
||||
|
<table class="table table-sm"> |
||||
|
<tbody> |
||||
|
<t t-set="total" t-value="0"/> |
||||
|
<tr t-foreach='payments' t-as='payment'> |
||||
|
<td> |
||||
|
<t t-esc="payment['name']['en_US']"/> |
||||
|
</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="payment['total']" |
||||
|
t-options="{'widget': 'float', 'precision': currency_precision}"/> |
||||
|
</td> |
||||
|
<t t-set="total" |
||||
|
t-value="total + payment['total']"/> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>Total</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="total" |
||||
|
t-options="{'widget': 'float', 'precision': currency_precision}"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
</t> |
||||
|
</t> |
||||
|
</template> |
||||
|
</odoo> |
@ -0,0 +1,69 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from odoo import api, fields, models |
||||
|
|
||||
|
|
||||
|
class ReportPosTopSellingCategories(models.AbstractModel): |
||||
|
"""Generate top_selling categories report""" |
||||
|
_name = 'report.advanced_pos_reports.report_pos_top_selling_categories' |
||||
|
_description = "Report for Top Selling POS Categories" |
||||
|
|
||||
|
def get_top_selling_categories_details(self, no_of_categories=None, |
||||
|
start_date=False, end_date=False): |
||||
|
"""Get top_selling categories details""" |
||||
|
order_ids = self.env["pos.order"].search( |
||||
|
[('date_order', '>=', start_date), |
||||
|
('date_order', '<=', end_date), |
||||
|
('state', 'in', ['paid', 'done', 'invoiced'])]) |
||||
|
if order_ids: |
||||
|
query = """ |
||||
|
SELECT category.name, sum(price_subtotal_incl) as amount |
||||
|
FROM pos_order_line AS line |
||||
|
INNER JOIN product_product AS product ON line.product_id = product.id |
||||
|
INNER JOIN product_template AS template ON product.product_tmpl_id = template.id |
||||
|
INNER JOIN pos_category_product_template_rel as categ ON product.product_tmpl_id = categ.product_template_id |
||||
|
INNER JOIN pos_category AS category ON categ.pos_category_id = category.id WHERE line.order_id IN %s GROUP BY category.name ORDER BY amount DESC |
||||
|
""" |
||||
|
|
||||
|
if no_of_categories > 0: |
||||
|
query += " LIMIT %s" |
||||
|
self.env.cr.execute(query, |
||||
|
(tuple(order_ids.ids), no_of_categories)) |
||||
|
else: |
||||
|
self.env.cr.execute(query, (tuple(order_ids.ids),)) |
||||
|
categories = self.env.cr.dictfetchall() |
||||
|
return { |
||||
|
'categories': categories or [], |
||||
|
'today': fields.Datetime.now(), |
||||
|
'start_date': start_date, |
||||
|
'end_date': end_date |
||||
|
} |
||||
|
|
||||
|
@api.model |
||||
|
def _get_report_values(self, docids, data=None): |
||||
|
"""Get report values""" |
||||
|
data = dict(data or {}) |
||||
|
data.update( |
||||
|
self.get_top_selling_categories_details(data['no_of_categories'], |
||||
|
data['start_date'], |
||||
|
data['end_date'])) |
||||
|
return data |
@ -0,0 +1,65 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<!-- Template for top_selling categories report of pos--> |
||||
|
<template id="report_pos_top_selling_categories"> |
||||
|
<t t-call="web.html_container"> |
||||
|
<t t-call="web.external_layout"> |
||||
|
<div class="page"> |
||||
|
<div class="text-center"> |
||||
|
<h2>Top Selling Categories</h2> |
||||
|
</div> |
||||
|
<table class="table table-lg"> |
||||
|
<tbody> |
||||
|
<tr> |
||||
|
<td>Report Date:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="today" |
||||
|
t-options='{"widget": "date"}'/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>Report Time:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="today" |
||||
|
t-options='{"widget": "datetime", "time_only": True}'/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>Start Date:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="start_date"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>End Date:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="end_date"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
<br/> |
||||
|
<table class="table table-lg"> |
||||
|
<thead> |
||||
|
<th>Category</th> |
||||
|
<th style="text-align: right;">Total</th> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<tr t-foreach="categories" t-as="category"> |
||||
|
<td> |
||||
|
<t t-esc="category['name']['en_US']"/> |
||||
|
</td> |
||||
|
|
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="category['amount']"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<br/> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
<br/> |
||||
|
</div> |
||||
|
</t> |
||||
|
</t> |
||||
|
</template> |
||||
|
</odoo> |
@ -0,0 +1,66 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from odoo import api, fields, models |
||||
|
|
||||
|
|
||||
|
class ReportPosTopSellingCustomers(models.AbstractModel): |
||||
|
"""Generate top_selling customers report of pos""" |
||||
|
_name = 'report.advanced_pos_reports.report_pos_top_selling_customers' |
||||
|
_description = "Report for Top Selling POS Customers" |
||||
|
|
||||
|
def get_top_selling_customers_details(self, no_of_customers=None, |
||||
|
start_date=False, end_date=False): |
||||
|
"""Get top_selling customers details""" |
||||
|
order_ids = self.env["pos.order"].search([ |
||||
|
('date_order', '>=', start_date), |
||||
|
('date_order', '<=', end_date), |
||||
|
('state', 'in', ['paid', 'done', 'invoiced'])]) |
||||
|
if order_ids: |
||||
|
query = """ |
||||
|
SELECT partner.id, partner.name, |
||||
|
sum(amount_total) as amount FROM pos_order, |
||||
|
res_partner AS partner |
||||
|
WHERE partner.id= pos_order.partner_id AND |
||||
|
pos_order.id IN %s GROUP BY partner.id, partner.name |
||||
|
ORDER BY amount DESC |
||||
|
""" |
||||
|
if no_of_customers > 0: |
||||
|
query += " LIMIT %s" |
||||
|
self.env.cr.execute(query, |
||||
|
(tuple(order_ids.ids), no_of_customers)) |
||||
|
else: |
||||
|
self.env.cr.execute(query, (tuple(order_ids.ids),)) |
||||
|
customers = self.env.cr.dictfetchall() |
||||
|
return { |
||||
|
'customers': customers or [], |
||||
|
'today': fields.Datetime.now(), |
||||
|
'start_date': start_date, |
||||
|
'end_date': end_date |
||||
|
} |
||||
|
|
||||
|
@api.model |
||||
|
def _get_report_values(self, docids, data=None): |
||||
|
"""Get report values""" |
||||
|
data = dict(data or {}) |
||||
|
data.update(self.get_top_selling_customers_details( |
||||
|
data['no_of_customers'], data['start_date'], data['end_date'])) |
||||
|
return data |
@ -0,0 +1,64 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<!-- Template for top_selling customers report of pos--> |
||||
|
<template id="report_pos_top_selling_customers"> |
||||
|
<t t-call="web.html_container"> |
||||
|
<t t-call="web.external_layout"> |
||||
|
<div class="page"> |
||||
|
<div class="text-center"> |
||||
|
<h2>Top Customers</h2> |
||||
|
</div> |
||||
|
<table class="table table-lg"> |
||||
|
<tbody> |
||||
|
<tr> |
||||
|
<td>Report Date:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="today" |
||||
|
t-options='{"widget": "date"}'/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>Report Time:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="today" |
||||
|
t-options='{"widget": "datetime", "time_only": True}'/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>Start Date:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="start_date"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>End Date:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="end_date"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
<br/> |
||||
|
<table class="table table-lg"> |
||||
|
<thead> |
||||
|
<th>Customer</th> |
||||
|
<th style="text-align: right;">Amount</th> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<tr t-foreach="customers" t-as="customer"> |
||||
|
<td> |
||||
|
<t t-esc="customer['name']"/> |
||||
|
</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="customer['amount']"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<br/> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
<br/> |
||||
|
</div> |
||||
|
</t> |
||||
|
</t> |
||||
|
</template> |
||||
|
</odoo> |
@ -0,0 +1,76 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from odoo import api, fields, models |
||||
|
|
||||
|
|
||||
|
class ReportPosTopSellingProducts(models.AbstractModel): |
||||
|
"""Generate top_selling products from pos""" |
||||
|
_name = 'report.advanced_pos_reports.report_pos_top_selling_products' |
||||
|
_description = "Report for POS Top Selling Products" |
||||
|
|
||||
|
def get_top_selling_products_details(self, |
||||
|
no_of_products=None, |
||||
|
start_date=False, end_date=False): |
||||
|
"""Get top_selling products details""" |
||||
|
order_ids = self.env["pos.order"].search( |
||||
|
[('date_order', '>=', start_date), |
||||
|
('date_order', '<=', end_date), |
||||
|
('state', 'in', ['paid', 'done', 'invoiced'])]) |
||||
|
|
||||
|
if order_ids: |
||||
|
query = """ |
||||
|
SELECT product.id, template.name, uom.name AS uom, |
||||
|
product.default_code as code, sum(qty) as qty, |
||||
|
sum(line.price_subtotal_incl) as total FROM |
||||
|
product_product AS product, pos_order_line AS line, |
||||
|
product_template AS template , uom_uom AS uom WHERE |
||||
|
product.id = line.product_id AND |
||||
|
template.id = product.product_tmpl_id AND |
||||
|
uom.id = template.uom_id AND line.order_id IN %s |
||||
|
GROUP BY product.id, template.name, |
||||
|
template.default_code, uom.name ORDER BY qty DESC |
||||
|
""" |
||||
|
if no_of_products > 0: |
||||
|
query += " LIMIT %s" |
||||
|
self.env.cr.execute(query, |
||||
|
(tuple(order_ids.ids), no_of_products)) |
||||
|
else: |
||||
|
self.env.cr.execute(query, (tuple(order_ids.ids),)) |
||||
|
|
||||
|
product_summary = self.env.cr.dictfetchall() |
||||
|
|
||||
|
return { |
||||
|
'products': product_summary, |
||||
|
'today': fields.Datetime.now(), |
||||
|
'start_date': start_date, |
||||
|
'end_date': end_date |
||||
|
} |
||||
|
|
||||
|
@api.model |
||||
|
def _get_report_values(self, docids, data=None): |
||||
|
"""Get report values""" |
||||
|
data = dict(data or {}) |
||||
|
data.update( |
||||
|
self.get_top_selling_products_details(data['no_of_products'], |
||||
|
data['start_date'], |
||||
|
data['end_date'])) |
||||
|
return data |
@ -0,0 +1,71 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<!-- Template for top_selling products report of pos--> |
||||
|
<template id="report_pos_top_selling_products"> |
||||
|
<t t-call="web.html_container"> |
||||
|
<t t-call="web.external_layout"> |
||||
|
<div class="page"> |
||||
|
<div class="text-center"> |
||||
|
<h2>Top Selling Products</h2> |
||||
|
</div> |
||||
|
<table class="table table-lg"> |
||||
|
<tbody> |
||||
|
<tr> |
||||
|
<td>Report Date:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="today" |
||||
|
t-options='{"widget": "date"}'/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>Report Time:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="today" |
||||
|
t-options='{"widget": "datetime", "time_only": True}'/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>Start Date:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="start_date"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>End Date:</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="end_date"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
<br/> |
||||
|
<table class="table table-lg"> |
||||
|
<thead> |
||||
|
<th>Product</th> |
||||
|
<th style="text-align: center;">Quantity</th> |
||||
|
<th style="text-align: right;">Unit</th> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<tr t-foreach="products" t-as="product"> |
||||
|
<td> |
||||
|
<t t-if="product['code']">[<t |
||||
|
t-esc="product['code']"/>] |
||||
|
</t> |
||||
|
<t t-esc="product['name']['en_US']"/> |
||||
|
</td> |
||||
|
<td style="text-align: center;"> |
||||
|
<t t-esc="product['qty']"/> |
||||
|
</td> |
||||
|
<td style="text-align: right;"> |
||||
|
<t t-esc="product['uom']['en_US']"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<br/> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
<br/> |
||||
|
</div> |
||||
|
</t> |
||||
|
</t> |
||||
|
</template> |
||||
|
</odoo> |
|
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 738 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 589 B |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 565 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 967 B |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 1.6 KiB |