diff --git a/product_expiry_warning/__init__.py b/product_expiry_warning/__init__.py new file mode 100644 index 000000000..7d5aa7fc2 --- /dev/null +++ b/product_expiry_warning/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Avinash Nk() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +from . import models diff --git a/product_expiry_warning/__manifest__.py b/product_expiry_warning/__manifest__.py new file mode 100644 index 000000000..472c59381 --- /dev/null +++ b/product_expiry_warning/__manifest__.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Avinash Nk() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +{ + 'name': 'Expiry Date Warning', + 'summary': """Generates Warning for Expired Products, When it sells.""", + 'version': '10.0.1.0.0', + 'author': 'Cybrosys Techno Solutions', + 'website': "http://www.cybrosys.com", + 'company': 'Cybrosys Techno Solutions', + "category": "Sales", + "depends": ["sale", "stock", "product", "product_expiry"], + 'images': ['static/description/banner.jpg'], + 'license': 'LGPL-3', + 'installable': True, + 'application': False, +} diff --git a/product_expiry_warning/models/__init__.py b/product_expiry_warning/models/__init__.py new file mode 100644 index 000000000..0626a6ef0 --- /dev/null +++ b/product_expiry_warning/models/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Avinash Nk() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +from . import expiry_date_warning diff --git a/product_expiry_warning/models/expiry_date_warning.py b/product_expiry_warning/models/expiry_date_warning.py new file mode 100644 index 000000000..e0611a055 --- /dev/null +++ b/product_expiry_warning/models/expiry_date_warning.py @@ -0,0 +1,80 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Avinash Nk() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +from datetime import datetime, date +from odoo import models, api, _ +from odoo.exceptions import UserError + + +class ExpiryDateWarning(models.Model): + _inherit = 'sale.order.line' + + @api.onchange('product_uom', 'product_uom_qty') + def product_uom_change(self): + super(ExpiryDateWarning, self).product_uom_change() + if self.product_id: + total_quantity = 0.0 + product_sale = self.product_id + quantity_in_lot = self.env['stock.quant'].search([]) + lot_number_obj = self.env['stock.production.lot'] + lot_number_obj_specific = lot_number_obj.search([]) + for records in lot_number_obj_specific: + dates = date.today() + if records.life_date: + dates = datetime.strptime(records.life_date, '%Y-%m-%d %H:%M:%S').date() + if records.product_id.id == product_sale.id and dates < date.today(): + for values in quantity_in_lot: + if values.lot_id.id == records.id and values.product_id.id == product_sale.id: + total_quantity = total_quantity+values.qty + good_products = self.product_id.qty_available - total_quantity + if good_products < self.product_uom_qty: + warning_mess = { + 'title': _('Not enough good products!'), + 'message': _( + 'You plan to sell %.2f %s but you only have %.2f %s Good Products available!\n' + 'The stock on hand is %.2f %s.') % ( + self.product_uom_qty, self.product_uom.name, good_products, self.product_id.uom_id.name, + self.product_id.qty_available, self.product_id.uom_id.name) + } + return {'warning': warning_mess} + + +class ExpiryDateStockPackOperation(models.Model): + _inherit = "stock.pack.operation" + + @api.multi + def save(self): + res = super(ExpiryDateStockPackOperation, self).save() + lots = [x.lot_id for x in self.pack_lot_ids] + lot_list = [] + for lot in lots: + if self.product_id == lot.product_id: + if lot.life_date: + today = date.today() + life_date = datetime.strptime(lot.life_date, '%Y-%m-%d %H:%M:%S').date() + if life_date < today: + lot_list.append(str(lot.name)) + if len(lot_list) == 1: + raise UserError(_('Product in this lot number is expired : %s' % lot_list[0])) + elif len(lot_list) > 1: + raise UserError(_('Products in these lot numbers are expired : %s' % lot_list)) + return res diff --git a/product_expiry_warning/static/description/banner.jpg b/product_expiry_warning/static/description/banner.jpg new file mode 100644 index 000000000..f3cb520f1 Binary files /dev/null and b/product_expiry_warning/static/description/banner.jpg differ diff --git a/product_expiry_warning/static/description/expiry11.png b/product_expiry_warning/static/description/expiry11.png new file mode 100644 index 000000000..2572738e8 Binary files /dev/null and b/product_expiry_warning/static/description/expiry11.png differ diff --git a/product_expiry_warning/static/description/expiry22.png b/product_expiry_warning/static/description/expiry22.png new file mode 100644 index 000000000..9e506f617 Binary files /dev/null and b/product_expiry_warning/static/description/expiry22.png differ diff --git a/product_expiry_warning/static/description/expiry33.png b/product_expiry_warning/static/description/expiry33.png new file mode 100644 index 000000000..64a65fbcd Binary files /dev/null and b/product_expiry_warning/static/description/expiry33.png differ diff --git a/product_expiry_warning/static/description/icon.png b/product_expiry_warning/static/description/icon.png new file mode 100644 index 000000000..cb7c7c2c0 Binary files /dev/null and b/product_expiry_warning/static/description/icon.png differ diff --git a/product_expiry_warning/static/description/index.html b/product_expiry_warning/static/description/index.html new file mode 100644 index 000000000..285af1a69 --- /dev/null +++ b/product_expiry_warning/static/description/index.html @@ -0,0 +1,112 @@ +
+
+

Expiry Date Warning !

+

Generates warning for expired products, when we sell the product.

+

Cybrosys Technologies

+
+
+

Features:

+
+ Both Sales and Inventory Section Gets the Warning Message
+ Integrate with Products Expiration Date Module.
+
+
+
+ +
+
+
+

Overview

+

+ In Odoo ERP you can set expiry date for any product. But what if we failed + to notice an expired product and attempt to sell the same? Expiry Date Warning + App by team Cybrosys solve the issue by generating a warning message while you + try to sell an expired product. This app uses the "End of life date" you set + for a product to generate the warning. So first, you need to set an Expiry + date for a product. +

+

+ Read this blog from Cybrosys to know "How to set expiry date for a product". +

+

+ Blog : https://www.cybrosys.com/blog/how-setup-product-expiry-dates-in-odoo +

+
+
+
+
+
+

Warning in Sale order

+
+
+ +
+ If you select a product that does not have good products in the + inventory, you will get this error message. +
+
+
+
+ +
+
+

Warning at Stock Picking

+
+
+ +
+ This warning is generated when you pick some expired product from + the inventory. +
+
+
+
+ +
+
+

Define expiry date

+
+
+ +
+

+ You can set expiry date from +

+

+ Inventory --> Inventory Control --> Lots/Serial Numbers +

+

+ The app generate Expiry warning based on the date you give on "End of Life" field. +

+
+
+
+ +
+

Need Any Help?

+ +
+ + +