1# -*- coding: utf-8 -*- 2# Part of Odoo. See LICENSE file for full copyright and licensing details. 3 4from odoo import models, _ 5from odoo.exceptions import UserError 6 7 8class StockProductionLot(models.Model): 9 _inherit = 'stock.production.lot' 10 11 def _check_create(self): 12 active_mo_id = self.env.context.get('active_mo_id') 13 if active_mo_id: 14 active_mo = self.env['mrp.production'].browse(active_mo_id) 15 if not active_mo.picking_type_id.use_create_components_lots: 16 raise UserError(_('You are not allowed to create or edit a lot or serial number for the components with the operation type "Manufacturing". To change this, go on the operation type and tick the box "Create New Lots/Serial Numbers for Components".')) 17 return super(StockProductionLot, self)._check_create() 18