diff --git a/addons/product_expiry/product_expiry.py b/addons/product_expiry/product_expiry.py index 392e574a0bb..4b52d9bf3b6 100644 --- a/addons/product_expiry/product_expiry.py +++ b/addons/product_expiry/product_expiry.py @@ -21,6 +21,7 @@ import datetime import openerp +from openerp import api, models from openerp.osv import fields, osv class stock_production_lot(osv.osv): @@ -75,6 +76,19 @@ class stock_production_lot(osv.osv): } +# Onchange added in new api to avoid having to change views +class StockProductionLot(models.Model): + _inherit = 'stock.production.lot' + + @api.onchange('product_id') + def _onchange_product(self): + defaults = self.with_context( + product_id=self.product_id.id).default_get( + ['life_date', 'use_date', 'removal_date', 'alert_date']) + for field, value in defaults.items(): + setattr(self, field, value) + + class stock_quant(osv.osv): _inherit = 'stock.quant'