# -*- coding: utf-8 -*- from odoo import models, fields, api from datetime import datetime, timedelta class StockMoveLine(models.Model): _inherit = 'stock.move.line' production_date = fields.Date( string='Production Date', compute='_compute_production_date', store=False, readonly=True, ) expiration_date = fields.Date( string='Expiration Date', compute='_compute_expiration_date', store=False, readonly=True, ) lot_number = fields.Char( string='Lot Number', related='lot_id.name', readonly=True, ) product_ref = fields.Char( string='Product Reference', related='product_id.default_code', readonly=True, ) @api.depends('move_id.create_date') def _compute_production_date(self): """Set production date to today or the move's creation date""" for line in self: line.production_date = fields.Date.today() @api.depends('move_id.create_date') def _compute_expiration_date(self): """Set expiration date to 6 months (180 days) from today""" for line in self: line.expiration_date = fields.Date.today() + timedelta(days=180)