@ -0,0 +1,48 @@ |
|||||
|
.. 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 |
||||
|
|
||||
|
Purchase All In One Report Generator |
||||
|
==================================== |
||||
|
This module Helps to Generate All in One Dynamic Purchase Report. |
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
* No additional configuration is needed. |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
||||
|
|
||||
|
License |
||||
|
------- |
||||
|
Affero General Public License, Version 3 (AGPL v3). |
||||
|
(https://www.gnu.org/licenses/agpl-3.0-standalone.html) |
||||
|
|
||||
|
Credits |
||||
|
------- |
||||
|
* Developers: (V17) Ayana 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) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.info) |
||||
|
# |
||||
|
# 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,54 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.info) |
||||
|
# |
||||
|
# 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': 'Purchase All In One Report Generator', |
||||
|
'version': '18.0.1.0.0', |
||||
|
'category': 'Purchases', |
||||
|
'summary': """This module Helps to Generate All in One Dynamic Purchase |
||||
|
Report.""", |
||||
|
'description': """This module facilitates comprehensive Purchase Reports, |
||||
|
offering insights into a company's procurement analysis from various |
||||
|
angles, including orders, order details, sales representatives, and the |
||||
|
ability to filter data by different date ranges.""", |
||||
|
'author': 'Cybrosys Techno Solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer': 'Cybrosys Techno Solutions', |
||||
|
'website': 'https://www.cybrosys.com', |
||||
|
'depends': ['purchase'], |
||||
|
'data': [ |
||||
|
'security/ir.model.access.csv', |
||||
|
'views/dynamic_purchase_report_views.xml', |
||||
|
'report/purchase_order_report_templates.xml' |
||||
|
], |
||||
|
'assets': { |
||||
|
'web.assets_backend': [ |
||||
|
'purchase_report_generator/static/src/css/purchase_report.css', |
||||
|
'purchase_report_generator/static/src/js/purchase_report.js', |
||||
|
'purchase_report_generator/static/src/xml/purchase_report_view.xml', |
||||
|
], |
||||
|
}, |
||||
|
'images': ['static/description/banner.jpg'], |
||||
|
'license': 'AGPL-3', |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'application': False, |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.info) |
||||
|
# |
||||
|
# 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 purchase_report_generator |
@ -0,0 +1,63 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.info) |
||||
|
# |
||||
|
# 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): |
||||
|
""" This endpoint generates and provides an XLSX report in response to an |
||||
|
HTTP POST request. The function uses the provided data to create the |
||||
|
report and returns it as an XLSX file. """ |
||||
|
@http.route('/purchase_dynamic_xlsx_reports', type='http', auth='user', |
||||
|
methods=['POST'], csrf=False) |
||||
|
def get_report_xlsx(self, model, options, output_format, report_data, |
||||
|
report_name, dfr_data, **kw): |
||||
|
""" Endpoint for getting xlsx report """ |
||||
|
uid = request.session.uid |
||||
|
report_obj = request.env[model].with_user(uid) |
||||
|
dfr_data = dfr_data |
||||
|
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_purchase_xlsx_report(options, response, |
||||
|
report_data, dfr_data) |
||||
|
response.set_cookie('fileToken', token) |
||||
|
return response |
||||
|
except Exception as e: |
||||
|
se = 0 |
||||
|
error = { |
||||
|
'code': 200, |
||||
|
'message': 'Odoo Server Error', |
||||
|
'data': se |
||||
|
} |
||||
|
return request.make_response(html_escape(json.dumps(error))) |
@ -0,0 +1,6 @@ |
|||||
|
## Module <purchase_report_generator> |
||||
|
|
||||
|
#### 02.08.2025 |
||||
|
#### Version 18.0.1.0.0 |
||||
|
##### ADD |
||||
|
- Initial Commit for Purchase All In One Report Generator |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.info) |
||||
|
# |
||||
|
# 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 dynamic_purchase_report |
@ -0,0 +1,521 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.info) |
||||
|
# |
||||
|
# 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 |
||||
|
import re |
||||
|
from datetime import datetime |
||||
|
|
||||
|
from odoo import api, fields, models |
||||
|
|
||||
|
try: |
||||
|
from odoo.tools.misc import xlsxwriter |
||||
|
except ImportError: |
||||
|
import xlsxwriter |
||||
|
|
||||
|
|
||||
|
class DynamicPurchaseReport(models.Model): |
||||
|
""" Model for getting dynamic purchase report """ |
||||
|
_name = "dynamic.purchase.report" |
||||
|
_description = "Dynamic Purchase Report" |
||||
|
|
||||
|
purchase_report = fields.Char(string="Purchase Report", |
||||
|
help='Name of the report') |
||||
|
date_from = fields.Datetime(string="Date From", help='Start date of report') |
||||
|
date_to = fields.Datetime(string="Date to", help='End date of report') |
||||
|
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_purchase_representative', |
||||
|
'Report By Purchase Representative'), |
||||
|
('report_by_state', 'Report By State')], default='report_by_order', |
||||
|
help='The order of the report') |
||||
|
|
||||
|
@api.model |
||||
|
def purchase_report(self, option): |
||||
|
""" Function for getting datas for requests """ |
||||
|
report_values = self.env['dynamic.purchase.report'].browse(option[0]) |
||||
|
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('PURCHASE') |
||||
|
|
||||
|
return { |
||||
|
'name': "Purchase Orders", |
||||
|
'type': 'ir.actions.client', |
||||
|
'tag': 's_r', |
||||
|
'orders': data, |
||||
|
'filters': filters, |
||||
|
'report_lines': lines, |
||||
|
} |
||||
|
|
||||
|
def get_filter(self, option): |
||||
|
"""Function for get data according to order_by filter""" |
||||
|
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_purchase_representative': |
||||
|
filters['report_type'] = 'Report By Purchase Representative' |
||||
|
elif data.get('report_type') == 'report_by_state': |
||||
|
filters['report_type'] = 'Report By State' |
||||
|
else: |
||||
|
filters['report_type'] = 'report_by_order' |
||||
|
return filters |
||||
|
|
||||
|
def get_filter_data(self, option): |
||||
|
"""Function for get filter data in report""" |
||||
|
record = self.env['dynamic.purchase.report'].browse(option[0]) |
||||
|
default_filters = {} |
||||
|
filter_dict = { |
||||
|
'report_type': record.report_type, |
||||
|
} |
||||
|
filter_dict.update(default_filters) |
||||
|
return filter_dict |
||||
|
|
||||
|
def _get_report_sub_lines(self, data): |
||||
|
"""Function for get report value using sql query""" |
||||
|
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.notes,l.user_id,res_partner.name as partner, |
||||
|
res_users.partner_id as user_partner,sum(purchase_order_line.product_qty), |
||||
|
l.id as id,(SELECT res_partner.name as salesman FROM res_partner |
||||
|
WHERE res_partner.id = res_users.partner_id) from purchase_order as l |
||||
|
left join res_partner on l.partner_id = res_partner.id |
||||
|
left join res_users on l.user_id = res_users.id |
||||
|
left join purchase_order_line on l.id = purchase_order_line.order_id |
||||
|
where 1=1 """ |
||||
|
if data.get('date_from'): |
||||
|
query += """and l.date_order >= '%s' """ % data.get('date_from') |
||||
|
if data.get('date_to'): |
||||
|
query += """ and l.date_order <= '%s' """ % data.get('date_to') |
||||
|
query += """group by l.user_id,res_users.partner_id,res_partner.name, |
||||
|
l.partner_id,l.date_order,l.name,l.amount_total,l.notes,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.notes, l.user_id,res_partner.name as partner,res_users.partner_id |
||||
|
as user_partner,sum(purchase_order_line.product_qty), |
||||
|
purchase_order_line.name as product, purchase_order_line.price_unit, |
||||
|
purchase_order_line.price_subtotal,l.amount_total, |
||||
|
purchase_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 purchase_order as l |
||||
|
left join res_partner on l.partner_id = res_partner.id |
||||
|
left join res_users on l.user_id = res_users.id |
||||
|
left join purchase_order_line on l.id = purchase_order_line.order_id |
||||
|
left join product_product on purchase_order_line.product_id = product_product.id |
||||
|
where 1=1 """ |
||||
|
if data.get('date_from'): |
||||
|
query += """ and l.date_order >= '%s' """ % data.get('date_from') |
||||
|
if data.get('date_to'): |
||||
|
query += """ and l.date_order <= '%s' """ % data.get('date_to') |
||||
|
query += """group by l.user_id,res_users.partner_id,res_partner.name, |
||||
|
l.partner_id,l.date_order,l.name,l.amount_total,l.notes, |
||||
|
purchase_order_line.name,purchase_order_line.price_unit, |
||||
|
purchase_order_line.price_subtotal,l.amount_total, |
||||
|
purchase_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,sum(purchase_order_line.product_qty) |
||||
|
as qty, purchase_order_line.name as product, purchase_order_line.price_unit, |
||||
|
product_product.default_code,product_category.name from purchase_order |
||||
|
as l left join purchase_order_line on l.id = purchase_order_line.order_id |
||||
|
left join product_product on purchase_order_line.product_id = product_product.id |
||||
|
left join product_template on purchase_order_line.product_id = product_template.id |
||||
|
left join product_category on product_category.id = product_template.categ_id |
||||
|
where 1=1 """ |
||||
|
if data.get('date_from'): |
||||
|
query += """and l.date_order >= '%s' """ % data.get('date_from') |
||||
|
if data.get('date_to'): |
||||
|
query += """ and l.date_order <= '%s' """ % data.get('date_to') |
||||
|
query += """group by l.amount_total,purchase_order_line.name, |
||||
|
purchase_order_line.price_unit,purchase_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.product_qty) as qty, |
||||
|
sum(l.price_subtotal) as amount_total from purchase_order_line as l |
||||
|
left join product_template on l.product_id = product_template.id |
||||
|
left join product_category on product_category.id = product_template.categ_id |
||||
|
left join purchase_order on l.order_id = purchase_order.id |
||||
|
where 1=1 """ |
||||
|
if data.get('date_from'): |
||||
|
query += """and pos_order.date_order >= '%s' """ % data.get( |
||||
|
'date_from') |
||||
|
if data.get('date_to'): |
||||
|
query += """ and 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_purchase_representative': |
||||
|
query = """select res_partner.name,sum(purchase_order_line.product_qty) |
||||
|
as qty,sum(purchase_order_line.price_subtotal) as amount,count(DISTINCT l.id) |
||||
|
as order from purchase_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 purchase_order_line |
||||
|
on l.id = purchase_order_line.order_id where 1=1 """ |
||||
|
if data.get('date_from'): |
||||
|
query += """ and l.date_order >= '%s' """ % data.get('date_from') |
||||
|
if data.get('date_to'): |
||||
|
query += """ and l.date_order <= '%s' """ % data.get('date_to') |
||||
|
query += "group by res_partner.name" |
||||
|
self._cr.execute(query) |
||||
|
report_by_purchase_representative = self._cr.dictfetchall() |
||||
|
report_sub_lines.append(report_by_purchase_representative) |
||||
|
elif data.get('report_type') == 'report_by_state': |
||||
|
query = """select l.state,sum(purchase_order_line.product_qty) as |
||||
|
qty,sum(purchase_order_line.price_subtotal) as amount, |
||||
|
count(DISTINCT l.id) as order from purchase_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 purchase_order_line on l.id = purchase_order_line.order_id |
||||
|
where 1=1 """ |
||||
|
if data.get('date_from'): |
||||
|
query += """and so.date_order >= '%s' """ % data.get('date_from') |
||||
|
if data.get('date_to'): |
||||
|
query += """ and so.date_order <= '%s' """ % data.get('date_to') |
||||
|
query += "group by l.state" |
||||
|
self._cr.execute(query) |
||||
|
report_by_state = self._cr.dictfetchall() |
||||
|
report_sub_lines.append(report_by_state) |
||||
|
return report_sub_lines |
||||
|
|
||||
|
@staticmethod |
||||
|
def strip_html_tags(text): |
||||
|
if not text: |
||||
|
return '' |
||||
|
return re.sub(r'<[^>]*>', '', text) |
||||
|
|
||||
|
def _get_report_values(self, data): |
||||
|
"""Get report values based on the provided data.""" |
||||
|
docs = data['model'] |
||||
|
if data.get('report_type'): |
||||
|
report_res = self._get_report_sub_lines(data)[0] |
||||
|
else: |
||||
|
report_res = self._get_report_sub_lines(data) |
||||
|
|
||||
|
if isinstance(report_res, list): |
||||
|
for row in report_res: |
||||
|
if 'notes' in row: |
||||
|
row['notes'] = self.strip_html_tags(row['notes']) |
||||
|
elif isinstance(report_res, dict): |
||||
|
if 'notes' in report_res: |
||||
|
report_res['notes'] = self.strip_html_tags(report_res['notes']) |
||||
|
return { |
||||
|
'doc_ids': self.ids, |
||||
|
'docs': docs, |
||||
|
'PURCHASE': report_res, |
||||
|
} |
||||
|
|
||||
|
def get_purchase_xlsx_report(self, data, response, report_data, dfr_data): |
||||
|
""" This function generates an XLSX report based on the provided data |
||||
|
and report type. It writes the report data to the response |
||||
|
object for download. |
||||
|
Args: |
||||
|
data (str): JSON data containing report filters. |
||||
|
response (object): The response object used to send the XLSX file. |
||||
|
report_data (str): JSON data containing the report data to be |
||||
|
included in the XLSX. |
||||
|
dfr_data: Data that doesn't appear to be used in this function.""" |
||||
|
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': 1, 'border_color': 'black'}) |
||||
|
txt_l = workbook.add_format({ |
||||
|
'font_size': '10px', 'border': 1, 'bold': True}) |
||||
|
txt_normal = workbook.add_format({ |
||||
|
'font_size': '10px', 'border': 1}) |
||||
|
sheet.merge_range('A2:H3', 'Purchase Report', head) |
||||
|
if filters.get('report_type') == 'report_by_order': |
||||
|
sheet.merge_range('B5:C5', 'Report Type: ' + |
||||
|
'Report By Order', txt_l) |
||||
|
|
||||
|
if filters.get('date_from') and filters.get('date_to'): |
||||
|
formatted_date_from = datetime.strptime( |
||||
|
filters['date_from'], '%Y-%m-%d %H:%M:%S').strftime( |
||||
|
'%d/%m/%y') |
||||
|
formatted_date_to = datetime.strptime( |
||||
|
filters['date_to'], '%Y-%m-%d %H:%M:%S').strftime( |
||||
|
'%d/%m/%y') |
||||
|
sheet.write('B6', 'Start Date:', txt_l) |
||||
|
sheet.write('C6', formatted_date_from, txt_l) |
||||
|
sheet.write('D6', 'End Date:', txt_l) |
||||
|
sheet.write('E6', formatted_date_to, txt_l) |
||||
|
|
||||
|
sheet.write('A7', 'Order', heading) |
||||
|
sheet.write('B7', 'Date Order', heading) |
||||
|
sheet.write('C7', 'Customer', heading) |
||||
|
sheet.write('D7', 'Purchase Representative', heading) |
||||
|
sheet.write('E7', 'Total Qty', heading) |
||||
|
sheet.write('F7', 'Amount Total', heading) |
||||
|
lst = [] |
||||
|
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_normal) |
||||
|
sheet.write(row, col + 1, rec_data['date_order'], txt_normal) |
||||
|
sheet.write(row, col + 2, rec_data['partner'], txt_normal) |
||||
|
sheet.write(row, col + 3, rec_data['salesman'], txt_normal) |
||||
|
sheet.write(row, col + 4, rec_data['sum'], txt_normal) |
||||
|
sheet.write(row, col + 5, rec_data['amount_total'], txt_normal) |
||||
|
if filters.get('report_type') == 'report_by_order_detail': |
||||
|
sheet.merge_range('B5:C5', 'Report Type: ' + |
||||
|
'Report By Order Details', txt_l) |
||||
|
|
||||
|
if filters.get('date_from') and filters.get('date_to'): |
||||
|
formatted_date_from = datetime.strptime( |
||||
|
filters['date_from'], '%Y-%m-%d %H:%M:%S').strftime( |
||||
|
'%d/%m/%y') |
||||
|
formatted_date_to = datetime.strptime( |
||||
|
filters['date_to'], '%Y-%m-%d %H:%M:%S').strftime( |
||||
|
'%d/%m/%y') |
||||
|
sheet.write('B6', 'Start Date:', txt_l) |
||||
|
sheet.write('C6', formatted_date_from, txt_l) |
||||
|
sheet.write('D6', 'End Date:', txt_l) |
||||
|
sheet.write('E6', formatted_date_to, txt_l) |
||||
|
|
||||
|
sheet.write('A7', 'Order', heading) |
||||
|
sheet.write('B7', 'Date Order', heading) |
||||
|
sheet.write('C7', 'Customer', heading) |
||||
|
sheet.write('D7', 'Purchase Representative', heading) |
||||
|
sheet.write('E7', 'Product Code', heading) |
||||
|
sheet.write('F7', 'Product Name', heading) |
||||
|
sheet.write('G7', 'Price unit', heading) |
||||
|
sheet.write('H7', 'Qty', heading) |
||||
|
sheet.write('I7', 'Price Total', heading) |
||||
|
lst = [] |
||||
|
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['name'], txt_normal) |
||||
|
sheet.write(row, col + 1, rec_data['date_order'], txt_normal) |
||||
|
sheet.write(row, col + 2, rec_data['partner'], txt_normal) |
||||
|
sheet.write(row, col + 3, rec_data['salesman'], txt_normal) |
||||
|
sheet.write(row, col + 4, rec_data['default_code'], txt_normal) |
||||
|
sheet.write(row, col + 5, rec_data['product'], txt_normal) |
||||
|
sheet.write(row, col + 6, rec_data['price_unit'], txt_normal) |
||||
|
sheet.write(row, col + 7, rec_data['sum'], txt_normal) |
||||
|
sheet.write(row, col + 8, rec_data['amount_total'], txt_normal) |
||||
|
if filters.get('report_type') == 'report_by_product': |
||||
|
sheet.merge_range('B5:C5', 'Report Type: ' + |
||||
|
'Report By Product', txt_l) |
||||
|
|
||||
|
if filters.get('date_from') and filters.get('date_to'): |
||||
|
formatted_date_from = datetime.strptime( |
||||
|
filters['date_from'], '%Y-%m-%d %H:%M:%S').strftime( |
||||
|
'%d/%m/%y') |
||||
|
formatted_date_to = datetime.strptime( |
||||
|
filters['date_to'], '%Y-%m-%d %H:%M:%S').strftime( |
||||
|
'%d/%m/%y') |
||||
|
sheet.write('B6', 'Start Date:', txt_l) |
||||
|
sheet.write('C6', formatted_date_from, txt_l) |
||||
|
sheet.write('D6', 'End Date:', txt_l) |
||||
|
sheet.write('E6', formatted_date_to, 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) |
||||
|
lst = [] |
||||
|
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) |
||||
|
for rec_data in report_data_main: |
||||
|
row += 1 |
||||
|
sheet.write(row, col, rec_data['name'], txt_normal) |
||||
|
sheet.write(row, col + 1, rec_data['default_code'], txt_normal) |
||||
|
sheet.write(row, col + 2, rec_data['product'], txt_normal) |
||||
|
sheet.write(row, col + 3, rec_data['qty'], txt_normal) |
||||
|
sheet.write(row, col + 4, rec_data['amount_total'], txt_normal) |
||||
|
if filters.get('report_type') == 'report_by_categories': |
||||
|
sheet.merge_range('B5:C5', 'Report Type: ' + |
||||
|
'Report By Categories', txt_normal) |
||||
|
|
||||
|
if filters.get('date_from') and filters.get('date_to'): |
||||
|
formatted_date_from = datetime.strptime( |
||||
|
filters['date_from'], '%Y-%m-%d %H:%M:%S').strftime( |
||||
|
'%d/%m/%y') |
||||
|
formatted_date_to = datetime.strptime( |
||||
|
filters['date_to'], '%Y-%m-%d %H:%M:%S').strftime( |
||||
|
'%d/%m/%y') |
||||
|
sheet.write('B6', 'Start Date:', txt_l) |
||||
|
sheet.write('C6', formatted_date_from, txt_l) |
||||
|
sheet.write('D6', 'End Date:', txt_l) |
||||
|
sheet.write('E6', formatted_date_to, txt_l) |
||||
|
|
||||
|
sheet.write('B7', 'Category', heading) |
||||
|
sheet.write('C7', 'Qty', heading) |
||||
|
sheet.write('D7', 'Amount Total', heading) |
||||
|
lst = [] |
||||
|
for rec in report_data_main[0]: |
||||
|
lst.append(rec) |
||||
|
row = 6 |
||||
|
col = 1 |
||||
|
sheet.set_column(3, 1, 15) |
||||
|
sheet.set_column(4, 2, 15) |
||||
|
sheet.set_column(5, 3, 15) |
||||
|
for rec_data in report_data_main: |
||||
|
row += 1 |
||||
|
sheet.write(row, col, rec_data['name'], txt_normal) |
||||
|
sheet.write(row, col + 1, rec_data['qty'], txt_normal) |
||||
|
sheet.write(row, col + 2, rec_data['amount_total'], txt_normal) |
||||
|
if filters.get('report_type') == 'report_by_purchase_representative': |
||||
|
sheet.merge_range('B5:C5', 'Report Type: ' + |
||||
|
'Report By Purchase Representative', txt_l) |
||||
|
|
||||
|
if filters.get('date_from') and filters.get('date_to'): |
||||
|
formatted_date_from = datetime.strptime( |
||||
|
filters['date_from'], '%Y-%m-%d %H:%M:%S').strftime( |
||||
|
'%d/%m/%y') |
||||
|
formatted_date_to = datetime.strptime( |
||||
|
filters['date_to'], '%Y-%m-%d %H:%M:%S').strftime( |
||||
|
'%d/%m/%y') |
||||
|
sheet.write('B6', 'Start Date:', txt_l) |
||||
|
sheet.write('C6', formatted_date_from, txt_l) |
||||
|
sheet.write('D6', 'End Date:', txt_l) |
||||
|
sheet.write('E6', formatted_date_to, txt_l) |
||||
|
|
||||
|
sheet.write('A7', 'Purchase Representative', heading) |
||||
|
sheet.write('B7', 'Total Order', heading) |
||||
|
sheet.write('C7', 'Total Qty', heading) |
||||
|
sheet.write('D7', 'Total Amount', heading) |
||||
|
lst = [] |
||||
|
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_normal) |
||||
|
sheet.write(row, col + 1, rec_data['order'], txt_normal) |
||||
|
sheet.write(row, col + 2, rec_data['qty'], txt_normal) |
||||
|
sheet.write(row, col + 3, rec_data['amount'], txt_normal) |
||||
|
if filters.get('report_type') == 'report_by_state': |
||||
|
sheet.merge_range('B5:C5', 'Report Type: ' + |
||||
|
'Report By State', txt_l) |
||||
|
|
||||
|
if filters.get('date_from') and filters.get('date_to'): |
||||
|
formatted_date_from = datetime.strptime( |
||||
|
filters['date_from'], '%Y-%m-%d %H:%M:%S').strftime( |
||||
|
'%d/%m/%y') |
||||
|
formatted_date_to = datetime.strptime( |
||||
|
filters['date_to'], '%Y-%m-%d %H:%M:%S').strftime( |
||||
|
'%d/%m/%y') |
||||
|
sheet.write('B6', 'Start Date:', txt_l) |
||||
|
sheet.write('C6', formatted_date_from, txt_l) |
||||
|
sheet.write('D6', 'End Date:', txt_l) |
||||
|
sheet.write('E6', formatted_date_to, txt_l) |
||||
|
|
||||
|
sheet.write('A7', 'State', heading) |
||||
|
sheet.write('B7', 'Total Count', heading) |
||||
|
sheet.write('C7', 'Quantity', heading) |
||||
|
sheet.write('D7', 'Amount', heading) |
||||
|
lst = [] |
||||
|
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 |
||||
|
if rec_data['state'] == 'draft': |
||||
|
sheet.write(row, col, 'RFQ', txt_normal) |
||||
|
elif rec_data['state'] == 'sent': |
||||
|
sheet.write(row, col, 'RFQ Sent', txt_normal) |
||||
|
elif rec_data['state'] == 'purchase': |
||||
|
sheet.write(row, col, 'Purchase Order', txt_normal) |
||||
|
sheet.write(row, col + 1, rec_data['order'], txt_normal) |
||||
|
sheet.write(row, col + 2, rec_data['qty'], txt_normal) |
||||
|
sheet.write(row, col + 3, rec_data['amount'], txt_normal) |
||||
|
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) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.info) |
||||
|
# |
||||
|
# 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 purchase_order_report |
@ -0,0 +1,49 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.info) |
||||
|
# |
||||
|
# 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 |
||||
|
from odoo.fields import Date, Datetime |
||||
|
|
||||
|
|
||||
|
class PurchaseOrderReport(models.AbstractModel): |
||||
|
"""Model for creating pdf report and data fetching """ |
||||
|
_name = 'report.purchase_report_generator.purchase_order_report' |
||||
|
_description = "Purchase Report" |
||||
|
|
||||
|
@api.model |
||||
|
def _get_report_values(self, docids, data=None): |
||||
|
"""Function for get pdf report values""" |
||||
|
if self.env.context.get('purchase_order_report'): |
||||
|
report_data = data.get('report_data', {}) |
||||
|
orders = report_data.get('orders', {}) |
||||
|
filters = report_data.get('filters', {}) |
||||
|
report_lines = report_data.get('report_lines', []) |
||||
|
date_from = Date.from_string(orders.get('date_from', '')) |
||||
|
date_to = Date.from_string(orders.get('date_to', '')) |
||||
|
if report_data: |
||||
|
data.update({ |
||||
|
'report_main_line_data': report_lines, |
||||
|
'Filters': filters, |
||||
|
'date_from': (Datetime.from_string(date_from)).strftime('%d/%m/%y') if date_from else '', |
||||
|
'date_to': (Datetime.from_string(date_to)).strftime('%d/%m/%y') if date_to else '', |
||||
|
'company': self.env.company, |
||||
|
}) |
||||
|
return data |
@ -0,0 +1,390 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<odoo> |
||||
|
<!-- Template for purchase pdf report --> |
||||
|
<template id="purchase_order_report"> |
||||
|
<t t-call="web.html_container"> |
||||
|
<t t-call="web.external_layout"> |
||||
|
<t t-if="Filters.get('report_type')=='Report By Order'"> |
||||
|
<t t-call="purchase_report_generator.report_order"/> |
||||
|
</t> |
||||
|
<t t-if="Filters.get('report_type')=='Report By Order Detail'"> |
||||
|
<t t-call="purchase_report_generator.report_order_detail"/> |
||||
|
</t> |
||||
|
<t t-if="Filters.get('report_type')=='Report By Product'"> |
||||
|
<t t-call="purchase_report_generator.report_product"/> |
||||
|
</t> |
||||
|
<t t-if="Filters.get('report_type')=='Report By Categories'"> |
||||
|
<t t-call="purchase_report_generator.report_category"/> |
||||
|
</t> |
||||
|
<t t-if="Filters.get('report_type')=='Report By Purchase Representative'"> |
||||
|
<t t-call="purchase_report_generator.report_purchase_representative"/> |
||||
|
</t> |
||||
|
<t t-if="Filters.get('report_type')=='Report By State'"> |
||||
|
<t t-call="purchase_report_generator.report_state"/> |
||||
|
</t> |
||||
|
</t> |
||||
|
</t> |
||||
|
</template> |
||||
|
<template id="report_order"> |
||||
|
<div class="page"> |
||||
|
<div class="oe_structure"/> |
||||
|
<span t-if="date_from"> |
||||
|
<strong>From:</strong> |
||||
|
<t t-esc="date_from"/> |
||||
|
</span> |
||||
|
<span t-if="date_to"> |
||||
|
<strong>To:</strong> |
||||
|
<t t-esc="date_to"/> |
||||
|
</span> |
||||
|
<div> |
||||
|
<div style="width:100%;"> |
||||
|
<div style="text-align:centre;" class="row"> |
||||
|
<div class="col-4"> |
||||
|
<strong>Report Type:</strong> |
||||
|
<t t-esc="Filters.get('report_type')"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<br/> |
||||
|
<table class="table table-reports"> |
||||
|
<thead> |
||||
|
<th style="font-weight: bold;">Order</th> |
||||
|
<th style="font-weight: bold;">Date Order</th> |
||||
|
<th style="font-weight: bold;">Customer</th> |
||||
|
<th style="font-weight: bold;">Purchase Representative</th> |
||||
|
<th style="font-weight: bold;">Total Qty</th> |
||||
|
<th style="font-weight: bold;">Amount Total</th> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="report_main_line_data" t-as="main"> |
||||
|
<tr> |
||||
|
<td class="ps-1"> |
||||
|
<span t-esc="main['name']"/> |
||||
|
</td> |
||||
|
<td> |
||||
|
<span t-esc="main['date_order']"/> |
||||
|
</td> |
||||
|
<td> |
||||
|
<span t-esc="main['partner']"/> |
||||
|
</td> |
||||
|
<td class="text-center"> |
||||
|
<span t-esc="main['salesman']"/> |
||||
|
</td> |
||||
|
<td class="text-center"> |
||||
|
<span t-esc="main['sum']"/> |
||||
|
</td> |
||||
|
<td class="text-center"> |
||||
|
<span t-esc="main['amount_total']"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
<br/> |
||||
|
</div> |
||||
|
</template> |
||||
|
<template id="report_order_detail"> |
||||
|
<div class="page"> |
||||
|
<div class="oe_structure"/> |
||||
|
<span t-if="date_from"> |
||||
|
<strong>From:</strong> |
||||
|
<t t-esc="date_from"/> |
||||
|
</span> |
||||
|
<span t-if="date_to"> |
||||
|
<strong>To:</strong> |
||||
|
<t t-esc="date_to"/> |
||||
|
</span> |
||||
|
<div> |
||||
|
<div style="width:100%;"> |
||||
|
<div style="text-align:centre;" class="row"> |
||||
|
<div class="col-4"> |
||||
|
<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 style="font-weight: bold;">Order</th> |
||||
|
<th style="font-weight: bold;">Date Order</th> |
||||
|
<th style="font-weight: bold;">Customer</th> |
||||
|
<th style="font-weight: bold;">Purchase Representative</th> |
||||
|
<th style="font-weight: bold;">Product Code</th> |
||||
|
<th style="font-weight: bold;">Product Name</th> |
||||
|
<th style="font-weight: bold;">Price unit</th> |
||||
|
<th style="font-weight: bold;">Qty</th> |
||||
|
<th style="font-weight: bold;">Price Total</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="report_main_line_data" t-as="main"> |
||||
|
<tr> |
||||
|
<td class="ps-1"> |
||||
|
<span t-esc="main['name']"/> |
||||
|
</td> |
||||
|
<td> |
||||
|
<span t-esc="main['date_order']"/> |
||||
|
</td> |
||||
|
<td> |
||||
|
<span t-esc="main['partner']"/> |
||||
|
</td> |
||||
|
<td> |
||||
|
<span t-esc="main['salesman']"/> |
||||
|
</td> |
||||
|
<td> |
||||
|
<span t-esc="main['default_code']"/> |
||||
|
</td> |
||||
|
<td> |
||||
|
<span t-esc="main['product']"/> |
||||
|
</td> |
||||
|
<td> |
||||
|
<span t-esc="main['price_unit']"/> |
||||
|
</td> |
||||
|
<td> |
||||
|
<span t-esc="main['sum']"/> |
||||
|
</td> |
||||
|
<td> |
||||
|
<span t-esc="main['amount_total']"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
<br/> |
||||
|
</div> |
||||
|
</template> |
||||
|
<template id="report_product"> |
||||
|
<div class="page"> |
||||
|
<div class="oe_structure"/> |
||||
|
<span t-if="date_from"> |
||||
|
<strong>From:</strong> |
||||
|
<t t-esc="date_from"/> |
||||
|
</span> |
||||
|
<span t-if="date_to"> |
||||
|
<strong>To:</strong> |
||||
|
<t t-esc="date_to"/> |
||||
|
</span> |
||||
|
<div> |
||||
|
<div style="width:100%;"> |
||||
|
<div style="text-align:centre;" class="row"> |
||||
|
<div class="col-4"> |
||||
|
<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 style="font-weight: bold;">Category</th> |
||||
|
<th style="font-weight: bold;">Product Code</th> |
||||
|
<th style="font-weight: bold;">Product Name</th> |
||||
|
<th style="font-weight: bold;">Qty</th> |
||||
|
<th style="font-weight: bold;">Amount Total</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="report_main_line_data" t-as="main"> |
||||
|
<tr> |
||||
|
<td class="ps-1"> |
||||
|
<span t-esc="main['name']"/> |
||||
|
</td> |
||||
|
<td> |
||||
|
<span t-esc="main['default_code']"/> |
||||
|
</td> |
||||
|
<td> |
||||
|
<span t-esc="main['product']"/> |
||||
|
</td> |
||||
|
<td> |
||||
|
<span t-esc="main['qty']"/> |
||||
|
</td> |
||||
|
<td class="text-center"> |
||||
|
<span t-esc="main['amount_total']"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
<br/> |
||||
|
</div> |
||||
|
</template> |
||||
|
<template id="report_category"> |
||||
|
<div class="page"> |
||||
|
<div class="oe_structure"/> |
||||
|
<span t-if="date_from"> |
||||
|
<strong>From:</strong> |
||||
|
<t t-esc="date_from"/> |
||||
|
</span> |
||||
|
<span t-if="date_to"> |
||||
|
<strong>To:</strong> |
||||
|
<t t-esc="date_to"/> |
||||
|
</span> |
||||
|
<div> |
||||
|
<div style="width:100%;"> |
||||
|
<div style="text-align:centre;" class="row"> |
||||
|
<div class="col-4"> |
||||
|
<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 style="font-weight: bold;">Category</th> |
||||
|
<th style="font-weight: bold;">Qty</th> |
||||
|
<th style="font-weight: bold;">Amount Total</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="report_main_line_data" |
||||
|
t-as="purchase_category"> |
||||
|
<tr> |
||||
|
<td class="ps-2"> |
||||
|
<span t-esc="purchase_category['name']"/> |
||||
|
</td> |
||||
|
<td class="text-center"> |
||||
|
<span t-esc="purchase_category['qty']"/> |
||||
|
</td> |
||||
|
<td class="text-center"> |
||||
|
<span t-esc="purchase_category['amount_total']"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
<br/> |
||||
|
</div> |
||||
|
</template> |
||||
|
<template id="report_purchase_representative"> |
||||
|
<div class="page"> |
||||
|
<div class="oe_structure"/> |
||||
|
<span t-if="date_from"> |
||||
|
<strong>From:</strong> |
||||
|
<t t-esc="date_from"/> |
||||
|
</span> |
||||
|
<span t-if="date_to"> |
||||
|
<strong>To:</strong> |
||||
|
<t t-esc="date_to"/> |
||||
|
</span> |
||||
|
<div> |
||||
|
<div style="width:100%;"> |
||||
|
<div style="text-align:centre;" class="row"> |
||||
|
<div class="col-4"> |
||||
|
<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 style="font-weight: bold;">Purchase Representative</th> |
||||
|
<th style="font-weight: bold;">Total Order</th> |
||||
|
<th style="font-weight: bold;">Total Qty</th> |
||||
|
<th style="font-weight: bold;">Total Amount</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="report_main_line_data" t-as="main"> |
||||
|
<tr> |
||||
|
<td class="ps-2"> |
||||
|
<span t-esc="main['name']"/> |
||||
|
</td> |
||||
|
<td class="text-center"> |
||||
|
<span t-esc="main['order']"/> |
||||
|
</td> |
||||
|
<td class="text-center"> |
||||
|
<span t-esc="main['qty']"/> |
||||
|
</td> |
||||
|
<td class="text-center"> |
||||
|
<span t-esc="main['amount']"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
<br/> |
||||
|
</div> |
||||
|
</template> |
||||
|
<template id="report_state"> |
||||
|
<div class="page"> |
||||
|
<div class="oe_structure"/> |
||||
|
<span t-if="date_from"> |
||||
|
<strong>From:</strong> |
||||
|
<t t-esc="date_from"/> |
||||
|
</span> |
||||
|
<span t-if="date_to"> |
||||
|
<strong>To:</strong> |
||||
|
<t t-esc="date_to"/> |
||||
|
</span> |
||||
|
<div> |
||||
|
<div style="width:100%;"> |
||||
|
<div style="text-align:centre;" class="row"> |
||||
|
<div class="col-4"> |
||||
|
<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 class="text-center" style="font-weight: bold;">State</th> |
||||
|
<th class="text-center" style="font-weight: bold;">Total Count</th> |
||||
|
<th class="text-center" style="font-weight: bold;">Quantity</th> |
||||
|
<th class="text-center" style="font-weight: bold;">Amount</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="report_main_line_data" t-as="main"> |
||||
|
<tr> |
||||
|
<td class="text-center" > |
||||
|
<t t-if="main['state'] == 'draft'"> |
||||
|
<span>RFQ</span> |
||||
|
</t> |
||||
|
<t t-if="main['state'] == 'sent'"> |
||||
|
<span>RFQ Sent</span> |
||||
|
</t> |
||||
|
<t t-if="main['state'] == 'purchase'"> |
||||
|
<span>Purchase Order</span> |
||||
|
</t> |
||||
|
</td> |
||||
|
<td class="text-center"> |
||||
|
<span t-esc="main['order']"/> |
||||
|
</td> |
||||
|
<td class="text-center"> |
||||
|
<span t-esc="main['qty']"/> |
||||
|
</td> |
||||
|
<td class="text-center"> |
||||
|
<span t-esc="main['amount']"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
<br/> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<!-- Report Action --> |
||||
|
<record id="action_report_purchase_all_in_one" model="ir.actions.report"> |
||||
|
<field name="name">Purchase All In One Report</field> |
||||
|
<field name="model">dynamic.purchase.report</field> |
||||
|
<field name="report_type">qweb-pdf</field> |
||||
|
<field name="report_name">purchase_report_generator.purchase_order_report</field> |
||||
|
<field name="report_file">purchase_report_generator.purchase_order_report</field> |
||||
|
</record> |
||||
|
</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: 142 KiB |
After Width: | Height: | Size: 138 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 86 KiB |
After Width: | Height: | Size: 300 KiB |
After Width: | Height: | Size: 229 KiB |
After Width: | Height: | Size: 183 KiB |
After Width: | Height: | Size: 107 KiB |
After Width: | Height: | Size: 160 KiB |
After Width: | Height: | Size: 104 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 115 KiB |
After Width: | Height: | Size: 802 KiB |
After Width: | Height: | Size: 42 KiB |
@ -0,0 +1,138 @@ |
|||||
|
.time_range_pr { |
||||
|
width: 125px; |
||||
|
border: 2px solid #ccc; |
||||
|
border-radius: 5px; |
||||
|
padding: 10px; |
||||
|
} |
||||
|
.apply_sale { |
||||
|
margin-right: 5px; |
||||
|
padding: 4px; |
||||
|
} |
||||
|
#apply_filter { |
||||
|
margin-right: 25px; |
||||
|
} |
||||
|
#pdf, #xlsx, #apply_filter { |
||||
|
color: white; |
||||
|
background-color: #7c7bad; |
||||
|
border-color: #7c7bad; |
||||
|
} |
||||
|
a.dropdown-toggle.report-type { |
||||
|
margin: 10px; |
||||
|
} |
||||
|
.search-Result-Selection { |
||||
|
border: 2px solid #ccc; |
||||
|
max-width: 360px; |
||||
|
min-width: 250px; |
||||
|
margin-right: 10px; |
||||
|
margin-left: 10px; |
||||
|
border-radius: 5px; |
||||
|
min-height: 40px; |
||||
|
text-align: center; |
||||
|
} |
||||
|
.search-Result-Selection:hover{ |
||||
|
border:2px solid #eaeaea; |
||||
|
} |
||||
|
#selection{ |
||||
|
min-height: 46px; |
||||
|
min-width: 150px; |
||||
|
padding: 10px 10px 10px; |
||||
|
} |
||||
|
.dropdown-togglereport-type{ |
||||
|
min-height: 10px; |
||||
|
padding-top: 5px; |
||||
|
} |
||||
|
.low_case, #report_res { |
||||
|
text-transform: capitalize; |
||||
|
text-align: center; |
||||
|
} |
||||
|
#report_res{ |
||||
|
padding-right: 3px; |
||||
|
} |
||||
|
.print-btns { |
||||
|
margin-bottom: 30px; |
||||
|
} |
||||
|
.table_pr_head { |
||||
|
background-color: #7c7bad; |
||||
|
color: #fff; |
||||
|
padding: 20px; |
||||
|
margin: 20px; |
||||
|
height: 57px; |
||||
|
width: 100%; |
||||
|
border: 1px solid #000; |
||||
|
} |
||||
|
tr.pr-line { |
||||
|
height: 48px; |
||||
|
} |
||||
|
tr.table_pr_head th { |
||||
|
font-size: 18px; |
||||
|
text-align: center; |
||||
|
} |
||||
|
.table_view_pr { |
||||
|
overflow-y: scroll; |
||||
|
position: relative; |
||||
|
height: 500px; |
||||
|
max-width: 100%; |
||||
|
} |
||||
|
.my_custom_dropdown{ |
||||
|
min-width:200px; |
||||
|
height:150px; |
||||
|
padding: 20px; |
||||
|
} |
||||
|
.my_custom_dropdown input{ |
||||
|
height:25px; |
||||
|
} |
||||
|
.report_type{ |
||||
|
min-height: 100px; |
||||
|
min-width: 150px; |
||||
|
padding: 30px 10px 10px; |
||||
|
} |
||||
|
.sub_container_right, .print-btns { |
||||
|
display: flex; |
||||
|
justify-content: space-around; |
||||
|
align-items: center; |
||||
|
} |
||||
|
@media screen and (max-width: 768px) { |
||||
|
.sub_container_right, .print-btns { |
||||
|
flex-flow: column; |
||||
|
align-items: center; |
||||
|
} |
||||
|
.sub_container_left { |
||||
|
order: 2; |
||||
|
margin: 0; |
||||
|
} |
||||
|
.sub_container_right { |
||||
|
flex-flow: row; |
||||
|
margin-bottom: 10px; |
||||
|
flex-wrap: wrap !important; |
||||
|
width: 100%; |
||||
|
} |
||||
|
} |
||||
|
@media screen and (max-width: 576px) { |
||||
|
.apply_filter { |
||||
|
width: 100%; |
||||
|
position: relative; |
||||
|
} |
||||
|
#apply_filter { |
||||
|
position: absolute; |
||||
|
margin: 30px 0 0; |
||||
|
top: 50%; |
||||
|
left: 50%; |
||||
|
-ms-transform: translate(-50%, -50%); |
||||
|
transform: translate(-50%, -50%); |
||||
|
} |
||||
|
#date_chose { |
||||
|
margin-bottom: 15px; |
||||
|
} |
||||
|
.sub_container_left { |
||||
|
order: 2; |
||||
|
display: flex; |
||||
|
margin-top: 50px; |
||||
|
width: 100%; |
||||
|
justify-content: center; |
||||
|
align-items: center; |
||||
|
flex-wrap: wrap !important; |
||||
|
} |
||||
|
.sub_container_right { |
||||
|
flex-direction: column; |
||||
|
} |
||||
|
} |
@ -0,0 +1,189 @@ |
|||||
|
/** @odoo-module */ |
||||
|
const { Component } = owl; |
||||
|
import { registry } from "@web/core/registry"; |
||||
|
import { download } from "@web/core/network/download"; |
||||
|
import { useService } from "@web/core/utils/hooks"; |
||||
|
import { useRef, useState } from "@odoo/owl"; |
||||
|
const actionRegistry = registry.category("actions"); |
||||
|
import { uiService } from "@web/core/ui/ui_service"; |
||||
|
// Extending components for adding purchase report class
|
||||
|
class PurchaseReport extends Component { |
||||
|
async setup() { |
||||
|
super.setup(...arguments); |
||||
|
this.actionService = useService("action"); |
||||
|
this.uiService = useService('ui'); |
||||
|
this.initial_render = true; |
||||
|
this.orm = useService('orm'); |
||||
|
this.action = useService('action'); |
||||
|
this.start_date = useRef('date_from'); |
||||
|
this.end_date = useRef('date_to'); |
||||
|
this.order_by = useRef('order_by'); |
||||
|
this.state = useState({ |
||||
|
order_line: [], |
||||
|
data: null, |
||||
|
order_by : 'report_by_order', |
||||
|
wizard_id : [] |
||||
|
}); |
||||
|
this.reportTypeLabels = { |
||||
|
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_purchase_representative: 'Report By Purchase Representative', |
||||
|
report_by_state: 'Report By State', |
||||
|
}; |
||||
|
this.load_data(); |
||||
|
} |
||||
|
get reportLabel() { |
||||
|
return this.reportTypeLabels[this.state.order_by] || this.state.order_by; |
||||
|
} |
||||
|
async load_data(wizard_id = null) { |
||||
|
/** |
||||
|
* Loads the data for the purchase report. |
||||
|
*/ |
||||
|
let move_lines = '' |
||||
|
try { |
||||
|
if(wizard_id == null){ |
||||
|
this.state.wizard_id = await this.orm.create("dynamic.purchase.report",[{}]); |
||||
|
} |
||||
|
this.state.data = await this.orm.call("dynamic.purchase.report", "purchase_report", [this.state.wizard_id]); |
||||
|
if (Array.isArray(this.state.data)) { |
||||
|
this.state.order_line = this.state.data.map(item => { |
||||
|
return item; |
||||
|
}); |
||||
|
} else if (typeof this.state.data === 'object' && this.state.data !== null) { |
||||
|
this.state.order_line = this.state.data.report_lines; |
||||
|
} |
||||
|
} |
||||
|
catch (el) { |
||||
|
window.location.href; |
||||
|
} |
||||
|
} |
||||
|
async onchangeFromDate() { |
||||
|
// Validation for start date
|
||||
|
if (this.end_date.el.value && this.start_date.el.value > this.end_date.el.value) { |
||||
|
this.actionService.doAction({ |
||||
|
type: 'ir.actions.client', |
||||
|
tag: 'display_notification', |
||||
|
params: { |
||||
|
message: 'End date should be greater than the start date.', |
||||
|
type: 'warning', |
||||
|
sticky: false, |
||||
|
} |
||||
|
}); |
||||
|
this.start_date.el.value = '' |
||||
|
this.end_date.el.value = '' |
||||
|
} |
||||
|
} |
||||
|
async onchangeEndDate() { |
||||
|
// Validation for end date
|
||||
|
if (this.start_date.el.value && this.start_date.el.value > this.end_date.el.value) { |
||||
|
this.actionService.doAction({ |
||||
|
type: 'ir.actions.client', |
||||
|
tag: 'display_notification', |
||||
|
params: { |
||||
|
message: 'End date should be greater than the start date.', |
||||
|
type: 'warning', |
||||
|
sticky: false, |
||||
|
} |
||||
|
}); |
||||
|
this.start_date.el.value = '' |
||||
|
this.end_date.el.value = '' |
||||
|
} |
||||
|
} |
||||
|
async applyFilter(ev) { |
||||
|
let filter_data = {} |
||||
|
this.state.order_by = this.order_by.el.value |
||||
|
filter_data.date_from = this.start_date.el.value |
||||
|
filter_data.date_to = this.end_date.el.value |
||||
|
filter_data.report_type = this.order_by.el.value |
||||
|
let data = await this.orm.write("dynamic.purchase.report",this.state.wizard_id, filter_data); |
||||
|
this.load_data(this.state.wizard_id) |
||||
|
} |
||||
|
viewPurchaseOrder(ev) { |
||||
|
return this.action.doAction({ |
||||
|
type: "ir.actions.act_window", |
||||
|
res_model: 'purchase.order', |
||||
|
res_id: parseInt(ev.target.id), |
||||
|
views: [[false, "form"]], |
||||
|
target: "current", |
||||
|
}); |
||||
|
} |
||||
|
async print_xlsx() { |
||||
|
/** |
||||
|
* Generates and downloads an XLSX report for the purchase orders. |
||||
|
*/ |
||||
|
var data = this.state.data |
||||
|
if (data.report_lines && data.report_lines.length > 0) { |
||||
|
const action = { |
||||
|
'data': { |
||||
|
'model': 'dynamic.purchase.report', |
||||
|
'options': JSON.stringify(data['orders']), |
||||
|
'output_format': 'xlsx', |
||||
|
'report_data': JSON.stringify(data['report_lines']), |
||||
|
'report_name': 'Purchase Report', |
||||
|
'dfr_data': JSON.stringify(data), |
||||
|
}, |
||||
|
}; |
||||
|
this.uiService.block(); |
||||
|
await download({ |
||||
|
url: '/purchase_dynamic_xlsx_reports', |
||||
|
data: action.data, |
||||
|
complete: this.uiService.unblock(), |
||||
|
error: (error) => this.call('crash_manager', 'rpc_error', error), |
||||
|
}); |
||||
|
} else { |
||||
|
// Notify the user if there's no data
|
||||
|
this.actionService.doAction({ |
||||
|
type: 'ir.actions.client', |
||||
|
tag: 'display_notification', |
||||
|
params: { |
||||
|
message: 'No data available to print', |
||||
|
type: 'warning', |
||||
|
sticky: false, |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
async printPdf(ev) { |
||||
|
/** |
||||
|
* Generates and displays a PDF report for the purchase orders. |
||||
|
* |
||||
|
* @param {Event} ev - The event object triggered by the action. |
||||
|
* @returns {Promise} - A promise that resolves to the result of the action. |
||||
|
*/ |
||||
|
ev.preventDefault(); |
||||
|
var self = this; |
||||
|
var action_title = self.props.action.display_name; |
||||
|
var data = this.state.data |
||||
|
if (data.report_lines && data.report_lines.length > 0) { |
||||
|
return self.action.doAction({ |
||||
|
'type': 'ir.actions.report', |
||||
|
'report_type': 'qweb-pdf', |
||||
|
'report_name': 'purchase_report_generator.purchase_order_report', |
||||
|
'report_file': 'purchase_report_generator.purchase_order_report', |
||||
|
'data': { |
||||
|
'report_data': data |
||||
|
}, |
||||
|
'context': { |
||||
|
'active_model': 'purchase.report', |
||||
|
'purchase_order_report': true |
||||
|
}, |
||||
|
'display_name': 'Purchase Order', |
||||
|
}) |
||||
|
} else { |
||||
|
// Notify the user if there's no data
|
||||
|
this.actionService.doAction({ |
||||
|
type: 'ir.actions.client', |
||||
|
tag: 'display_notification', |
||||
|
params: { |
||||
|
message: 'No data available to print', |
||||
|
type: 'warning', |
||||
|
sticky: false, |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
PurchaseReport.template = 'PurchaseReport'; |
||||
|
actionRegistry.add("purchase_report", PurchaseReport); |
@ -0,0 +1,496 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<templates> |
||||
|
<t t-name="PurchaseReport" owl="1"> |
||||
|
<!-- Section contains a structure for the purchase report, including a filter |
||||
|
view and a table view. It has div elements for the filter view and table view, |
||||
|
with respective classes for styling. --> |
||||
|
<div class=""> |
||||
|
<div> |
||||
|
<center> |
||||
|
<h1 style="margin: 20px;">Purchase Report</h1> |
||||
|
</center> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="print-btns"> |
||||
|
<div class="sub_container_left" |
||||
|
style="width: 285px; margin-left: 36px;"> |
||||
|
<div class="report_print"> |
||||
|
<button type="button" class="btn btn-primary" id="pdf" |
||||
|
style="float: left; margin-right: 9px;" |
||||
|
t-on-click="printPdf"> |
||||
|
Print (PDF) |
||||
|
</button> |
||||
|
<button type="button" class="btn btn-primary" id="xlsx" |
||||
|
t-on-click="print_xlsx"> |
||||
|
Export (XLSX) |
||||
|
</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
<br/> |
||||
|
<div class="sub_container_right"> |
||||
|
<div class="dropdown"> |
||||
|
<button class="btn btn-secondary dropdown-toggle time_range_pr" |
||||
|
type="button" id="date_chose" |
||||
|
data-bs-toggle="dropdown" aria-expanded="false"> |
||||
|
<span class="fa fa-calendar" title="Dates" role="img" |
||||
|
aria-label="Dates"/> |
||||
|
Date Range |
||||
|
</button> |
||||
|
<div class="dropdown-menu my_custom_dropdown" role="menu" |
||||
|
aria-labelledby="date_chose"> |
||||
|
<div class="form-group"> |
||||
|
<label class="" for="date_from">Start Date :</label> |
||||
|
<div class="input-group date" id="date_from" |
||||
|
data-target-input="nearest" t-on-change="onchangeFromDate"> |
||||
|
<input type="date" name="date_from" |
||||
|
t-ref="date_from" |
||||
|
class="form-control datetimepicker-input" |
||||
|
data-target="#date_from" |
||||
|
t-att-name="prefix"/> |
||||
|
<div class="input-group-append" |
||||
|
data-target="#date_from" |
||||
|
data-toggle="datetimepicker" |
||||
|
style="pointer-events: none;"> |
||||
|
</div> |
||||
|
</div> |
||||
|
<label class="" for="date_to">End Date :</label> |
||||
|
<div class="input-group date" id="date_to" |
||||
|
data-target-input="nearest" t-on-change="onchangeEndDate"> |
||||
|
<input type="date" name="date_to" |
||||
|
t-ref="date_to" |
||||
|
class="form-control datetimepicker-input" |
||||
|
data-target="#date_to" |
||||
|
t-att-name="prefix"/> |
||||
|
<div class="input-group-append" |
||||
|
data-target="#date_to" |
||||
|
data-toggle="datetimepicker" |
||||
|
style="pointer-events: none;"> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="search-Result-Selection"> |
||||
|
<div class="dropdown"> |
||||
|
<a class="btn btn-secondary dropdown-togglereport-type" |
||||
|
href="#" role="button" id="dropdownMenuLink" |
||||
|
data-bs-toggle="dropdown" aria-expanded="false"> |
||||
|
<span class="fa fa-book"/> |
||||
|
<span class="low_case dropdown-toggle">Report Type |
||||
|
: |
||||
|
</span> |
||||
|
</a> |
||||
|
<select id="selection" class="dropdown-menu report_type" |
||||
|
aria-labelledby="dropdownMenuLink" |
||||
|
t-ref="order_by" |
||||
|
name="states[]"> |
||||
|
<div role="separator" class="dropdown-divider"/> |
||||
|
<option value="report_by_order" selected="">Report |
||||
|
By Order |
||||
|
</option> |
||||
|
<option value="report_by_order_detail">Report By |
||||
|
Order Detail |
||||
|
</option> |
||||
|
<option value="report_by_product">Report By |
||||
|
Product |
||||
|
</option> |
||||
|
<option value="report_by_categories">Report By |
||||
|
Categories |
||||
|
</option> |
||||
|
<option value="report_by_purchase_representative"> |
||||
|
Report By Purchase Representative |
||||
|
</option> |
||||
|
<option value="report_by_state">Report By |
||||
|
State |
||||
|
</option> |
||||
|
</select> |
||||
|
<span id="report_res" t-out="reportLabel"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="apply_filter"> |
||||
|
<button type="button" id="apply_filter" |
||||
|
class="btn btn-primary" t-on-click="applyFilter"> |
||||
|
Apply |
||||
|
</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="overflow-auto" style="height: 70vh; padding:10px"> |
||||
|
<div t-if="state.order_by == 'report_by_order'"> |
||||
|
<div class="table_main_view"> |
||||
|
<table cellspacing="0" width="100%"> |
||||
|
<thead> |
||||
|
<tr class="table_pr_head"> |
||||
|
<th>Order</th> |
||||
|
<th class="mon_fld">Date Order</th> |
||||
|
<th class="mon_fld">Customer</th> |
||||
|
<th class="mon_fld">Purchase Representative</th> |
||||
|
<th class="mon_fld">Total Qty</th> |
||||
|
<th class="mon_fld">Amount Total</th> |
||||
|
<th class="mon_fld">Note</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="state.order_line" |
||||
|
t-as="dynamic_purchase_report" |
||||
|
t-key="dynamic_purchase_report_index"> |
||||
|
<tr style="border: 1.5px solid black;" |
||||
|
class="pr-line" |
||||
|
t-att-data-account-id="dynamic_purchase_report['id']" |
||||
|
t-attf-data-target=".a{{dynamic_purchase_report['id']}}"> |
||||
|
<td> |
||||
|
<t t-if="dynamic_purchase_report['id']"> |
||||
|
<div class="dropdown dropdown-toggle"> |
||||
|
<a data-toggle="dropdown" |
||||
|
href="#" |
||||
|
id="table_toggle_btn" |
||||
|
data-bs-toggle="dropdown" |
||||
|
aria-expanded="false"> |
||||
|
<span class="caret"/> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['name']"/> |
||||
|
</span> |
||||
|
</a> |
||||
|
<ul class="dropdown-menu" |
||||
|
role="menu" |
||||
|
aria-labelledby="table_toggle_btn"> |
||||
|
<li> |
||||
|
<a class="view_purchase_order" |
||||
|
tabindex="-1" |
||||
|
href="#" |
||||
|
t-att-id="dynamic_purchase_report['id']" |
||||
|
t-on-click="viewPurchaseOrder"> |
||||
|
View Purchase Order |
||||
|
</a> |
||||
|
</li> |
||||
|
</ul> |
||||
|
</div> |
||||
|
</t> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['date_order']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['partner']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['salesman']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['sum']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['amount_total']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['notes']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
</div> |
||||
|
<!--Report for order detail--> |
||||
|
<div t-if="state.order_by == 'report_by_order_detail'"> |
||||
|
<div class="table_main_view"> |
||||
|
<table cellspacing="0" width="100%"> |
||||
|
<thead> |
||||
|
<tr class="table_pr_head"> |
||||
|
<th>Order</th> |
||||
|
<th class="mon_fld">Date Order</th> |
||||
|
<th class="mon_fld">Customer</th> |
||||
|
<th class="mon_fld">Purchase Representative</th> |
||||
|
<th class="mon_fld">Product Code</th> |
||||
|
<th class="mon_fld">Product Name</th> |
||||
|
<th class="mon_fld">Price unit</th> |
||||
|
<th class="mon_fld">Qty</th> |
||||
|
<th class="mon_fld">Price Subtotal</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-log="state.order_line"/> |
||||
|
<t t-foreach="state.order_line" |
||||
|
t-as="dynamic_purchase_report" |
||||
|
t-key="dynamic_purchase_report_index"> |
||||
|
<tr style="border: 1.5px solid black;" |
||||
|
class="pr-line" |
||||
|
t-att-data-account-id="dynamic_purchase_report['id']" |
||||
|
t-attf-data-target=".a{{dynamic_purchase_report['id']}}"> |
||||
|
<td> |
||||
|
<div class="dropdown dropdown-toggle"> |
||||
|
<a data-toggle="dropdown" href="#" |
||||
|
id="table_toggle_btn" |
||||
|
data-bs-toggle="dropdown" |
||||
|
aria-expanded="false"> |
||||
|
<span class="caret"/> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['name']"/> |
||||
|
</span> |
||||
|
</a> |
||||
|
<ul class="dropdown-menu" |
||||
|
role="menu" |
||||
|
aria-labelledby="table_toggle_btn"> |
||||
|
<li> |
||||
|
<a class="view_purchase_order" |
||||
|
tabindex="-1" href="#" |
||||
|
t-att-id="dynamic_purchase_report['id']"> |
||||
|
View Purchase Order |
||||
|
</a> |
||||
|
</li> |
||||
|
</ul> |
||||
|
</div> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['date_order']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['partner']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['salesman']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['default_code']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['product']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['price_unit']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['sum']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['price_subtotal']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
</div> |
||||
|
<!-- Report for product --> |
||||
|
<div t-if="state.order_by == 'report_by_product'"> |
||||
|
<div class="table_main_view"> |
||||
|
<table cellspacing="0" width="100%"> |
||||
|
<thead> |
||||
|
<tr class="table_pr_head"> |
||||
|
<th>Category</th> |
||||
|
<th class="mon_fld">Product Code</th> |
||||
|
<th class="mon_fld">Product Name</th> |
||||
|
<th class="mon_fld">Qty</th> |
||||
|
<th class="mon_fld">Amount Total</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="state.order_line" |
||||
|
t-as="dynamic_purchase_report" |
||||
|
t-key="dynamic_purchase_report_index"> |
||||
|
<tr style="border: 1.5px solid black;" |
||||
|
class="pr-line" |
||||
|
t-att-data-account-id="dynamic_purchase_report['id']" |
||||
|
t-attf-data-target=".a{{dynamic_purchase_report['id']}}"> |
||||
|
<td> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['name']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['default_code']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['product']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['qty']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['amount_total']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
</div> |
||||
|
<!-- Report for Categories --> |
||||
|
<div t-if="state.order_by == 'report_by_categories'"> |
||||
|
<div class="table_main_view"> |
||||
|
<table cellspacing="0" width="100%"> |
||||
|
<thead> |
||||
|
<tr class="table_pr_head"> |
||||
|
<th>Category</th> |
||||
|
<th class="mon_fld">Qty</th> |
||||
|
<th class="mon_fld">Amount Total</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="state.order_line" |
||||
|
t-as="dynamic_purchase_report" |
||||
|
t-key="dynamic_purchase_report_index"> |
||||
|
<tr style="border: 1.5px solid black;" |
||||
|
class="pr-line" |
||||
|
t-att-data-account-id="dynamic_purchase_report['id']" |
||||
|
t-attf-data-target=".a{{dynamic_purchase_report['id']}}"> |
||||
|
<td style="border: 0px solid black;"> |
||||
|
<t t-esc="dynamic_purchase_report['name']"/> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['qty']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['amount_total']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
</div> |
||||
|
<!-- Report for purchase_representative --> |
||||
|
<div t-if="state.order_by == 'report_by_purchase_representative'"> |
||||
|
<div class="table_main_view"> |
||||
|
<table cellspacing="0" width="100%"> |
||||
|
<thead> |
||||
|
<tr class="table_pr_head"> |
||||
|
<th>Purchase Representative</th> |
||||
|
<th class="mon_fld">Total Order</th> |
||||
|
<th class="mon_fld">Total Qty</th> |
||||
|
<th class="mon_fld">Total Amount</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="state.order_line" |
||||
|
t-as="dynamic_purchase_report" |
||||
|
t-key="dynamic_purchase_report_index"> |
||||
|
<tr style="border: 1.5px solid black;" |
||||
|
class="pr-line" |
||||
|
data-toggle="collapse" |
||||
|
t-att-data-account-id="dynamic_purchase_report['id']" |
||||
|
t-attf-data-target=".a{{dynamic_purchase_report['id']}}"> |
||||
|
<td style="border: 0px solid black;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['name']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['order']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['qty']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['amount']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
</div> |
||||
|
<!-- Report for State --> |
||||
|
<div t-if="state.order_by == 'report_by_state'"> |
||||
|
<div class="table_main_view"> |
||||
|
<table cellspacing="0" width="100%"> |
||||
|
<thead> |
||||
|
<tr class="table_pr_head"> |
||||
|
<th>State</th> |
||||
|
<th class="mon_fld">Total Count</th> |
||||
|
<th class="mon_fld">Quantity</th> |
||||
|
<th class="mon_fld">Amount</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="state.order_line" |
||||
|
t-as="dynamic_purchase_report" |
||||
|
t-key="dynamic_purchase_report_index"> |
||||
|
<tr style="border: 1.5px solid black;" |
||||
|
class="pr-line" |
||||
|
data-toggle="collapse" |
||||
|
t-att-data-account-id="dynamic_purchase_report['id']" |
||||
|
t-attf-data-target=".a{{dynamic_purchase_report['id']}}"> |
||||
|
<td style="border: 0px solid black;"> |
||||
|
<span> |
||||
|
<t t-if="dynamic_purchase_report['state'] == 'sent'"> |
||||
|
RFQ Sent |
||||
|
</t> |
||||
|
<t t-if="dynamic_purchase_report['state'] == 'purchase'"> |
||||
|
Purchase Order |
||||
|
</t> |
||||
|
<t t-if="dynamic_purchase_report['state'] == 'draft'"> |
||||
|
RFQ |
||||
|
</t> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['order']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['qty']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
<td style="text-align:center;"> |
||||
|
<span> |
||||
|
<t t-esc="dynamic_purchase_report['amount']"/> |
||||
|
</span> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</t> |
||||
|
</templates> |