diff --git a/product_expiry_simple/__init__.py b/product_expiry_simple/__init__.py new file mode 100644 index 0000000..838de2d --- /dev/null +++ b/product_expiry_simple/__init__.py @@ -0,0 +1,3 @@ +# -*- encoding: utf-8 -*- + +from . import stock diff --git a/product_expiry_simple/__openerp__.py b/product_expiry_simple/__openerp__.py new file mode 100644 index 0000000..6c62c54 --- /dev/null +++ b/product_expiry_simple/__openerp__.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# © 2017 Akretion (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Product Expiry Simple', + 'version': '8.0.1.0.0', + 'category': 'Product', + 'license': 'AGPL-3', + 'summary': 'Simpler and better alternative to the official product_expiry module', + 'description': """ +Product Expiry Simple +===================== + +This module is similar to the official *product_expiry* modules, but much simpler and much better: + +* Only one expiry date field instead of 4 ! +* date field instead of datetime +* No automatic computing of expiry date based on a delay configured on product (not needed in most companies) +* colored production lot and stock quant tree views depending on expiry dates +* ability to show stats about expiry dates on quants pivot table (thanks to related stored field on stock.quant) + +This module has been written by Alexis de Lattre from Akretion . + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['stock'], + 'conflicts': ['product_expiry'], + 'data': [ + 'stock_view.xml', + 'product_removal_data.xml', + ], + 'installable': True, +} diff --git a/product_expiry_simple/product_removal_data.xml b/product_expiry_simple/product_removal_data.xml new file mode 100644 index 0000000..668012d --- /dev/null +++ b/product_expiry_simple/product_removal_data.xml @@ -0,0 +1,11 @@ + + + + + + First Expiry First Out (FEFO) + fefo + + + + diff --git a/product_expiry_simple/stock.py b/product_expiry_simple/stock.py new file mode 100644 index 0000000..71c4f95 --- /dev/null +++ b/product_expiry_simple/stock.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# © 2017 Akretion (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import models, fields, api + + +class StockProductionLot(models.Model): + _inherit = 'stock.production.lot' + _rec_name = 'display_name' + + expiry_date = fields.Date(string='Expiry Date') + display_name = fields.Char( + compute='compute_display_name_field', + string='Lot/Serial Number Display', store=True, readonly=True) + + @api.multi + @api.depends('name', 'expiry_date') + def compute_display_name_field(self): + for lot in self: + dname = lot.name + if lot.expiry_date: + dname = '[%s] %s' % (lot.expiry_date, dname) + lot.display_name = dname + + +class StockQuant(models.Model): + _inherit = 'stock.quant' + + expiry_date = fields.Date( + related='lot_id.expiry_date', store=True, readonly=True) + + # method copy/pasted from the official product_expiry module + # © Odoo SA + @api.model + def apply_removal_strategy( + self, location, product, qty, domain, removal_strategy): + if removal_strategy == 'fefo': + order = 'expiry_date, location_id, package_id, lot_id, in_date, id' + return self._quants_get_order( + location, product, qty, domain, order) + return super(StockQuant, self).apply_removal_strategy( + location, product, qty, domain, removal_strategy) diff --git a/product_expiry_simple/stock_view.xml b/product_expiry_simple/stock_view.xml new file mode 100644 index 0000000..3a7ea16 --- /dev/null +++ b/product_expiry_simple/stock_view.xml @@ -0,0 +1,94 @@ + + + + + + + + + product_expiry_simple.stock.production.lot.form + stock.production.lot + + + + + + + + + + product_expiry_simple.stock.production.lot.tree + stock.production.lot + + + + + + + red:expiry_date and expiry_date < current_date;green:expiry_date >= current_date + + + + + + product_expiry_simple.stock.production.lot.search + stock.production.lot + + + + + + + + + + + + + + + + + + product_expiry_simple.stock.quant.tree + stock.quant + + + + + + + red:expiry_date and expiry_date < current_date;green:expiry_date >= current_date + + + + + + product_expiry_simple.stock.quant.search + stock.quant + + + + + + + + + + + + + + +