X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=addons%2Fproduct_expiry%2Fproduct_expiry.py;h=4497ca71957f8712086d38f2b60a9f8089bc1bd6;hb=7d5e28fbb8d49b8a2825bfdd525938d99574e234;hp=92dc7974bf7d26d44d56450041418be03028e3bd;hpb=fe6e6e43c10e93dfe72bc6d513655db55162a08a;p=odoo%2Fodoo.git diff --git a/addons/product_expiry/product_expiry.py b/addons/product_expiry/product_expiry.py index 92dc797..4497ca7 100644 --- a/addons/product_expiry/product_expiry.py +++ b/addons/product_expiry/product_expiry.py @@ -23,7 +23,6 @@ from osv import fields, osv import pooler class stock_production_lot(osv.osv): - _name = 'stock.production.lot' _inherit = 'stock.production.lot' def _get_date(dtype): @@ -41,39 +40,50 @@ class stock_production_lot(osv.osv): # set date to False when no expiry time specified on the product date = duration and (datetime.datetime.today() + datetime.timedelta(days=duration)) - return date and date.strftime('%Y-%m-%d') + return date and date.strftime('%Y-%m-%d %H:%M:%S') or False return calc_date _columns = { - 'life_date': fields.date('End of Life Date', - help='The date the lot may become dangerous and should not be consumed.'), - 'use_date': fields.date('Best before Date', - help='The date the lot starts deteriorating without becoming dangerous.'), - 'removal_date': fields.date('Removal Date', - help='The date the lot should be removed.'), - 'alert_date': fields.date('Alert Date'), + 'life_date': fields.datetime('End of Life Date', + help='The date on which the lot may become dangerous and should not be consumed.'), + 'use_date': fields.datetime('Best before Date', + help='The date on which the lot starts deteriorating without becoming dangerous.'), + 'removal_date': fields.datetime('Removal Date', + help='The date on which the lot should be removed.'), + 'alert_date': fields.datetime('Alert Date', help="The date on which an alert should be notified about the production lot."), } + # Assign dates according to products data + def create(self, cr, uid, vals, context=None): + newid = super(stock_production_lot, self).create(cr, uid, vals, context=context) + obj = self.browse(cr, uid, newid, context=context) + towrite = [] + for f in ('life_date', 'use_date', 'removal_date', 'alert_date'): + if not getattr(obj, f): + towrite.append(f) + if context is None: + context = {} + context['product_id'] = obj.product_id.id + self.write(cr, uid, [obj.id], self.default_get(cr, uid, towrite, context=context)) + return newid _defaults = { - # 'life_date': _get_date('life_time'), - # 'use_date': _get_date('use_time'), - # 'removal_date': _get_date('removal_time'), - # 'alert_date': _get_date('alert_time'), + 'life_date': _get_date('life_time'), + 'use_date': _get_date('use_time'), + 'removal_date': _get_date('removal_time'), + 'alert_date': _get_date('alert_time'), } stock_production_lot() class product_product(osv.osv): _inherit = 'product.product' - _name = 'product.product' _columns = { - 'life_time': fields.integer('Product lifetime', + 'life_time': fields.integer('Product Life Time', help='The number of days before a production lot may become dangerous and should not be consumed.'), - 'use_time': fields.integer('Product usetime', + 'use_time': fields.integer('Product Use Time', help='The number of days before a production lot starts deteriorating without becoming dangerous.'), - 'removal_time': fields.integer('Product removal time', + 'removal_time': fields.integer('Product Removal Time', help='The number of days before a production lot should be removed.'), - 'alert_time': fields.integer('Product alert time'), + 'alert_time': fields.integer('Product Alert Time', help="The number of days after which an alert should be notified about the production lot."), } product_product() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -