@ -0,0 +1,45 @@ |
|||||
|
.. 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 |
||||
|
|
||||
|
Lot and Serial Number Expiry Report |
||||
|
=================================== |
||||
|
Generates a report based on lot and serial number expiry dates or product expiry date. |
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
The user should be added to the security group: Administrator(Inventory/ Stock) inorder to get access to the new menu. |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
||||
|
|
||||
|
License |
||||
|
------- |
||||
|
GNU AFFERO GENERAL PUBLIC LICENSE, Version 3 (AGPLv3) |
||||
|
(https://www.gnu.org/licenses/agpl-3.0-standalone.html) |
||||
|
|
||||
|
Credits |
||||
|
------- |
||||
|
Developer : (V18) Nivedhya T, Contact: odoo@cybrosys.com |
||||
|
|
||||
|
Contacts |
||||
|
-------- |
||||
|
* Mail Contact : odoo@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 https://www.cybrosys.com |
||||
|
|
||||
|
Further information |
||||
|
=================== |
||||
|
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU 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 wizard |
@ -0,0 +1,47 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU 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': 'Lot and Serial Number Expiry Report', |
||||
|
'version': '18.0.1.0.0', |
||||
|
'category': 'Warehouse', |
||||
|
'summary': """Generates a detailed Lot and Serial Number Expiry based on |
||||
|
their expiry details.""", |
||||
|
'description': """This module helps you to print a report about tracking |
||||
|
products (lot/serial) based on their expiry date. You can filter your |
||||
|
report based on different criteria.""", |
||||
|
'author': 'Cybrosys Techno Solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer': 'Cybrosys Techno Solutions', |
||||
|
'website': 'https://www.cybrosys.com', |
||||
|
'depends': ['stock'], |
||||
|
'data': [ |
||||
|
'security/ir.model.access.csv', |
||||
|
'report/product_batch_report_reports.xml', |
||||
|
'report/product_batch_report_templates.xml', |
||||
|
'wizard/product_batch_report_views.xml', |
||||
|
], |
||||
|
'images': ['static/description/banner.jpg'], |
||||
|
'license': 'AGPL-3', |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'application': False, |
||||
|
} |
@ -0,0 +1,6 @@ |
|||||
|
## Module <product_batch_report> |
||||
|
|
||||
|
#### 08.10.2024 |
||||
|
#### Version 18.0.1.0.0 |
||||
|
#### ADD |
||||
|
- Initial commit for Lot and Serial Number Expiry Report |
@ -0,0 +1,12 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<odoo> |
||||
|
<!--report action for Lot/Serial Number Expiry PDF Report--> |
||||
|
<record id="product_batch_report_action_report" model="ir.actions.report"> |
||||
|
<field name="name">Lot/Serial Number Expiry PDF Report</field> |
||||
|
<field name="model">product.batch.report</field> |
||||
|
<field name="report_type">qweb-pdf</field> |
||||
|
<field name="report_name">product_batch_report.product_batch_report_template</field> |
||||
|
<field name="report_file">product_batch_report.product_batch_report_template</field> |
||||
|
<field name="attachment_use">True</field> |
||||
|
</record> |
||||
|
</odoo> |
@ -0,0 +1,92 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<!-- product_batch_report template--> |
||||
|
<template id="product_batch_report_template"> |
||||
|
<t t-call="web.external_layout"> |
||||
|
<t t-call="web.html_container"> |
||||
|
<div class="page"> |
||||
|
<h3 align="center">Lot/Serial Number Expiry Report</h3> |
||||
|
<div class="row mt32"> |
||||
|
<!--printing from and to date of expiry based on expiry type--> |
||||
|
<t t-if="expiry_type =='expire'"> |
||||
|
<div class="col-3"> |
||||
|
<span>From :</span> |
||||
|
<strong t-esc="today"/> |
||||
|
</div> |
||||
|
<div class="col-12"> |
||||
|
<span>To :</span> |
||||
|
<strong t-esc="date_within"/> |
||||
|
</div> |
||||
|
</t> |
||||
|
<t t-if="expiry_type =='expired'"> |
||||
|
<div class="col-3"> |
||||
|
<span>From :</span> |
||||
|
<strong t-esc="date_within"/> |
||||
|
</div> |
||||
|
<div class="col-12"> |
||||
|
<span>To :</span> |
||||
|
<strong t-esc="today"/> |
||||
|
</div> |
||||
|
</t> |
||||
|
</div> |
||||
|
</div> |
||||
|
<!--printing report data inside a table--> |
||||
|
<table class="table table-condensed"> |
||||
|
<thead> |
||||
|
<t t-if="view_type =='product_wise'"> |
||||
|
<th>Product</th> |
||||
|
</t> |
||||
|
<th>Lot/Serial Number</th> |
||||
|
<th>Expiry Date</th> |
||||
|
<t t-if="expiry_type =='expire'"> |
||||
|
<th>Expire Within</th> |
||||
|
</t> |
||||
|
<t t-if="expiry_type =='expired'"> |
||||
|
<th>Expired Before</th> |
||||
|
</t> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<!--displaying product expiry dates if the report type is product wise--> |
||||
|
<t t-if="view_type =='product_wise'"> |
||||
|
<tr t-foreach="heading" t-as="doc"> |
||||
|
<td align="left" colspan="4"> |
||||
|
<strong> |
||||
|
<span t-esc="doc['name']" style="color:#515151"/> |
||||
|
</strong> |
||||
|
</td> |
||||
|
<tr t-foreach="values" t-as="doc2"> |
||||
|
<t t-if="doc['name']==doc2['product']"> |
||||
|
<td/> |
||||
|
<td align="center"> |
||||
|
<span t-esc="doc2['lot_name']"/> |
||||
|
</td> |
||||
|
<td align="center"> |
||||
|
<span t-esc="doc2['expiry_date']"/> |
||||
|
</td> |
||||
|
<td align="center"> |
||||
|
<span t-esc="doc2['expiry_days']"/> |
||||
|
</td> |
||||
|
</t> |
||||
|
</tr> |
||||
|
</tr> |
||||
|
</t> |
||||
|
<!--displaying lot/serial expiry dates if the report type is tracking_wise--> |
||||
|
<t t-if="view_type =='tracking_wise'"> |
||||
|
<tr t-foreach="values" t-as="doc2"> |
||||
|
<td align="center"> |
||||
|
<span t-esc="doc2['lot_name']"/> |
||||
|
</td> |
||||
|
<td align="center"> |
||||
|
<span t-esc="doc2['expiry_date']"/> |
||||
|
</td> |
||||
|
<td align="center"> |
||||
|
<span t-esc="doc2['expiry_days']"/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</t> |
||||
|
</t> |
||||
|
</template> |
||||
|
</odoo> |
|
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 628 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 217 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: 49 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 100 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 99 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 96 KiB |
After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 63 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 57 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 880 KiB |
After Width: | Height: | Size: 742 KiB |
After Width: | Height: | Size: 36 KiB |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU 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 product_batch_report |
@ -0,0 +1,111 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################ |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU 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 datetime import datetime, timedelta |
||||
|
from odoo import fields, models, _ |
||||
|
from odoo.exceptions import UserError |
||||
|
|
||||
|
|
||||
|
class ProductBatchReport(models.TransientModel): |
||||
|
"""Model to create product batch report""" |
||||
|
_name = 'product.batch.report' |
||||
|
_description = 'Product Batch Report' |
||||
|
|
||||
|
tracking_wise = fields.Selection([ |
||||
|
('tracking_wise', 'Lot/Serial Wise'), |
||||
|
('product_wise', 'Product Wise'), ], |
||||
|
string='Tracking', default="tracking_wise", required=True, |
||||
|
help="Tracking wise") |
||||
|
product_ids = fields.Many2many('product.product', string='Product', |
||||
|
help="Add products") |
||||
|
expiry_days = fields.Integer(string='Within', help="Expire within...") |
||||
|
expiry_type = fields.Selection([ |
||||
|
('expired', 'Expired'), |
||||
|
('expire', 'Going to Expire'), ], |
||||
|
string='Tracking Type', required=True, help="Type of expire") |
||||
|
|
||||
|
def generate_pdf_report(self): |
||||
|
expiration_config = self.env['res.config.settings'].search([], order='id desc', limit=1).mapped( |
||||
|
'module_product_expiry') |
||||
|
if not expiration_config: |
||||
|
raise UserError(_('Please enable Expiration Settings to get the Report.')) |
||||
|
|
||||
|
if self.expiry_days and self.expiry_days < 0: |
||||
|
raise UserError(_('Please Enter a Non Negative Number.')) |
||||
|
|
||||
|
today = datetime.strftime(datetime.today(), '%Y-%m-%d %H:%M:%S') |
||||
|
batch_data = self.env['stock.lot'] |
||||
|
if self.product_ids: |
||||
|
for product in self.product_ids: |
||||
|
batch_data += batch_data.search( |
||||
|
[('product_id', '=', product.id), ('product_id.qty_available', '>', 0)]) |
||||
|
else: |
||||
|
batch_data = batch_data.search([('product_id.qty_available', '>', 0)]) |
||||
|
|
||||
|
if self.expiry_type == 'expired': |
||||
|
batch_data = batch_data.filtered(lambda l: str(l.expiration_date) <= today) |
||||
|
else: |
||||
|
batch_data = batch_data.filtered(lambda l: str(l.expiration_date) >= today) |
||||
|
values = [] |
||||
|
date_within = '' |
||||
|
if self.expiry_days: |
||||
|
if self.expiry_type == 'expired': |
||||
|
date_within = datetime.strftime(datetime.today() - timedelta(days=int(self.expiry_days)), |
||||
|
'%Y-%m-%d %H:%M:%S') |
||||
|
batch_data = batch_data.filtered(lambda l: str(date_within) <= str(l.expiration_date) <= str(today)) |
||||
|
else: |
||||
|
date_within = datetime.strftime(datetime.today() + timedelta(days=int(self.expiry_days)), |
||||
|
'%Y-%m-%d %H:%M:%S') |
||||
|
batch_data = batch_data.filtered(lambda l: str(date_within) >= str(l.expiration_date) >= str(today)) |
||||
|
|
||||
|
batch_data = batch_data.filtered(lambda l: l.expiration_date) |
||||
|
|
||||
|
for line in batch_data: |
||||
|
expiry_date_str = str(line.expiration_date) |
||||
|
|
||||
|
# Attempt to parse the date with and without microseconds |
||||
|
if '.' in expiry_date_str: |
||||
|
expiry_date = datetime.strptime(expiry_date_str, "%Y-%m-%d %H:%M:%S.%f") |
||||
|
else: |
||||
|
expiry_date = datetime.strptime(expiry_date_str, "%Y-%m-%d %H:%M:%S") |
||||
|
expiry_days = (expiry_date - datetime.strptime(today, "%Y-%m-%d %H:%M:%S")).days |
||||
|
|
||||
|
values.append({ |
||||
|
'lot_name': line.name, |
||||
|
'product': line.product_id.name, |
||||
|
'expiry_date': expiry_date_str, |
||||
|
'expiry_days': f"{abs(expiry_days)} Days" |
||||
|
}) |
||||
|
heading = [{'name': line.id if self.tracking_wise == 'tracking_wise' else line.product_id.name} for line in |
||||
|
batch_data] |
||||
|
heading = [dict(t) for t in {tuple(d.items()) for d in heading}] |
||||
|
|
||||
|
data_dict = { |
||||
|
'values': values, |
||||
|
'heading': heading, |
||||
|
'view_type': self.tracking_wise, |
||||
|
'expiry_type': self.expiry_type, |
||||
|
'today': today.split(' ')[0], |
||||
|
'date_within': date_within.split(' ')[0] if date_within else '', |
||||
|
'expiry_days': self.expiry_days, |
||||
|
} |
||||
|
return self.env.ref('product_batch_report.product_batch_report_action_report').report_action(self, |
||||
|
data=data_dict) |
@ -0,0 +1,41 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<odoo> |
||||
|
<!--product_batch_report form view--> |
||||
|
<record id="product_batch_report_view_form" model="ir.ui.view"> |
||||
|
<field name="name">product.batch.report.view.form</field> |
||||
|
<field name="model">product.batch.report</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<form string="Product Lot or Serial Report"> |
||||
|
<group> |
||||
|
<group> |
||||
|
<field name="tracking_wise"/> |
||||
|
<field name="product_ids" invisible="tracking_wise == 'tracking_wise'" widget="many2many_tags"/> |
||||
|
<field name="expiry_type"/> |
||||
|
</group> |
||||
|
<group> |
||||
|
<label for="expiry_days"/> |
||||
|
<div> |
||||
|
<field name="expiry_days" class="oe_inline" widget="integer"/> |
||||
|
<span>Days</span> |
||||
|
</div> |
||||
|
</group> |
||||
|
</group> |
||||
|
<footer> |
||||
|
<button name="generate_pdf_report" string="PDF Report" type="object" class="oe_highlight"/> |
||||
|
<button string="Cancel" special="cancel"/> |
||||
|
</footer> |
||||
|
</form> |
||||
|
</field> |
||||
|
</record> |
||||
|
<!--product_batch_report menu action--> |
||||
|
<record id="product_batch_report_action" model="ir.actions.act_window"> |
||||
|
<field name="name">Lot or Serial Expiring Report</field> |
||||
|
<field name="res_model">product.batch.report</field> |
||||
|
<field name="type">ir.actions.act_window</field> |
||||
|
<field name="view_mode">form</field> |
||||
|
<field name="target">new</field> |
||||
|
</record> |
||||
|
<!--Lot or Serial expiry Report menu inside inventory--> |
||||
|
<menuitem id="product_batch_report_menu" name="Lot/Serial Expiry" action="product_batch_report_action" |
||||
|
parent="stock.menu_warehouse_report" sequence="200"/> |
||||
|
</odoo> |