Browse Source

Jul 24 : [UPDT] Bug Fixed 'manufacturing_reports'

pull/275/head
AjmalCybro 2 years ago
parent
commit
699443d7c8
  1. 35
      manufacturing_reports/README.rst
  2. 10
      manufacturing_reports/__init__.py
  3. 31
      manufacturing_reports/__manifest__.py
  4. 8
      manufacturing_reports/controllers/__init__.py
  5. 16
      manufacturing_reports/controllers/main.py
  6. 9
      manufacturing_reports/doc/RELEASE_NOTES.md
  7. 3
      manufacturing_reports/reports/mrp_report.xml
  8. 44
      manufacturing_reports/reports/mrp_report_template.xml
  9. 70
      manufacturing_reports/reports/mrp_report_templates.xml
  10. 3
      manufacturing_reports/security/ir.model.access.csv
  11. BIN
      manufacturing_reports/static/description/assets/screenshots/14_1.png
  12. BIN
      manufacturing_reports/static/description/assets/screenshots/14_2.png
  13. BIN
      manufacturing_reports/static/description/banner.png
  14. 52
      manufacturing_reports/static/description/index.html
  15. 50
      manufacturing_reports/static/src/js/action_manager.js
  16. 10
      manufacturing_reports/views/action_manager.xml
  17. 10
      manufacturing_reports/views/manufacturing_report_menus.xml
  18. 9
      manufacturing_reports/views/menu_items.xml
  19. 10
      manufacturing_reports/wizards/__init__.py
  20. 104
      manufacturing_reports/wizards/mrp_report_wizard.py
  21. 31
      manufacturing_reports/wizards/mrp_wizard_view.xml

35
manufacturing_reports/README.rst

