from odoo import api, models class StockLot(models.Model): _inherit = 'stock.lot' @api.model_create_multi def create(self, vals_list): # For each lot being created without a name, assign the next serial from the product's template sequence for vals in vals_list: if not vals.get('name') and vals.get('product_id'): product = self.env['product.product'].browse(vals['product_id']) seq = getattr(product.product_tmpl_id, 'lot_sequence_id', False) if seq: vals['name'] = seq.next_by_id() else: # Fallback to global sequence if no product sequence vals['name'] = self.env['ir.sequence'].next_by_code('stock.lot.serial') return super().create(vals_list)