@ -0,0 +1,50 @@ |
|||||
|
.. 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 |
||||
|
|
||||
|
POS All in One Report Generator |
||||
|
=============================== |
||||
|
This module helps to generate reports based on Orders, Order Details, Products, Categories, Salespersons and Payments. |
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
* No additional configuration is needed. |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
||||
|
|
||||
|
License |
||||
|
------- |
||||
|
Affero General Public License, v3.0 (AGPL v3). |
||||
|
(https://www.gnu.org/licenses/agpl-3.0-standalone.html) |
||||
|
|
||||
|
Credits |
||||
|
------- |
||||
|
* Developers : (V15) Sreelakshmi, |
||||
|
(V16) Abhijith, |
||||
|
(V17) Bhagyadev KP, |
||||
|
(V18) Aysha Shalin |
||||
|
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: Aysha Shalin (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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################ |
||||
|
from . import controllers |
||||
|
from . import models |
||||
|
from . import report |
@ -0,0 +1,51 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################ |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################ |
||||
|
{ |
||||
|
'name': 'POS All in One Report Generator', |
||||
|
'version': '18.0.1.0.0', |
||||
|
'category': 'Point of Sale', |
||||
|
'summary': """Dynamic Point Of Sale Reports.""", |
||||
|
'description': """This module helps to generate reports based on Orders, |
||||
|
Order Details, Products, Categories, Salespersons and Payments.""", |
||||
|
'author': 'Cybrosys Techno Solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer': 'Cybrosys Techno Solutions', |
||||
|
'website': 'https://www.cybrosys.com', |
||||
|
'depends': ['point_of_sale', 'stock', 'web'], |
||||
|
'data': [ |
||||
|
'security/ir.model.access.csv', |
||||
|
'report/pos_order_report_templates.xml', |
||||
|
'views/pos_report_menus.xml', |
||||
|
], |
||||
|
'assets': { |
||||
|
'web.assets_backend': [ |
||||
|
'pos_report_generator/static/src/js/PosReport.js', |
||||
|
'pos_report_generator/static/src/xml/PosReport.xml', |
||||
|
'pos_report_generator/static/src/css/pos_report.css', |
||||
|
], |
||||
|
}, |
||||
|
'images': ['static/description/banner.png'], |
||||
|
'license': 'AGPL-3', |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'application': False, |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################ |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################ |
||||
|
from . import pos_report_generator |
@ -0,0 +1,61 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################ |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################ |
||||
|
import json |
||||
|
from odoo import http |
||||
|
from odoo.http import content_disposition, request |
||||
|
from odoo.tools import html_escape |
||||
|
|
||||
|
|
||||
|
class TBXLSXReportController(http.Controller): |
||||
|
@http.route('/pos_dynamic_xlsx_reports', type='http', auth='user', |
||||
|
methods=['POST'], csrf=False) |
||||
|
def get_report_xlsx(self, model, options, output_format, report_data, |
||||
|
report_name, **kw): |
||||
|
""" |
||||
|
Generate an XLSX report based on the provided data and return it as a |
||||
|
response. |
||||
|
""" |
||||
|
uid = request.session.uid |
||||
|
report_obj = request.env[model].with_user(uid) |
||||
|
options = 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_pos_xlsx_report(options, response, report_data) |
||||
|
response.set_cookie('fileToken', token) |
||||
|
return response |
||||
|
except Exception as e: |
||||
|
se = http.serialize_exception(e) |
||||
|
error = { |
||||
|
'code': 200, |
||||
|
'message': 'Odoo Server Error', |
||||
|
'data': se |
||||
|
} |
||||
|
return request.make_response(html_escape(json.dumps(error))) |
@ -0,0 +1,6 @@ |
|||||
|
## Module <pos_report_generator> |
||||
|
|
||||
|
#### 22.10.2024 |
||||
|
#### Version 18.0.1.0.0 |
||||
|
##### ADD |
||||
|
- Initial Commit for POS All in One Report Generator |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################ |
||||
|
from . import pos_report |
@ -0,0 +1,558 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################ |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################ |
||||
|
import io |
||||
|
import json |
||||
|
from odoo import api, fields, models |
||||
|
|
||||
|
try: |
||||
|
from odoo.tools.misc import xlsxwriter |
||||
|
except ImportError: |
||||
|
import xlsxwriter |
||||
|
|
||||
|
|
||||
|
class PosReportGenerator(models.Model): |
||||
|
""" Pos_report generating model """ |
||||
|
_name = "pos.report" |
||||
|
_description = "Model to generate Point of Sale report." |
||||
|
|
||||
|
pos_report = fields.Char(string="PoS Report", help="Point Of Sale Report") |
||||
|
date_from = fields.Datetime(string="Date From", help="Date From") |
||||
|
date_to = fields.Datetime(string="Date to", help="Date To") |
||||
|
report_type = fields.Selection([ |
||||
|
('report_by_order', 'Report By Order'), |
||||
|
('report_by_order_detail', |
||||
|
'Report By Order Detail'), |
||||
|
('report_by_product', 'Report By Product'), |
||||
|
('report_by_categories', |
||||
|
'Report By Categories'), |
||||
|
('report_by_salesman', |
||||
|
'Report By Salesman'), |
||||
|
('report_by_payment', |
||||
|
'Report By Payment')], |
||||
|
help='Select the report', |
||||
|
default='report_by_order') |
||||
|
|
||||
|
@api.model |
||||
|
def pos_report(self, option): |
||||
|
""" |
||||
|
Generate a Point of Sale (POS) report based on the specified option. |
||||
|
""" |
||||
|
report_values = self.env['pos.report'].search([('id', '=', option)]) |
||||
|
data = { |
||||
|
'report_type': report_values.report_type, |
||||
|
'model': self, |
||||
|
} |
||||
|
if report_values.date_from: |
||||
|
data.update({ |
||||
|
'date_from': report_values.date_from, |
||||
|
}) |
||||
|
if report_values.date_to: |
||||
|
data.update({ |
||||
|
'date_to': report_values.date_to, |
||||
|
}) |
||||
|
filters = self.get_filter(option) |
||||
|
lines = self._get_report_values(data).get('POS') |
||||
|
main_line = self._get_report_values(data).get('pos_main') |
||||
|
return { |
||||
|
'name': "PoS Orders", |
||||
|
'type': 'ir.actions.client', |
||||
|
'tag': 'pos_r', |
||||
|
'orders': data, |
||||
|
'filters': filters, |
||||
|
'report_lines': lines, |
||||
|
'report_main_line': main_line, |
||||
|
} |
||||
|
|
||||
|
def get_filter(self, option): |
||||
|
""" |
||||
|
Get filter data for the specified report option and return it as a |
||||
|
dictionary. |
||||
|
""" |
||||
|
data = self.get_filter_data(option) |
||||
|
filters = {} |
||||
|
if data.get('report_type') == 'report_by_order': |
||||
|
filters['report_type'] = 'Report By Order' |
||||
|
elif data.get('report_type') == 'report_by_order_detail': |
||||
|
filters['report_type'] = 'Report By Order Detail' |
||||
|
elif data.get('report_type') == 'report_by_product': |
||||
|
filters['report_type'] = 'Report By Product' |
||||
|
elif data.get('report_type') == 'report_by_categories': |
||||
|
filters['report_type'] = 'Report By Categories' |
||||
|
elif data.get('report_type') == 'report_by_salesman': |
||||
|
filters['report_type'] = 'Report By Salesman' |
||||
|
elif data.get('report_type') == 'report_by_payment': |
||||
|
filters['report_type'] = 'Report By Payment' |
||||
|
else: |
||||
|
filters['report_type'] = 'report_by_order' |
||||
|
return filters |
||||
|
|
||||
|
def get_filter_data(self, option): |
||||
|
""" |
||||
|
Retrieve filter data for the specified report option and return it as a |
||||
|
dictionary. |
||||
|
""" |
||||
|
report = self.env['pos.report'].search([('id', '=', option)]) |
||||
|
default_filters = {} |
||||
|
filter_dict = { |
||||
|
'report_type': report.report_type, |
||||
|
} |
||||
|
filter_dict.update(default_filters) |
||||
|
return filter_dict |
||||
|
|
||||
|
@api.model |
||||
|
def create(self, vals): |
||||
|
""" |
||||
|
Create a new instance of the PosReportGenerator model with the provided |
||||
|
values. |
||||
|
""" |
||||
|
res = super(PosReportGenerator, self).create(vals) |
||||
|
return res |
||||
|
|
||||
|
def write(self, vals): |
||||
|
""" |
||||
|
Update the fields of the current instance of the PosReportGenerator |
||||
|
model with the provided values. |
||||
|
""" |
||||
|
res = super(PosReportGenerator, self).write(vals) |
||||
|
return res |
||||
|
|
||||
|
def _get_report_sub_lines(self, data): |
||||
|
""" |
||||
|
Get report sublines based on the specified report type, date range, |
||||
|
and data. |
||||
|
""" |
||||
|
report_sub_lines = [] |
||||
|
if data.get('report_type') == 'report_by_order': |
||||
|
query = ''' |
||||
|
select l.name,l.date_order,l.partner_id,l.amount_total, |
||||
|
l.general_note,l.user_id,res_partner.name,l.name as shop, |
||||
|
pos_session.name as session, |
||||
|
res_users.partner_id as user_partner, |
||||
|
sum(pos_order_line.qty),l.id as id, |
||||
|
(SELECT res_partner.name as salesman FROM res_partner |
||||
|
WHERE res_partner.id = res_users.partner_id) |
||||
|
from pos_order as l |
||||
|
left join pos_session on l.session_id = pos_session.id |
||||
|
left join res_partner on l.partner_id = res_partner.id |
||||
|
left join res_users on l.user_id = res_users.id |
||||
|
left join pos_order_line on l.id = pos_order_line.order_id |
||||
|
''' |
||||
|
term = 'Where ' |
||||
|
if data.get('date_from'): |
||||
|
query += "Where (l.date_order >= '%s') " % data.get( |
||||
|
'date_from').strftime('%Y-%m-%d 00:00:00') |
||||
|
term = 'AND ' |
||||
|
if data.get('date_to'): |
||||
|
query += term + "(l.date_order <= '%s') " % data.get( |
||||
|
'date_to').strftime('%Y-%m-%d 11:59:59') |
||||
|
query += ("group by l.user_id,res_users.partner_id," |
||||
|
"res_partner.name," |
||||
|
"l.partner_id,l.date_order,pos_session.name,l.session_id," |
||||
|
"l.name,l.amount_total,l.general_note,l.id") |
||||
|
self._cr.execute(query) |
||||
|
report_by_order = self._cr.dictfetchall() |
||||
|
report_sub_lines.append(report_by_order) |
||||
|
elif data.get('report_type') == 'report_by_order_detail': |
||||
|
query = ''' |
||||
|
select l.name,l.date_order,l.partner_id,l.amount_total,l.general_note, |
||||
|
l.user_id,res_partner.name,l.name as shop,pos_session.name as |
||||
|
session, res_users.partner_id as user_partner, |
||||
|
sum(pos_order_line.qty), pos_order_line.full_product_name, |
||||
|
pos_order_line.price_unit,pos_order_line.price_subtotal, |
||||
|
pos_order_line.price_subtotal_incl,pos_order_line.product_id, |
||||
|
product_product.default_code, (SELECT res_partner.name as salesman |
||||
|
FROM res_partner WHERE res_partner.id = res_users.partner_id) |
||||
|
from pos_order as l left join pos_session on l.session_id = |
||||
|
pos_session.id left join res_partner on l.partner_id = |
||||
|
res_partner.id left join res_users on l.user_id = res_users.id left |
||||
|
join pos_order_line on l.id = pos_order_line.order_id left join |
||||
|
product_product on pos_order_line.product_id = product_product.id |
||||
|
''' |
||||
|
term = 'Where ' |
||||
|
if data.get('date_from'): |
||||
|
query += "Where l.date_order >= '%s' " % data.get( |
||||
|
'date_from').strftime('%Y-%m-%d') |
||||
|
term = 'AND ' |
||||
|
if data.get('date_to'): |
||||
|
query += term + "l.date_order <= '%s' " % data.get( |
||||
|
'date_to').strftime('%Y-%m-%d') |
||||
|
query += ("group by l.user_id,res_users.partner_id," |
||||
|
"res_partner.name,l.partner_id,l.date_order," |
||||
|
"pos_session.name,l.session_id,l.name,l.amount_total," |
||||
|
"l.general_note,pos_order_line.full_product_name," |
||||
|
"pos_order_line.price_unit,pos_order_line.price_subtotal," |
||||
|
"pos_order_line.price_subtotal_incl," |
||||
|
"pos_order_line.product_id,product_product.default_code") |
||||
|
self._cr.execute(query) |
||||
|
report_by_order_details = self._cr.dictfetchall() |
||||
|
report_sub_lines.append(report_by_order_details) |
||||
|
elif data.get('report_type') == 'report_by_product': |
||||
|
query = ''' |
||||
|
select l.amount_total,l.amount_paid,sum(pos_order_line.qty) as qty, |
||||
|
pos_order_line.full_product_name, pos_order_line.price_unit, |
||||
|
product_product.default_code,product_category.name |
||||
|
from pos_order as l left join pos_order_line on l.id = |
||||
|
pos_order_line.order_id left join product_product on |
||||
|
pos_order_line.product_id = product_product.id left join |
||||
|
product_template on product_product.product_tmpl_id = product_template.id |
||||
|
join product_category on product_category.id = |
||||
|
product_template.categ_id |
||||
|
''' |
||||
|
term = 'Where ' |
||||
|
if data.get('date_from'): |
||||
|
query += "Where l.date_order >= '%s' " % data.get('date_from') |
||||
|
term = 'AND ' |
||||
|
if data.get('date_to'): |
||||
|
query += term + "l.date_order <= '%s' " % data.get('date_to') |
||||
|
query += ("group by l.amount_total,l.amount_paid," |
||||
|
"pos_order_line.full_product_name," |
||||
|
"pos_order_line.price_unit,pos_order_line.product_id," |
||||
|
"product_product.default_code,product_template.categ_id," |
||||
|
"product_category.name") |
||||
|
self._cr.execute(query) |
||||
|
report_by_product = self._cr.dictfetchall() |
||||
|
report_sub_lines.append(report_by_product) |
||||
|
elif data.get('report_type') == 'report_by_categories': |
||||
|
query = ''' |
||||
|
select product_category.name,sum(l.qty) as qty,sum(l.price_subtotal) |
||||
|
as amount_total,sum(price_subtotal_incl) as total_incl from |
||||
|
pos_order_line as l left join product_template on l.product_id = |
||||
|
product_template.id join product_category on |
||||
|
product_category.id = product_template.categ_id |
||||
|
left join pos_order on l.order_id = pos_order.id |
||||
|
''' |
||||
|
term = 'Where ' |
||||
|
if data.get('date_from'): |
||||
|
query += "Where pos_order.date_order >= '%s' " % data.get( |
||||
|
'date_from') |
||||
|
term = 'AND ' |
||||
|
if data.get('date_to'): |
||||
|
query += term + "pos_order.date_order <= '%s' " % data.get( |
||||
|
'date_to') |
||||
|
query += "group by product_category.name" |
||||
|
self._cr.execute(query) |
||||
|
report_by_categories = self._cr.dictfetchall() |
||||
|
report_sub_lines.append(report_by_categories) |
||||
|
elif data.get('report_type') == 'report_by_salesman': |
||||
|
query = ''' |
||||
|
select res_partner.name,sum(pos_order_line.qty) as qty, |
||||
|
sum(pos_order_line.price_subtotal) as amount,count(l.id) as order |
||||
|
from pos_order as l |
||||
|
left join res_users on l.user_id = res_users.id |
||||
|
left join res_partner on res_users.partner_id = res_partner.id |
||||
|
left join pos_order_line on l.id = pos_order_line.order_id |
||||
|
''' |
||||
|
term = 'Where ' |
||||
|
if data.get('date_from'): |
||||
|
query += "Where l.date_order >= '%s' " % data.get('date_from') |
||||
|
term = 'AND ' |
||||
|
if data.get('date_to'): |
||||
|
query += term + "l.date_order <= '%s' " % data.get('date_to') |
||||
|
query += "group by res_partner.name" |
||||
|
self._cr.execute(query) |
||||
|
report_by_salesman = self._cr.dictfetchall() |
||||
|
report_sub_lines.append(report_by_salesman) |
||||
|
elif data.get('report_type') == 'report_by_payment': |
||||
|
query = ''' |
||||
|
select pos_payment_method.name,sum(l.amount_total),pos_session.name |
||||
|
as session,pos_config.name as config |
||||
|
from pos_order as l |
||||
|
left join pos_payment on l.id = pos_payment.pos_order_id |
||||
|
left join pos_payment_method on pos_payment.payment_method_id = |
||||
|
pos_payment_method.id |
||||
|
left join pos_session on l.session_id = pos_session.id |
||||
|
left join pos_config on pos_session.config_id = pos_config.id |
||||
|
''' |
||||
|
term = 'Where ' |
||||
|
if data.get('date_from'): |
||||
|
query += "Where l.date_order >= '%s' " % data.get('date_from') |
||||
|
term = 'AND ' |
||||
|
if data.get('date_to'): |
||||
|
query += term + "l.date_order <= '%s' " % data.get('date_to') |
||||
|
query += ("group by pos_payment_method.name,pos_session.name," |
||||
|
"pos_config.name") |
||||
|
self._cr.execute(query) |
||||
|
report_by_payment = self._cr.dictfetchall() |
||||
|
report_sub_lines.append(report_by_payment) |
||||
|
return report_sub_lines |
||||
|
|
||||
|
def _get_report_total_value(self, data, report): |
||||
|
""" Get the total value for the specified report type. """ |
||||
|
report_main_lines = [] |
||||
|
if data.get('report_type') == 'report_by_order': |
||||
|
self._cr.execute(''' |
||||
|
select count(l.id) as order,sum(l.amount_total) as amount |
||||
|
from pos_order as l |
||||
|
''') |
||||
|
report_by_order = self._cr.dictfetchall() |
||||
|
report_main_lines.append(report_by_order) |
||||
|
elif data.get('report_type') == 'report_by_order_detail': |
||||
|
self._cr.execute(''' |
||||
|
select count(line.id) as order,sum(line.price_subtotal) |
||||
|
as total,sum(line.price_subtotal_incl) |
||||
|
from pos_order_line as line |
||||
|
''') |
||||
|
report_by_order_detail = self._cr.dictfetchall() |
||||
|
report_main_lines.append(report_by_order_detail) |
||||
|
elif data.get('report_type') == 'report_by_product': |
||||
|
self._cr.execute(''' |
||||
|
select count(l.product_id) as order,sum(l.price_subtotal) as amount |
||||
|
from pos_order_line as l |
||||
|
''') |
||||
|
report_by_product = self._cr.dictfetchall() |
||||
|
report_main_lines.append(report_by_product) |
||||
|
else: |
||||
|
report_main_lines = False |
||||
|
return report_main_lines |
||||
|
|
||||
|
def _get_report_values(self, data): |
||||
|
""" Get report values based on the provided data """ |
||||
|
docs = data['model'] |
||||
|
if data['report_type'] == 'report_by_order_detail': |
||||
|
report = ['Report By Order Detail'] |
||||
|
elif data['report_type'] == 'report_by_product': |
||||
|
report = ['Report By Product'] |
||||
|
elif data['report_type'] == 'report_by_categories': |
||||
|
report = ['Report By Categories'] |
||||
|
elif data['report_type'] == 'report_by_salesman': |
||||
|
report = ['Report By Salesman'] |
||||
|
elif data['report_type'] == 'report_by_payment': |
||||
|
report = ['Report By Payment'] |
||||
|
else: |
||||
|
report = ['Report By Order'] |
||||
|
report_res_total = self._get_report_total_value(data, report) |
||||
|
if data.get('report_type'): |
||||
|
report_res = \ |
||||
|
self._get_report_sub_lines(data)[0] |
||||
|
else: |
||||
|
report_res = self._get_report_sub_lines(data) |
||||
|
if data.get('report_type') == 'report_by_order': |
||||
|
report_res_total = self._get_report_total_value(data, report)[0] |
||||
|
return { |
||||
|
'doc_ids': self.ids, |
||||
|
'docs': docs, |
||||
|
'POS': report_res, |
||||
|
'pos_main': report_res_total, |
||||
|
} |
||||
|
|
||||
|
def get_pos_xlsx_report(self, data, response, report_data): |
||||
|
""" |
||||
|
Generate an Excel report based on the provided data and write it to the |
||||
|
response. |
||||
|
""" |
||||
|
report_data_main = json.loads(report_data) |
||||
|
output = io.BytesIO() |
||||
|
filters = json.loads(data) |
||||
|
workbook = xlsxwriter.Workbook(output, {'in_memory': True}) |
||||
|
sheet = workbook.add_worksheet() |
||||
|
head = workbook.add_format({'align': 'center', 'bold': True, |
||||
|
'font_size': '20px'}) |
||||
|
heading = workbook.add_format( |
||||
|
{'align': 'center', 'bold': True, 'font_size': '10px', |
||||
|
'border': 2, |
||||
|
'border_color': 'black'}) |
||||
|
txt_l = workbook.add_format( |
||||
|
{'font_size': '10px', 'border': 1, 'bold': True}) |
||||
|
sheet.merge_range('A2:H3', |
||||
|
'Point of Sale Report', |
||||
|
head) |
||||
|
if filters.get('report_type') == 'report_by_order': |
||||
|
sheet.merge_range('B5:D5', 'Report Type: ' + |
||||
|
filters.get('report_type'), txt_l) |
||||
|
sheet.write('A7', 'PoS', heading) |
||||
|
sheet.write('B7', 'Order', heading) |
||||
|
sheet.write('C7', 'Date Order', heading) |
||||
|
sheet.write('D7', 'Customer', heading) |
||||
|
sheet.write('E7', 'Salesman', heading) |
||||
|
sheet.write('F7', 'Total Qty', heading) |
||||
|
sheet.write('G7', 'Amount Total', heading) |
||||
|
sheet.write('H7', 'Note', heading) |
||||
|
lst = [] |
||||
|
if report_data_main: |
||||
|
for rec in report_data_main[0]: |
||||
|
lst.append(rec) |
||||
|
row = 6 |
||||
|
col = 0 |
||||
|
sheet.set_column(3, 0, 15) |
||||
|
sheet.set_column(4, 1, 15) |
||||
|
sheet.set_column(5, 2, 15) |
||||
|
sheet.set_column(6, 3, 15) |
||||
|
sheet.set_column(7, 4, 15) |
||||
|
sheet.set_column(8, 5, 15) |
||||
|
sheet.set_column(9, 6, 15) |
||||
|
for rec_data in report_data_main: |
||||
|
row += 1 |
||||
|
sheet.write(row, col, rec_data['shop'], txt_l) |
||||
|
sheet.write(row, col + 1, rec_data['session'], txt_l) |
||||
|
sheet.write(row, col + 2, rec_data['date_order'], txt_l) |
||||
|
sheet.write(row, col + 3, rec_data['name'], txt_l) |
||||
|
sheet.write(row, col + 4, rec_data['salesman'], txt_l) |
||||
|
sheet.write(row, col + 5, rec_data['sum'], txt_l) |
||||
|
sheet.write(row, col + 6, rec_data['amount_total'], txt_l) |
||||
|
sheet.write(row, col + 7, rec_data['general_note'], txt_l) |
||||
|
if filters.get('report_type') == 'report_by_order_detail': |
||||
|
sheet.merge_range('B5:D5', 'Report Type: ' + |
||||
|
filters.get('report_type'), txt_l) |
||||
|
sheet.write('A7', 'PoS', heading) |
||||
|
sheet.write('B7', 'Order', heading) |
||||
|
sheet.write('C7', 'Date Order', heading) |
||||
|
sheet.write('D7', 'Customer', heading) |
||||
|
sheet.write('E7', 'Salesman', heading) |
||||
|
sheet.write('F7', 'Product Code', heading) |
||||
|
sheet.write('G7', 'Product Name', heading) |
||||
|
sheet.write('H7', 'Price unit', heading) |
||||
|
sheet.write('I7', 'Qty', heading) |
||||
|
sheet.write('J7', 'Price Subtotal', heading) |
||||
|
sheet.write('K7', 'Price Subtotal Incl', heading) |
||||
|
lst = [] |
||||
|
if report_data_main: |
||||
|
for rec in report_data_main[0]: |
||||
|
lst.append(rec) |
||||
|
row = 6 |
||||
|
col = 0 |
||||
|
sheet.set_column(3, 0, 15) |
||||
|
sheet.set_column(4, 1, 15) |
||||
|
sheet.set_column(5, 2, 15) |
||||
|
sheet.set_column(6, 3, 15) |
||||
|
sheet.set_column(7, 4, 15) |
||||
|
sheet.set_column(8, 5, 15) |
||||
|
sheet.set_column(9, 6, 15) |
||||
|
sheet.set_column(10, 7, 15) |
||||
|
sheet.set_column(11, 8, 15) |
||||
|
sheet.set_column(12, 9, 15) |
||||
|
for rec_data in report_data_main: |
||||
|
row += 1 |
||||
|
sheet.write(row, col, rec_data['shop'], txt_l) |
||||
|
sheet.write(row, col + 1, rec_data['session'], txt_l) |
||||
|
sheet.write(row, col + 2, rec_data['date_order'], txt_l) |
||||
|
sheet.write(row, col + 3, rec_data['name'], txt_l) |
||||
|
sheet.write(row, col + 4, rec_data['salesman'], txt_l) |
||||
|
sheet.write(row, col + 5, rec_data['default_code'], txt_l) |
||||
|
sheet.write(row, col + 6, rec_data['full_product_name'], txt_l) |
||||
|
sheet.write(row, col + 7, rec_data['price_unit'], txt_l) |
||||
|
sheet.write(row, col + 8, rec_data['sum'], txt_l) |
||||
|
sheet.write(row, col + 9, rec_data['price_subtotal'], txt_l) |
||||
|
sheet.write(row, col + 10, rec_data['price_subtotal_incl'], |
||||
|
txt_l) |
||||
|
if filters.get('report_type') == 'report_by_product': |
||||
|
sheet.merge_range('B5:D5', 'Report Type: ' + |
||||
|
filters.get('report_type'), txt_l) |
||||
|
sheet.write('A7', 'Category', heading) |
||||
|
sheet.write('B7', 'Product Code', heading) |
||||
|
sheet.write('C7', 'Product Name', heading) |
||||
|
sheet.write('D7', 'Qty', heading) |
||||
|
sheet.write('E7', 'Amount Total', heading) |
||||
|
sheet.write('F7', 'Amount Total Incl', heading) |
||||
|
lst = [] |
||||
|
if report_data_main: |
||||
|
for rec in report_data_main[0]: |
||||
|
lst.append(rec) |
||||
|
row = 6 |
||||
|
col = 0 |
||||
|
sheet.set_column(3, 0, 15) |
||||
|
sheet.set_column(4, 1, 15) |
||||
|
sheet.set_column(5, 2, 15) |
||||
|
sheet.set_column(6, 3, 15) |
||||
|
sheet.set_column(7, 4, 15) |
||||
|
sheet.set_column(8, 5, 15) |
||||
|
for rec_data in report_data_main: |
||||
|
row += 1 |
||||
|
sheet.write(row, col, rec_data['name'], txt_l) |
||||
|
sheet.write(row, col + 1, rec_data['default_code'], txt_l) |
||||
|
sheet.write(row, col + 2, rec_data['full_product_name'], txt_l) |
||||
|
sheet.write(row, col + 3, rec_data['qty'], txt_l) |
||||
|
sheet.write(row, col + 4, rec_data['amount_total'], txt_l) |
||||
|
sheet.write(row, col + 5, rec_data['amount_paid'], txt_l) |
||||
|
if filters.get('report_type') == 'report_by_categories': |
||||
|
sheet.merge_range('B5:D5', 'Report Type: ' + |
||||
|
filters.get('report_type'), txt_l) |
||||
|
sheet.write('A7', 'Category', heading) |
||||
|
sheet.write('B7', 'Qty', heading) |
||||
|
sheet.write('C7', 'Amount Total', heading) |
||||
|
sheet.write('D7', 'Amount Total Incl', heading) |
||||
|
lst = [] |
||||
|
if report_data_main: |
||||
|
for rec in report_data_main[0]: |
||||
|
lst.append(rec) |
||||
|
row = 6 |
||||
|
col = 0 |
||||
|
sheet.set_column(3, 0, 15) |
||||
|
sheet.set_column(4, 1, 15) |
||||
|
sheet.set_column(5, 2, 15) |
||||
|
sheet.set_column(6, 3, 15) |
||||
|
for rec_data in report_data_main: |
||||
|
row += 1 |
||||
|
sheet.write(row, col, rec_data['name'], txt_l) |
||||
|
sheet.write(row, col + 1, rec_data['qty'], txt_l) |
||||
|
sheet.write(row, col + 2, rec_data['amount_total'], txt_l) |
||||
|
sheet.write(row, col + 3, rec_data['total_incl'], txt_l) |
||||
|
if filters.get('report_type') == 'report_by_salesman': |
||||
|
sheet.merge_range('B5:D5', 'Report Type: ' + |
||||
|
filters.get('report_type'), txt_l) |
||||
|
sheet.write('A7', 'Salesman', heading) |
||||
|
sheet.write('B7', 'Total Order', heading) |
||||
|
sheet.write('C7', 'Total Qty', heading) |
||||
|
sheet.write('D7', 'Total Amount', heading) |
||||
|
lst = [] |
||||
|
if report_data_main: |
||||
|
for rec in report_data_main[0]: |
||||
|
lst.append(rec) |
||||
|
row = 6 |
||||
|
col = 0 |
||||
|
sheet.set_column(3, 0, 15) |
||||
|
sheet.set_column(4, 1, 15) |
||||
|
sheet.set_column(5, 2, 15) |
||||
|
sheet.set_column(6, 3, 15) |
||||
|
for rec_data in report_data_main: |
||||
|
row += 1 |
||||
|
sheet.write(row, col, rec_data['name'], txt_l) |
||||
|
sheet.write(row, col + 1, rec_data['order'], txt_l) |
||||
|
sheet.write(row, col + 2, rec_data['qty'], txt_l) |
||||
|
sheet.write(row, col + 3, rec_data['amount'], txt_l) |
||||
|
if filters.get('report_type') == 'report_by_payment': |
||||
|
sheet.merge_range('B5:D5', 'Report Type: ' + |
||||
|
filters.get('report_type'), txt_l) |
||||
|
sheet.write('A7', 'Point of Sale', heading) |
||||
|
sheet.write('B7', 'PoS Session', heading) |
||||
|
sheet.write('C7', 'Payment', heading) |
||||
|
sheet.write('D7', 'Total Amount', heading) |
||||
|
lst = [] |
||||
|
if report_data_main: |
||||
|
for rec in report_data_main[0]: |
||||
|
lst.append(rec) |
||||
|
row = 6 |
||||
|
col = 0 |
||||
|
sheet.set_column(3, 0, 15) |
||||
|
sheet.set_column(4, 1, 15) |
||||
|
sheet.set_column(5, 2, 15) |
||||
|
sheet.set_column(6, 3, 15) |
||||
|
for rec_data in report_data_main: |
||||
|
name = list(rec_data['name'].values())[0] |
||||
|
row += 1 |
||||
|
sheet.write(row, col, rec_data['config'], txt_l) |
||||
|
sheet.write(row, col + 1, rec_data['session'], txt_l) |
||||
|
sheet.write(row, col + 2, name, txt_l) |
||||
|
sheet.write(row, col + 3, rec_data['sum'], txt_l) |
||||
|
workbook.close() |
||||
|
output.seek(0) |
||||
|
response.stream.write(output.read()) |
||||
|
output.close() |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################ |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################ |
||||
|
from . import pos_order_report |
@ -0,0 +1,41 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################ |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################ |
||||
|
from odoo import api, models |
||||
|
|
||||
|
|
||||
|
class PosReport(models.AbstractModel): |
||||
|
""" To retrieve the report days """ |
||||
|
_name = 'report.pos_report_generator.pos_order_report' |
||||
|
_description = 'POS Report Generator' |
||||
|
|
||||
|
@api.model |
||||
|
def _get_report_values(self, docids, data=None): |
||||
|
""" This method is used to retrieve report values for a POS order |
||||
|
report.""" |
||||
|
if self.env.context.get('pos_order_report'): |
||||
|
if data.get('report_data'): |
||||
|
data.update({'report_main_line_data': data.get('report_data')[ |
||||
|
'report_lines'], |
||||
|
'Filters': data.get('report_data')['filters'], |
||||
|
'company': self.env.company, |
||||
|
}) |
||||
|
return data |
@ -0,0 +1,420 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<odoo> |
||||
|
<!-- POS Order Report General Template --> |
||||
|
<template id="pos_order_report"> |
||||
|
<t t-call="web.html_container"> |
||||
|
<t t-call="web.internal_layout"> |
||||
|
<t t-if="Filters.get('report_type')=='Report By Order'"> |
||||
|
<t t-call="pos_report_generator.report_order"/> |
||||
|
</t> |
||||
|
<t t-if="Filters.get('report_type')=='Report By Order Detail'"> |
||||
|
<t t-call="pos_report_generator.report_order_detail"/> |
||||
|
</t> |
||||
|
<t t-if="Filters.get('report_type')=='Report By Product'"> |
||||
|
<t t-call="pos_report_generator.report_product"/> |
||||
|
</t> |
||||
|
<t t-if="Filters.get('report_type')=='Report By Categories'"> |
||||
|
<t t-call="pos_report_generator.report_category"/> |
||||
|
</t> |
||||
|
<t t-if="Filters.get('report_type')=='Report By Salesman'"> |
||||
|
<t t-call="pos_report_generator.report_salesman"/> |
||||
|
</t> |
||||
|
<t t-if="Filters.get('report_type')=='Report By Payment'"> |
||||
|
<t t-call="pos_report_generator.report_payment"/> |
||||
|
</t> |
||||
|
</t> |
||||
|
</t> |
||||
|
</template> |
||||
|
<!-- Template of Report by order --> |
||||
|
<template id="report_order"> |
||||
|
<div class="page"> |
||||
|
<div class="oe_structure"/> |
||||
|
<span t-if="Filters.get('date_from')"> |
||||
|
<strong>From:</strong> |
||||
|
<t t-esc="Filters['date_from']"/> |
||||
|
</span> |
||||
|
<span t-if="Filters.get('date_to')"> |
||||
|
<strong>To:</strong> |
||||
|
<t t-esc="Filters['date_to']"/> |
||||
|
</span> |
||||
|
<div> |
||||
|
<div style="width:100%;"> |
||||
|
<div style="text-align:centre;" class="row"> |
||||
|
|
||||
|
<div class="col-2"> |
||||
|
<strong>Report Type:</strong> |
||||
|
<t t-esc="Filters.get('report_type')"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<br/> |
||||
|
<table class="table table-sm table-reports"> |
||||
|
<thead> |
||||
|
<tr class="text-right"> |
||||
|
<th colspan="6">PoS</th> |
||||
|
<th colspan="6">Order</th> |
||||
|
<th colspan="6">Date Order</th> |
||||
|
<th colspan="6">Customer</th> |
||||
|
<th colspan="6">Salesman</th> |
||||
|
<th colspan="6">Total Qty</th> |
||||
|
<th colspan="6">Amount Total</th> |
||||
|
<th colspan="6">Note</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="report_main_line_data" t-as="main"> |
||||
|
<tr style="font-weight: bold;"> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['shop']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['session']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['date_order']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['name']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['salesman']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['sum']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['amount_total']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['general_note']"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
<br/> |
||||
|
</div> |
||||
|
</template> |
||||
|
<!-- Template of report by order detail --> |
||||
|
<template id="report_order_detail"> |
||||
|
<div class="page"> |
||||
|
<div class="oe_structure"/> |
||||
|
<span t-if="Filters.get('date_from')"> |
||||
|
<strong>From:</strong> |
||||
|
<t t-esc="Filters['date_from']"/> |
||||
|
</span> |
||||
|
<span t-if="Filters.get('date_to')"> |
||||
|
<strong>To:</strong> |
||||
|
<t t-esc="Filters['date_to']"/> |
||||
|
</span> |
||||
|
<div> |
||||
|
<div style="width:100%;"> |
||||
|
<div style="text-align:centre;" class="row"> |
||||
|
<div class="col-2"> |
||||
|
<strong>Report Type:</strong> |
||||
|
<t t-esc="Filters.get('report_type')"/> |
||||
|
</div> |
||||
|
|
||||
|
</div> |
||||
|
</div> |
||||
|
<br/> |
||||
|
<table class="table table-sm table-reports"> |
||||
|
<thead> |
||||
|
<tr class="text-right"> |
||||
|
<th colspan="6">PoS</th> |
||||
|
<th colspan="6">Order</th> |
||||
|
<th colspan="6">Date Order</th> |
||||
|
<th colspan="6">Customer</th> |
||||
|
<th colspan="6">Salesman</th> |
||||
|
<th colspan="6">Product Code</th> |
||||
|
<th colspan="6">Product Name</th> |
||||
|
<th colspan="6">Price unit</th> |
||||
|
<th colspan="6">Qty</th> |
||||
|
<th colspan="6">Price Subtotal</th> |
||||
|
<th colspan="6">Price Subtotal Incl</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="report_main_line_data" t-as="main"> |
||||
|
<tr style="font-weight: bold;"> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['shop']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['session']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['date_order']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['name']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['salesman']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['default_code']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['full_product_name']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['price_unit']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['sum']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['price_subtotal']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['price_subtotal_incl']"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
|
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
<br/> |
||||
|
</div> |
||||
|
</template> |
||||
|
<!-- Template of report by product --> |
||||
|
<template id="report_product"> |
||||
|
<div class="page"> |
||||
|
<div class="oe_structure"/> |
||||
|
<span t-if="Filters.get('date_from')"> |
||||
|
<strong>From:</strong> |
||||
|
<t t-esc="Filters['date_from']"/> |
||||
|
</span> |
||||
|
<span t-if="Filters.get('date_to')"> |
||||
|
<strong>To:</strong> |
||||
|
<t t-esc="Filters['date_to']"/> |
||||
|
</span> |
||||
|
<div> |
||||
|
<div style="width:100%;"> |
||||
|
<div style="text-align:centre;" class="row"> |
||||
|
<div class="col-2"> |
||||
|
<strong>Report Type:</strong> |
||||
|
<t t-esc="Filters.get('report_type')"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<br/> |
||||
|
<table class="table table-sm table-reports"> |
||||
|
<thead> |
||||
|
<tr class="text-right"> |
||||
|
<th colspan="6">Category</th> |
||||
|
<th colspan="6">Product Code</th> |
||||
|
<th colspan="6">Product Name</th> |
||||
|
<th colspan="6">Qty</th> |
||||
|
<th colspan="6">Amount Total</th> |
||||
|
<th colspan="6">Amount Total Incl</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="report_main_line_data" t-as="main"> |
||||
|
<tr style="font-weight: bold;"> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['name']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['default_code']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['full_product_name']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['qty']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['amount_total']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['amount_total']"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
<br/> |
||||
|
</div> |
||||
|
</template> |
||||
|
<!-- Template of report by category --> |
||||
|
<template id="report_category"> |
||||
|
<div class="page"> |
||||
|
<div class="oe_structure"/> |
||||
|
<span t-if="Filters.get('date_from')"> |
||||
|
<strong>From:</strong> |
||||
|
<t t-esc="Filters['date_from']"/> |
||||
|
</span> |
||||
|
<span t-if="Filters.get('date_to')"> |
||||
|
<strong>To:</strong> |
||||
|
<t t-esc="Filters['date_to']"/> |
||||
|
</span> |
||||
|
<div> |
||||
|
<div style="width:100%;"> |
||||
|
<div style="text-align:centre;" class="row"> |
||||
|
<div class="col-2"> |
||||
|
<strong>Report Type:</strong> |
||||
|
<t t-esc="Filters.get('report_type')"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<br/> |
||||
|
<table class="table table-sm table-reports"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th colspan="6">Category</th> |
||||
|
<th colspan="6">Qty</th> |
||||
|
<th colspan="6">Amount Total</th> |
||||
|
<th colspan="6">Amount Total Incl</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="report_main_line_data" t-as="pos_category"> |
||||
|
<tr style="font-weight: bold;"> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="pos_category['name']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="pos_category['qty']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="pos_category['amount_total']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="pos_category['total_incl']"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
<br/> |
||||
|
</div> |
||||
|
</template> |
||||
|
<!-- Template of report by salesman --> |
||||
|
<template id="report_salesman"> |
||||
|
<div class="page"> |
||||
|
<div class="oe_structure"/> |
||||
|
<span t-if="Filters.get('date_from')"> |
||||
|
<strong>From:</strong> |
||||
|
<t t-esc="Filters['date_from']"/> |
||||
|
</span> |
||||
|
<span t-if="Filters.get('date_to')"> |
||||
|
<strong>To:</strong> |
||||
|
<t t-esc="Filters['date_to']"/> |
||||
|
</span> |
||||
|
<div> |
||||
|
<div style="width:100%;"> |
||||
|
<div style="text-align:centre;" class="row"> |
||||
|
<div class="col-2"> |
||||
|
<strong>Report Type:</strong> |
||||
|
<t t-esc="Filters.get('report_type')"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<br/> |
||||
|
<table class="table table-sm table-reports"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th>Salesman</th> |
||||
|
<th colspan="6">Total Order</th> |
||||
|
<th colspan="6">Total Qty</th> |
||||
|
<th colspan="6">Total Amount</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="report_main_line_data" t-as="main"> |
||||
|
<tr style="font-weight: bold;"> |
||||
|
<td> |
||||
|
<span t-esc="main['name']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['order']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['qty']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['amount']"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
<br/> |
||||
|
</div> |
||||
|
</template> |
||||
|
<!-- Template of report by payment --> |
||||
|
<template id="report_payment"> |
||||
|
<div class="page"> |
||||
|
<div class="oe_structure"/> |
||||
|
<span t-if="Filters.get('date_from')"> |
||||
|
<strong>From:</strong> |
||||
|
<t t-esc="Filters['date_from']"/> |
||||
|
</span> |
||||
|
<span t-if="Filters.get('date_to')"> |
||||
|
<strong>To:</strong> |
||||
|
<t t-esc="Filters['date_to']"/> |
||||
|
</span> |
||||
|
<div> |
||||
|
<div style="width:100%;"> |
||||
|
<div style="text-align:centre;" class="row"> |
||||
|
|
||||
|
<div class="col-2"> |
||||
|
<strong>Report Type:</strong> |
||||
|
<t t-esc="Filters.get('report_type')"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<br/> |
||||
|
<table class="table table-sm table-reports"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th>Point of Sale</th> |
||||
|
<th colspan="6">PoS Session</th> |
||||
|
<th colspan="6">Payment</th> |
||||
|
<th colspan="6">Total Amount</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="report_main_line_data" t-as="main"> |
||||
|
<tr style="font-weight: bold;"> |
||||
|
<td> |
||||
|
<span t-esc="main['config']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['session']"/> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span> |
||||
|
<t t-foreach="main['name']" t-as="nme"> |
||||
|
<t t-esc="main['name'][nme]"/> |
||||
|
</t> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td colspan="6"> |
||||
|
<span t-esc="main['sum']"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
<br/> |
||||
|
</div> |
||||
|
</template> |
||||
|
<!-- Report action record --> |
||||
|
<record id="action_report_pos_all_in_one" model="ir.actions.report"> |
||||
|
<field name="name">POS All In One Report</field> |
||||
|
<field name="model">pos.report</field> |
||||
|
<field name="report_type">qweb-pdf</field> |
||||
|
<field name="report_name">pos_report_generator.pos_order_report</field> |
||||
|
<field name="report_file">pos_report_generator.pos_order_report</field> |
||||
|
</record> |
||||
|
</odoo> |
|
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 628 KiB |
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: 912 KiB |
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 63 KiB |
After Width: | Height: | Size: 101 KiB |
After Width: | Height: | Size: 70 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 150 KiB |
After Width: | Height: | Size: 880 KiB |
After Width: | Height: | Size: 93 KiB |
After Width: | Height: | Size: 14 KiB |
@ -0,0 +1,54 @@ |
|||||
|
.time_range_pos { |
||||
|
width: 125px; |
||||
|
border: 2px solid #ccc; |
||||
|
border-radius: 5px; |
||||
|
padding: 10px; |
||||
|
} |
||||
|
a.dropdown-toggle.report-type { |
||||
|
margin: 10px; |
||||
|
} |
||||
|
.search-Result-Selection { |
||||
|
border: 2px solid #ccc; |
||||
|
width: 257px; |
||||
|
margin-right: 10px; |
||||
|
margin-left: 10px; |
||||
|
border-radius: 5px; |
||||
|
} |
||||
|
.table_pos_head { |
||||
|
background-color: #7c7bad; |
||||
|
color: #fff; |
||||
|
padding: 20px; |
||||
|
margin: 20px; |
||||
|
height: 57px; |
||||
|
width: 100%; |
||||
|
border: 1px solid #000; |
||||
|
} |
||||
|
element.style { |
||||
|
top: 0px; |
||||
|
height: 42px; |
||||
|
color: white; |
||||
|
background-color: #7c7bad; |
||||
|
border-color: #7c7bad; |
||||
|
width: 100px; |
||||
|
} |
||||
|
tr.ps-line { |
||||
|
height: 48px; |
||||
|
} |
||||
|
tr.table_pos_head th { |
||||
|
font-size: 18px; |
||||
|
text-align: center; |
||||
|
} |
||||
|
|
||||
|
ul.pos-dropdown.show { |
||||
|
height: 40px; |
||||
|
background-color: #eeeeee; |
||||
|
width: 200px; |
||||
|
} |
||||
|
|
||||
|
ul.pos-dropdown.show li { |
||||
|
margin-left: 10px; |
||||
|
} |
||||
|
|
||||
|
ul.pos-dropdown.show a{ |
||||
|
color: #221c1c; |
||||
|
} |
@ -0,0 +1,138 @@ |
|||||
|
/** @odoo-module */ |
||||
|
import { registry } from "@web/core/registry"; |
||||
|
import { BlockUI } from "@web/core/ui/block_ui"; |
||||
|
import { download } from "@web/core/network/download"; |
||||
|
import { Component, useRef, onMounted } from "@odoo/owl"; |
||||
|
import { useService } from "@web/core/utils/hooks"; |
||||
|
import { renderToFragment } from "@web/core/utils/render"; |
||||
|
const actionRegistry = registry.category("actions"); |
||||
|
|
||||
|
/* Define a new component named 'PosReport' */ |
||||
|
export class PosReport extends Component { |
||||
|
setup() { |
||||
|
super.setup(...arguments); |
||||
|
this.orm = useService("orm"); |
||||
|
this.root = useRef('root-PosReport') |
||||
|
this.table = useRef('table-view') |
||||
|
this.report = useRef('report-type') |
||||
|
this.wizard_id = this.props.action.context.wizard | null; |
||||
|
onMounted(() => { |
||||
|
this.start_function() |
||||
|
}) |
||||
|
} |
||||
|
// Start Function
|
||||
|
start_function() { |
||||
|
var self = this; |
||||
|
self.initial_render = true; |
||||
|
this.orm.call('pos.report', 'create', [{}]).then((res) => { |
||||
|
self.wizard_id = res; |
||||
|
self.load_data(self.initial_render); |
||||
|
self.apply_filter(); |
||||
|
}) |
||||
|
} |
||||
|
// Load Data function to load the data
|
||||
|
load_data(initial_render = true) { |
||||
|
var self = this; |
||||
|
self.orm.call('pos.report', 'pos_report', [this.wizard_id]).then((datas) => { |
||||
|
if(datas['orders']) { |
||||
|
this.root.el.querySelector('.table_view_pr').innerHTML = ''; |
||||
|
this.root.el.querySelector('.table_view_pr').append(renderToFragment('PosOrderTable', { |
||||
|
filter: datas['filters'], |
||||
|
order: datas['orders'], |
||||
|
report_lines: datas['report_lines'], |
||||
|
main_lines: datas['report_main_line'] |
||||
|
})); |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
// Function to print the PDF report
|
||||
|
print_pdf(e) { |
||||
|
e.preventDefault(); |
||||
|
var self = this; |
||||
|
this.orm.call('pos.report', 'pos_report', [[self.wizard_id]]).then((data) => { |
||||
|
var action = { |
||||
|
'type': 'ir.actions.report', |
||||
|
'report_type': 'qweb-pdf', |
||||
|
'report_name': 'pos_report_generator.pos_order_report', |
||||
|
'report_file': 'pos_report_generator.pos_order_report', |
||||
|
'data': { |
||||
|
'report_data': data |
||||
|
}, |
||||
|
'context': { |
||||
|
'active_model': 'pos.report', |
||||
|
'landscape': 1, |
||||
|
'pos_order_report': true |
||||
|
}, |
||||
|
'display_name': 'PoS Order', |
||||
|
}; |
||||
|
return this.env.services.action.doAction(action); |
||||
|
}) |
||||
|
} |
||||
|
// Function to print the xlsx report
|
||||
|
print_xlsx() { |
||||
|
var self = this; |
||||
|
this.orm.call('pos.report', 'pos_report', [self.wizard_id]).then((data) => { |
||||
|
var action = { |
||||
|
'data': { |
||||
|
'model': 'pos.report', |
||||
|
'options': JSON.stringify(data['orders']), |
||||
|
'output_format': 'xlsx', |
||||
|
'report_data': JSON.stringify(data['report_lines']), |
||||
|
'report_name': 'PoS Report', |
||||
|
'dfr_data': JSON.stringify(data), |
||||
|
}, |
||||
|
}; |
||||
|
self.downloadXlsx(action); |
||||
|
}) |
||||
|
} |
||||
|
// Xlsx download function
|
||||
|
downloadXlsx (action) { |
||||
|
BlockUI; |
||||
|
download({ |
||||
|
url: '/pos_dynamic_xlsx_reports', |
||||
|
data: action.data, |
||||
|
complete: () => unblockUI, |
||||
|
error: (error) => self.call('crash_manager', 'rpc_error', error), |
||||
|
}); |
||||
|
} |
||||
|
// Function to apply the filters
|
||||
|
apply_filter() { |
||||
|
var self = this; |
||||
|
var filter_data_selected = {}; |
||||
|
// Get the value of the date_from input element
|
||||
|
if(this.root.el.querySelector('.date_from').value) { |
||||
|
filter_data_selected.date_from = this.root.el.querySelector('.date_from').value |
||||
|
} |
||||
|
if(this.root.el.querySelector('.date_to').value){ |
||||
|
filter_data_selected.date_to = this.root.el.querySelector('.date_to').value |
||||
|
} |
||||
|
self.initial_render = false; |
||||
|
if (this.report.el || this.report.getEl?.().length) { |
||||
|
var report_res = this.root.el.querySelector('#report_res') |
||||
|
filter_data_selected.report_type = this.root.el.querySelector('.report_type').value |
||||
|
report_res.value = this.root.el.querySelector('.report_type').value |
||||
|
if (report_res.value == "report_by_order"){ |
||||
|
report_res.innerHTML = "Report By Order"; |
||||
|
} else if (report_res.value == "report_by_product"){ |
||||
|
report_res.innerHTML = "Report By Product"; |
||||
|
} else if (report_res.value == "report_by_order_detail"){ |
||||
|
report_res.innerHTML = "Report By Order Detail"; |
||||
|
} else if (report_res.value == "report_by_categories"){ |
||||
|
report_res.innerHTML = "Report By Categories"; |
||||
|
} else if (report_res.value == "report_by_salesman"){ |
||||
|
report_res.innerHTML = "Report By Salesman"; |
||||
|
} else { |
||||
|
report_res.innerHTML = "Report By Payment"; |
||||
|
} |
||||
|
if (this.root.el.querySelector('.report_type').value == "") { |
||||
|
report_res.innerHTML = "report_by_order"; |
||||
|
} |
||||
|
} |
||||
|
self.orm.call('pos.report', 'write', [self.wizard_id, filter_data_selected]).then((res) => { |
||||
|
self.initial_render = false; |
||||
|
self.load_data(self.initial_render); |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
PosReport.template = "PosReport"; |
||||
|
actionRegistry.add('pos_r', PosReport); |