@ -1,35 +1,29 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
Manufacturing Reports
=====================
Provides an option to print XLSX and PDF report for the Manufacturing module.
Invoice From Stock Picking
==========================
* Enables the option for creating invoice from stock picking
Installation
============
- www.odoo.com/documentation/15.0/setup/install.html
- www.odoo.com/documentation/14.0/setup/install.html
- Install our custom addon
Company
License
-------
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__
GNU AFFERO GENERAL PUBLIC LICENSE, Version 3 (AGPLv3)
(http://www.gnu.org/licenses/agpl.html)
License
Company
-------
Affero General Public License v3.0 (AGPL v3)
(https://www.gnu.org/licenses/agpl-3.0-standalone.html)
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__
Credits
-------
* Developer: (V9) Cybrosys Technologies.
(V14) Javid A
(V15) Javid A
* Developer:
V14 Javid A
Contacts
--------
* Mail Contact : odoo@cybrosys.com
* Website : https://cybrosys.com
Bug Tracker
-----------
@ -37,13 +31,10 @@ Bugs are tracked on GitHub Issues. In case of trouble, please check there if you
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/>`__
For support and more information, please visit https://www.cybrosys.com
Further information
===================
HTML Description: `<static/description/index.html>`__
HTML Description: `<static/description/index.html>`__

10
manufacturing_reports/__init__.py

@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
###############################################################################
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Javid A (odoo@cybrosys.com)
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Javid A(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
@ -18,6 +18,6 @@
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#############################################################################
from . import wizards
from . import controllers
from . import wizard

31
manufacturing_reports/__manifest__.py

@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
###############################################################################
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Javid A (odoo@cybrosys.com)
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Javid A(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
@ -18,16 +18,13 @@
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#############################################################################
{
'name': 'Manufacturing Reports',
'version': '15.0.1.0.0',
'category': 'Manufacturing',
'version': '14.0.1.0.0',
'summary': 'PDF & XLS Reports For Manufacturing Module',
'description': """This module crafted by Cybrosys Technologies provides
an option to print PDF & XLS report for MRP systems,
also you can view the product image in the report. This
works well for large and small business MRP systems.""",
'description': 'PDF & XLS reports for manufacturing module with advanced filters.',
'category': 'Manufacturing',
'author': 'Cybrosys Techno Solutions',
'website': "http://www.cybrosys.com",
'company': 'Cybrosys Techno Solutions',
@ -35,16 +32,12 @@
'depends': ['base', 'mrp'],
'data': [
'security/ir.model.access.csv',
'reports/mrp_report_templates.xml',
'reports/mrp_report_views.xml',
'wizard/mrp_report_views.xml',
'views/manufacturing_report_menus.xml',
'views/action_manager.xml',
'wizards/mrp_wizard_view.xml',
'reports/mrp_report_template.xml',
'reports/mrp_report.xml',
'views/menu_items.xml',
],
'assets': {
'web.assets_backend': [
'manufacturing_reports/static/src/js/action_manager.js',
]
},
'images': ['static/description/banner.png'],
'license': 'AGPL-3',
'installable': True,

8
manufacturing_reports/controllers/__init__.py

@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
###############################################################################
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Javid A (odoo@cybrosys.com)
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Javid A(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
@ -18,5 +18,5 @@
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#############################################################################
from . import main

16
manufacturing_reports/controllers/main.py

@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
###############################################################################
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Javid A (odoo@cybrosys.com)
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Javid A(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
@ -18,7 +18,7 @@
# (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
@ -27,15 +27,11 @@ from odoo.tools import html_escape
class XLSXReportController(http.Controller):
"""Class for the controller class XLSXReportController.
Contains the function to print XLSX report."""
@http.route('/xlsx_reports', type='http', auth='user', methods=['POST'],
csrf=False)
def get_report_xlsx(self, model, options, output_format, report_name):
@http.route('/xlsx_reports', type='http', auth='user', methods=['POST'], csrf=False)
def get_report_xlsx(self, model, options, output_format, token, report_name, **kw):
uid = request.session.uid
report_obj = request.env[model].with_user(uid)
options = json.loads(options)
token = 'dummy-because-api-expects-one'
try:
if output_format == 'xlsx':
response = request.make_response(

9
manufacturing_reports/doc/RELEASE_NOTES.md

@ -1,11 +1,6 @@
## Module <manufacturing_reports>
#### 17.02.2023
#### Version 15.0.1.0.0
#### Version 14.0.1.0.0
##### ADD
- Initial commit for Manufacturing Reports
#### 10.07.2023
#### Version 15.0.1.0.0
#### UPDT
- Bug Fix for the xlsx report not printing issue in Manufacturing Reports
- Initial commit

3
manufacturing_reports/reports/mrp_report_views.xml → manufacturing_reports/reports/mrp_report.xml

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<odoo>
<!-- Manufacturing Report-->
<record id="action_mrp_report" model="ir.actions.report">
<field name="name">Manufacturing Report</field>
<field name="model">mrp.report</field>
@ -9,4 +9,5 @@
<field name="report_file">manufacturing_reports.report_mrp_order</field>
<field name="binding_type">report</field>
</record>
</odoo>

44
manufacturing_reports/reports/mrp_report_template.xml

@ -0,0 +1,44 @@
<?xml version="1.0"?>
<odoo>
<template id="report_mrp_order">
<t t-call="web.html_container">
<t t-call="web.external_layout">
<div class="page">
<h1><strong>MRP Order Report</strong></h1>
<t t-if="date_from"><p><strong>Date From : </strong>
<t t-esc="date_from"/></p></t>
<t t-if="stage"><p><strong>State : </strong>
<t t-esc="stage"/></p></t>
<table class="table table-sm table-striped mt-4">
<thead>
<tr>
<th>Reference</th>
<th>Image</th>
<th>Product</th>
<th>Quantity</th>
<th>Unit</th>
<th>Responsible</th>
<th>Start Date</th>
<th>State</th>
</tr>
</thead>
<tbody>
<tr t-foreach="mrp" t-as="rec">
<td><t t-esc="rec['name']"/></td>
<td> <img t-attf-src="data:image/png;base64,{{rec['image']}}" style="width:70%;" margin="right"/></td>
<td><t t-esc="rec['product']"/></td>
<td><t t-esc="rec['quantity']"/></td>
<td><t t-esc="rec['unit']"/></td>
<td><t t-esc="rec['responsible']"/></td>
<td><t t-esc="rec['start_date']"/></td>
<td><t t-esc="rec['state']"/></td>
</tr>
</tbody>
</table>
</div>
</t>
</t>
</template>
</odoo>

70
manufacturing_reports/reports/mrp_report_templates.xml

@ -1,70 +0,0 @@
<?xml version="1.0"?>
<odoo>
<!-- Template for the manufacturing report.-->
<template id="report_mrp_order">
<t t-call="web.html_container">
<t t-call="web.external_layout">
<div class="page">
<h1>
<strong>MRP Order Report</strong>
</h1>
<t t-if="date_from">
<p>
<strong>Date From :</strong>
<t t-esc="date_from"/>
</p>
</t>
<t t-if="stage">
<p>
<strong>State :</strong>
<t t-esc="stage"/>
</p>
</t>
<table class="table table-sm table-striped mt-4">
<thead>
<tr>
<th>Reference</th>
<th>Image</th>
<th>Product</th>
<th>Quantity</th>
<th>Unit</th>
<th>Responsible</th>
<th>Start Date</th>
<th>State</th>
</tr>
</thead>
<tbody>
<tr t-foreach="mrp" t-as="rec">
<td>
<t t-esc="rec['name']"/>
</td>
<td>
<img t-attf-src="data:image/png;base64,{{rec['image']}}"
style="width:70%;" margin="right"/>
</td>
<td>
<t t-esc="rec['product']"/>
</td>
<td>
<t t-esc="rec['quantity']"/>
</td>
<td>
<t t-esc="rec['unit']"/>
</td>
<td>
<t t-esc="rec['responsible']"/>
</td>
<td>
<t t-esc="rec['start_date']"/>
</td>
<td>
<t t-esc="rec['state']"/>
</td>
</tr>
</tbody>
</table>
</div>
</t>
</t>
</template>
</odoo>

3
manufacturing_reports/security/ir.model.access.csv

@ -1,2 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_mrp_report,access.mrp.report,model_mrp_report,base.group_user,1,1,1,1
access_mrp_report,access.mrp.report,model_mrp_report,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_mrp_report access.mrp.report model_mrp_report base.group_user 1 1 1 1
3

BIN
manufacturing_reports/static/description/assets/screenshots/14_1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 114 KiB

BIN
manufacturing_reports/static/description/assets/screenshots/14_2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 97 KiB

BIN
manufacturing_reports/static/description/banner.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 61 KiB

52
manufacturing_reports/static/description/index.html

@ -29,14 +29,17 @@
<h1 style="color: #FFFFFF; font-weight: bolder; font-size: 50px; text-align: center; margin-top: 50px;">
Manufacturing Reports</h1>
<p style="color:#FFFFFF; padding: 8px 15px; text-align: center; font-size: 24px;">
PDF & XLSX Reports For Manufacturing Module</p>
PDF & XLS Reports For Manufacturing Module</p>
<!-- END OF APP HERO -->
<img src="assets/screenshots/hero.png" class="img-responsive"
style="width: 100%; margin-left: auto; margin-right: auto;" />
</div>
</div>
</div>
</div>
<!-- NAVIGATION SECTION -->
<div class="d-flex align-items-center" style="border-bottom: 2px solid #714B67; padding: 15px 0px; margin-top: 300px;">
<div class="d-flex justify-content-center align-items-center mr-2"
@ -105,7 +108,7 @@
<div class="col-sm-12 py-4">
Manufacturing Reports is a free Cybrosys MRP software which helps to generate advanced
report for MRP module(Material requirements planning).This allows both PDF & XLS report
for MRP systems, also you can view the product image in the report. This works well for
for MRP systems. Also you can view the product image in the report. This works well for
large and small business MRP systems.
</div>
</div>
@ -124,29 +127,29 @@
<div class="col-sm-12 col-md-6">
<div class="d-flex align-items-center" style="margin-top: 40px; margin-bottom: 40px">
<img src="assets/misc/check-box.png" class="mr-2" />
<span style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">Filter manufacturing orders by product.</span>
<span style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">Community Support</span>
</div>
<div class="d-flex align-items-center" style="margin-top: 30px; margin-bottom: 30px">
<img src="assets/misc/check-box.png" class="mr-2" />
<span style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">
Filter manufacturing orders by start date.
Filter manufacturing orders based on Product
</span>
</div>
<div class="d-flex align-items-center" style="margin-top: 30px; margin-bottom: 30px">
<img src="assets/misc/check-box.png" class="mr-2" />
<span style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">
Filter manufacturing orders by responsible person.
Set start to print the orders from that date
</span>
</div>
<div class="d-flex align-items-center" style="margin-top: 30px; margin-bottom: 30px">
<img src="assets/misc/check-box.png" class="mr-2" />
<span style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">
Filter orders based on the status of the production.</span>
Filter orders based on the status of the production</span>
</div>
<div class="d-flex align-items-center" style="margin-top: 30px; margin-bottom: 30px">
<img src="assets/misc/check-box.png" class="mr-2" />
<span style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">
Compatible with Community, Enterprise and Odoo.sh.</span>
Enable filter based on the responsible person for production</span>
</div>
</div>
</div>
@ -177,17 +180,21 @@
Start Date and Responsible Person</p>
<img src="assets/screenshots/14_2.png" class="img-thumbnail">
</div>
<div style="display: block; margin: 30px auto;">
<p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;">
PDF report with images.</p>
<img src="assets/screenshots/14_3.png" class="img-thumbnail">
</div>
<div style="display: block; margin: 30px auto;">
<p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;">
XLS report
</p>
<img src="assets/screenshots/14_4.png" class="img-thumbnail">
</div>
</div>
</div>
<!-- END OF SCREENSHOTS SECTION -->
@ -265,7 +272,8 @@
class="carousel-control-prev-icon"><i class="fa fa-chevron-left"
style="font-size:24px"></i></span>
</a> <a class="carousel-control-next" href="#demo1" data-slide="next" style="width:35px; color:#000">
<span class="carousel-control-next-icon"><i class="fa fa-chevron-right" style="font-size:24px"></i></span>
<span class="carousel-control-next-icon"><i class="fa fa-chevron-right"
style="font-size:24px"></i></span>
</a>
</div>
</div>
@ -273,6 +281,7 @@
<!-- END OF RELATED PRODUCTS -->
<!-- OUR SERVICES -->
<div class="d-flex align-items-center" style="border-bottom: 2px solid #714B67; padding: 15px 0px;">
<div class="d-flex justify-content-center align-items-center mr-2"
style="background-color: #F5F5F5; border-radius: 0px; width: 40px; height: 40px;">
@ -281,6 +290,7 @@
<h2 class="mt-2" style="font-family: 'Montserrat', sans-serif; font-size: 24px; font-weight: bold;">Our Services
</h2>
</div>
<div class="container my-5">
<div class="row">
<div class="col-lg-4 d-flex flex-column justify-content-center align-items-center my-4">
@ -292,6 +302,7 @@
Odoo
Customization</h6>
</div>
<div class="col-lg-4 d-flex flex-column justify-content-center align-items-center my-4">
<div class="d-flex justify-content-center align-items-center mx-3 my-3"
style="background-color: #ff6b6b !important; border-radius: 15px !important; height: 80px; width: 80px;">
@ -301,6 +312,7 @@
Odoo
Implementation</h6>
</div>
<div class="col-lg-4 d-flex flex-column justify-content-center align-items-center my-4">
<div class="d-flex justify-content-center align-items-center mx-3 my-3"
style="background-color: #6462CD !important; border-radius: 15px !important; height: 80px; width: 80px;">
@ -310,6 +322,8 @@
Odoo
Support</h6>
</div>
<div class="col-lg-4 d-flex flex-column justify-content-center align-items-center my-4">
<div class="d-flex justify-content-center align-items-center mx-3 my-3"
style="background-color: #ffa801 !important; border-radius: 15px !important; height: 80px; width: 80px;">
@ -320,6 +334,7 @@
Odoo
Developer</h6>
</div>
<div class="col-lg-4 d-flex flex-column justify-content-center align-items-center my-4">
<div class="d-flex justify-content-center align-items-center mx-3 my-3"
style="background-color: #54a0ff !important; border-radius: 15px !important; height: 80px; width: 80px;">
@ -329,6 +344,7 @@
Odoo
Integration</h6>
</div>
<div class="col-lg-4 d-flex flex-column justify-content-center align-items-center my-4">
<div class="d-flex justify-content-center align-items-center mx-3 my-3"
style="background-color: #6d7680 !important; border-radius: 15px !important; height: 80px; width: 80px;">
@ -338,6 +354,8 @@
Odoo
Migration</h6>
</div>
<div class="col-lg-4 d-flex flex-column justify-content-center align-items-center my-4">
<div class="d-flex justify-content-center align-items-center mx-3 my-3"
style="background-color: #786fa6 !important; border-radius: 15px !important; height: 80px; width: 80px;">
@ -347,6 +365,7 @@
Odoo
Consultancy</h6>
</div>
<div class="col-lg-4 d-flex flex-column justify-content-center align-items-center my-4">
<div class="d-flex justify-content-center align-items-center mx-3 my-3"
style="background-color: #f8a5c2 !important; border-radius: 15px !important; height: 80px; width: 80px;">
@ -356,6 +375,7 @@
Odoo
Implementation</h6>
</div>
<div class="col-lg-4 d-flex flex-column justify-content-center align-items-center my-4">
<div class="d-flex justify-content-center align-items-center mx-3 my-3"
style="background-color: #e6be26 !important; border-radius: 15px !important; height: 80px; width: 80px;">
@ -366,10 +386,13 @@
Licensing Consultancy</h6>
</div>
</div>
</div>
<!-- END OF OUR SERVICES -->
<!-- END OF END OF OUR SERVICES -->
<!-- OUR INDUSTRIES -->
<div class="d-flex align-items-center" style="border-bottom: 2px solid #714B67; padding: 15px 0px;">
<div class="d-flex justify-content-center align-items-center mr-2"
style="background-color: #F5F5F5; border-radius: 0px; width: 40px; height: 40px;">
@ -379,6 +402,7 @@
Industries
</h2>
</div>
<div class="container my-5">
<div class="row">
<div class="col-lg-3">
@ -394,6 +418,7 @@
sell your products</p>
</div>
</div>
<div class="col-lg-3">
<div class="my-4 d-flex flex-column justify-content-center"
style="background-color: #f6f8f9 !important; border-radius: 0px; padding: 2rem !important; height: 250px !important;">
@ -407,6 +432,7 @@
and convivial experience</p>
</div>
</div>
<div class="col-lg-3">
<div class="my-4 d-flex flex-column justify-content-center"
style="background-color: #f6f8f9 !important; border-radius: 0px; padding: 2rem !important; height: 250px !important;">
@ -419,6 +445,7 @@
educational management</p>
</div>
</div>
<div class="col-lg-3">
<div class="my-4 d-flex flex-column justify-content-center"
style="background-color: #f6f8f9 !important; border-radius: 0px; padding: 2rem !important; height: 250px !important;">
@ -431,6 +458,7 @@
schedule your operations</p>
</div>
</div>
<div class="col-lg-3">
<div class="my-4 d-flex flex-column justify-content-center"
style="background-color: #f6f8f9 !important; border-radius: 0px; padding: 2rem !important; height: 250px !important;">
@ -444,6 +472,7 @@
awe-inspiring product pages</p>
</div>
</div>
<div class="col-lg-3">
<div class="my-4 d-flex flex-column justify-content-center"
style="background-color: #f6f8f9 !important; border-radius: 0px; padding: 2rem !important; height: 250px !important;">
@ -456,6 +485,7 @@
services and invoice</p>
</div>
</div>
<div class="col-lg-3">
<div class="my-4 d-flex flex-column justify-content-center"
style="background-color: #f6f8f9 !important; border-radius: 0px; padding: 2rem !important; height: 250px !important;">
@ -468,6 +498,7 @@
restaurant methodically</p>
</div>
</div>
<div class="col-lg-3">
<div class="my-4 d-flex flex-column justify-content-center"
style="background-color: #f6f8f9 !important; border-radius: 0px; padding: 2rem !important; height: 250px !important;">
@ -483,7 +514,8 @@
</div>
</div>
</div>
<!-- END OF OUR INDUSTRIES -->
<!-- END OF END OF OUR INDUSTRIES -->
<!-- SUPPORT -->
<div class="d-flex align-items-center" style="border-bottom: 2px solid #714B67; padding: 15px 0px;">

50
manufacturing_reports/static/src/js/action_manager.js

@ -1,23 +1,31 @@
/** @odoo-module */
import { registry } from "@web/core/registry";
import { download } from "@web/core/network/download";
import framework from 'web.framework';
import session from 'web.session';
odoo.define('manufacturing_reports .action_manager', function (require) {
"use strict";
/**
* @override
* Add 'xlsx' report type to the report handler
* The purpose of this file is to add the actions of type
* 'ir_actions_xlsx_download' to the ActionManager.
*/
registry.category("ir.actions.report handlers").add("xlsx", async (action) => {
if (action.report_type === 'xlsx') {
framework.blockUI();
var def = $.Deferred();
session.get_file({
url: '/xlsx_reports',
data: action.data,
success: def.resolve.bind(def),
error: (error) => this.call('crash_manager', 'rpc_error', error),
complete: framework.unblockUI,
});
return def;
}
});
var ActionManager = require('web.ActionManager');
var framework = require('web.framework');
var session = require('web.session');
ActionManager.include({
_executexlsxReportDownloadAction: function (action) {
framework.blockUI();
var def = $.Deferred();
session.get_file({
url: '/xlsx_reports',
data: action.data,
success: def.resolve.bind(def),
error: (error) => this.call('crash_manager', 'rpc_error', error),
complete: framework.unblockUI,
});
return def;
},
_handleAction: function (action, options) {
if (action.report_type === 'xlsx') {
return this._executexlsxReportDownloadAction(action, options);
}
return this._super.apply(this, arguments);
},
});
});

10
manufacturing_reports/views/action_manager.xml

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>
<template id="assets_backend" name="xls_assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="manufacturing_reports/static/src/js/action_manager.js"/>
</xpath>
</template>
</data>
</odoo>

10
manufacturing_reports/views/manufacturing_report_menus.xml

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Menu for manufacturing report-->
<menuitem id="menu_mrp_reports"
parent="mrp.menu_mrp_reporting"
name="Manufacturing Reports"
action="manufacturing_reports.mrp_report_action"
sequence="5"/>
</odoo>

9
manufacturing_reports/views/menu_items.xml

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>
<menuitem id="menu_mrp_reports" parent="mrp.menu_mrp_reporting" name="Manufacturing Reports"
action="mrp_wizard_action" sequence="5"/>
</data>
</odoo>

10
manufacturing_reports/wizard/__init__.py → manufacturing_reports/wizards/__init__.py

@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
###############################################################################
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Javid A (odoo@cybrosys.com)
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Javid A(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
@ -18,5 +18,5 @@
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
from . import mrp_report
#############################################################################
from . import mrp_report_wizard

104
manufacturing_reports/wizard/mrp_report.py → manufacturing_reports/wizards/mrp_report_wizard.py

@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
###############################################################################
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Javid A (odoo@cybrosys.com)
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Javid A(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
@ -18,7 +18,7 @@
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#############################################################################
import io
import xlsxwriter
from odoo import fields, models
@ -26,30 +26,18 @@ from odoo.tools import date_utils
from odoo.tools.safe_eval import json
class MrpReport(models.TransientModel):
"""Class for the transient model mrp report."""
class MrpReportWizard(models.Model):
_name = 'mrp.report'
_description = 'MRP Report'
filter = fields.Boolean(string='Enable filter by date',
help='The reports can be filtered by date if '
'enabled.')
date_from = fields.Date(string='Start Date',
help='Start date for the report data.')
filter_user = fields.Boolean(string='Filter On Responsible',
help='The reports can be filtered by '
'responsible person, if enabled.')
responsible_id = fields.Many2many('res.users', string='Responsible',
help='Responsible person for the '
'records.')
product_id = fields.Many2many('product.product', string='Product',
help='Id of the product in the manufacturing'
' order.')
filter = fields.Boolean(string='Enable filter by date')
date_from = fields.Date(string='Start Date')
filter_user = fields.Boolean(string='Filter On Responsible')
responsible_id = fields.Many2many('res.users', string='Responsible')
product_id = fields.Many2many('product.product', string='Product')
stage = fields.Selection(
[('confirmed', 'Confirmed'), ('planned', 'Planned'),
('progress', 'In Progress'),
('done', 'Done'), ('cancel', 'Cancelled')], string="Filter State",
help='Stage of the manufacturing order.')
[('confirmed', 'Confirmed'), ('planned', 'Planned'), ('progress', 'In Progress'),
('done', 'Done'), ('cancel', 'Cancelled')], string="Filter State")
def check_report(self):
"""
@ -60,8 +48,7 @@ class MrpReport(models.TransientModel):
if self.product_id and self.stage and self.date_from and self.responsible_id:
mrp_orders = self.env['mrp.production'].search(
[('product_id', 'in', self.product_id.ids),
('state', '=', self.stage),
('date_planned_start', '>=', self.date_from),
('state', '=', self.stage), ('date_planned_start', '>=', self.date_from),
('user_id', 'in', self.responsible_id.ids)])
elif self.product_id and self.stage and self.date_from:
mrp_orders = self.env['mrp.production'].search(
@ -71,8 +58,7 @@ class MrpReport(models.TransientModel):
elif self.product_id and self.stage and self.responsible_id:
mrp_orders = self.env['mrp.production'].search(
[('product_id', 'in', self.product_id.ids),
('state', '=', self.stage),
('user_id', 'in', self.responsible_id.ids)])
('state', '=', self.stage), ('user_id', 'in', self.responsible_id.ids)])
elif self.product_id and self.date_from and self.responsible_id:
mrp_orders = self.env['mrp.production'].search(
[('product_id', 'in', self.product_id.ids),
@ -80,13 +66,11 @@ class MrpReport(models.TransientModel):
('user_id', 'in', self.responsible_id.ids)])
elif self.stage and self.date_from and self.responsible_id:
mrp_orders = self.env['mrp.production'].search(
[('state', '=', self.stage),
('date_planned_start', '>=', self.date_from),
[('state', '=', self.stage), ('date_planned_start', '>=', self.date_from),
('user_id', 'in', self.responsible_id.ids)])
elif self.product_id and self.stage:
mrp_orders = self.env['mrp.production'].search(
[('product_id', 'in', self.product_id.ids),
('state', '=', self.stage)])
[('product_id', 'in', self.product_id.ids), ('state', '=', self.stage)])
elif self.product_id and self.date_from:
mrp_orders = self.env['mrp.production'].search(
[('product_id', 'in', self.product_id.ids),
@ -101,8 +85,7 @@ class MrpReport(models.TransientModel):
('date_planned_start', '>=', self.date_from)])
elif self.stage and self.responsible_id:
mrp_orders = self.env['mrp.production'].search(
[('state', '=', self.stage),
('user_id', 'in', self.responsible_id.ids)])
[('state', '=', self.stage), ('user_id', 'in', self.responsible_id.ids)])
elif self.date_from and self.responsible_id:
mrp_orders = self.env['mrp.production'].search(
[('date_planned_start', '>=', self.date_from),
@ -131,7 +114,6 @@ class MrpReport(models.TransientModel):
'start_date': rec.date_planned_start,
'state': rec.state,
})
print('orders', orders)
data = {
'date_from': self.date_from,
'stage': self.stage,
@ -156,19 +138,16 @@ class MrpReport(models.TransientModel):
if self.product_id and self.stage and self.date_from and self.responsible_id:
mrp_orders = self.env['mrp.production'].search(
[('product_id', 'in', self.product_id.ids),
('state', '=', self.stage),
('date_planned_start', '>=', self.date_from),
('state', '=', self.stage), ('date_planned_start', '>=', self.date_from),
('user_id', 'in', self.responsible_id.ids)])
elif self.product_id and self.stage and self.date_from:
mrp_orders = self.env['mrp.production'].search(
[('product_id', 'in', self.product_id.ids),
('state', '=', self.stage),
('date_planned_start', '>=', self.date_from)])
('state', '=', self.stage), ('date_planned_start', '>=', self.date_from)])
elif self.product_id and self.stage and self.responsible_id:
mrp_orders = self.env['mrp.production'].search(
[('product_id', 'in', self.product_id.ids),
('state', '=', self.stage),
('user_id', 'in', self.responsible_id.ids)])
('state', '=', self.stage), ('user_id', 'in', self.responsible_id.ids)])
elif self.product_id and self.date_from and self.responsible_id:
mrp_orders = self.env['mrp.production'].search(
[('product_id', 'in', self.product_id.ids),
@ -176,13 +155,11 @@ class MrpReport(models.TransientModel):
('user_id', 'in', self.responsible_id.ids)])
elif self.stage and self.date_from and self.responsible_id:
mrp_orders = self.env['mrp.production'].search(
[('state', '=', self.stage),
('date_planned_start', '>=', self.date_from),
[('state', '=', self.stage), ('date_planned_start', '>=', self.date_from),
('user_id', 'in', self.responsible_id.ids)])
elif self.product_id and self.stage:
mrp_orders = self.env['mrp.production'].search(
[('product_id', 'in', self.product_id.ids),
('state', '=', self.stage)])
[('product_id', 'in', self.product_id.ids), ('state', '=', self.stage)])
elif self.product_id and self.date_from:
mrp_orders = self.env['mrp.production'].search(
[('product_id', 'in', self.product_id.ids),
@ -193,12 +170,10 @@ class MrpReport(models.TransientModel):
('user_id', 'in', self.responsible_id.ids)])
elif self.stage and self.date_from:
mrp_orders = self.env['mrp.production'].search(
[('state', '=', self.stage),
('date_planned_start', '>=', self.date_from)])
[('state', '=', self.stage), ('date_planned_start', '>=', self.date_from)])
elif self.stage and self.responsible_id:
mrp_orders = self.env['mrp.production'].search(
[('state', '=', self.stage),
('user_id', 'in', self.responsible_id.ids)])
[('state', '=', self.stage), ('user_id', 'in', self.responsible_id.ids)])
elif self.date_from and self.responsible_id:
mrp_orders = self.env['mrp.production'].search(
[('date_planned_start', '>=', self.date_from),
@ -234,17 +209,14 @@ class MrpReport(models.TransientModel):
'mrp': orders
}
return self.env.ref(
'manufacturing_reports.action_mrp_report').report_action(self,
data=data)
'manufacturing_reports.action_mrp_report').report_action(self, data=data)
def get_xlsx_report(self, data, response):
print('get_xlsx_report(self, data, response)')
output = io.BytesIO()
workbook = xlsxwriter.Workbook(output, {'in_memory': True})
sheet = workbook.add_worksheet()
cell_format = workbook.add_format({'font_size': '12px', 'bold': True})
head = workbook.add_format(
{'align': 'center', 'bold': True, 'font_size': '20px'})
head = workbook.add_format({'align': 'center', 'bold': True, 'font_size': '20px'})
txt_head = workbook.add_format({'font_size': '12px'})
sheet.set_column('B:B', 15)
sheet.set_column('C:C', 15)
@ -264,21 +236,21 @@ class MrpReport(models.TransientModel):
row = 9
col = 2
sheet.write(row, col, 'Reference', cell_format)
sheet.write(row, col + 1, 'Product', cell_format)
sheet.write(row, col + 2, 'Quantity', cell_format)
sheet.write(row, col + 3, 'Unit', cell_format)
sheet.write(row, col + 4, 'Responsible', cell_format)
sheet.write(row, col + 5, 'Start Date', cell_format)
sheet.write(row, col + 6, 'State', cell_format)
sheet.write(row, col+1, 'Product', cell_format)
sheet.write(row, col+2, 'Quantity', cell_format)
sheet.write(row, col+3, 'Unit', cell_format)
sheet.write(row, col+4, 'Responsible', cell_format)
sheet.write(row, col+5, 'Start Date', cell_format)
sheet.write(row, col+6, 'State', cell_format)
for rec in data['mrp']:
row += 1
sheet.write(row, col, rec['name'])
sheet.write(row, col + 1, rec['product'])
sheet.write(row, col + 2, rec['quantity'])
sheet.write(row, col + 3, rec['unit'])
sheet.write(row, col + 4, rec['responsible'])
sheet.write(row, col + 5, rec['start_date'])
sheet.write(row, col + 6, rec['state'])
sheet.write(row, col+1, rec['product'])
sheet.write(row, col+2, rec['quantity'])
sheet.write(row, col+3, rec['unit'])
sheet.write(row, col+4, rec['responsible'])
sheet.write(row, col+5, rec['start_date'])
sheet.write(row, col+6, rec['state'])
workbook.close()
output.seek(0)
response.stream.write(output.read())

31
manufacturing_reports/wizard/mrp_report_views.xml → manufacturing_reports/wizards/mrp_wizard_view.xml

@ -1,8 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Form view for mrp.report-->
<record id="mrp_report_view_form" model="ir.ui.view">
<field name="name">mrp.report.view.form</field>
<record id="mrp_wizard_action" model="ir.actions.act_window">
<field name="name">MRP Report</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.report</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record id="mrp_wizard_view" model="ir.ui.view">
<field name="name">MRP Report</field>
<field name="model">mrp.report</field>
<field name="arch" type="xml">
<form string="MRP Report">
@ -21,23 +29,14 @@
</group>
</group>
<footer>
<button name="check_report" string="Export xls"
type="object" class="oe_highlight"
icon='fa-download'/>
<button name="print_pdf" string="Print Pdf" type="object"
class="oe_highlight" icon='fa-download'/>
<button name="check_report" string="Export xls" type="object" class="oe_highlight" icon='fa-download'/>
<button name="print_pdf" string="Print Pdf" type="object" class="oe_highlight" icon='fa-download'/>
or
<button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
<!-- Action for the mrp.report-->
<record id="mrp_report_action" model="ir.actions.act_window">
<field name="name">MRP Report</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.report</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</odoo>
Loading…
Cancel
Save