Yes, Odoo 16 allows you to add serial numbers to an inventory that has already been created and moved, and it can also automatically generate and assign serial numbers to products.
Here are the steps to add serial numbers to existing inventory:
- Enable Serial Number Tracking: Go to Inventory > Configuration > Settings and enable the Lots & Serial Numbers feature.
- Configure Serial Number Tracking: Go to Inventory > Products > Products, choose a product to track, click Edit, navigate to the Inventory tab, and select the By Unique Serial Number option.
- Create New Serial Numbers: Go to Inventory > Products > Lots/Serial Numbers and click Create. A new Lot/Serial Number is generated automatically. You can assign this new number to the product.
For automatic generation and assignment of serial numbers, you can use the ir.sequence model in Odoo. Here’s a sample code snippet:
@api.model
def create(self, vals):
if vals.get('serial_number', _('New')) == _('New'):
vals['serial_number'] = self.env['ir.sequence'].next_by_code('your.sequence.code') or _('New')
rec = super(YourModel, self).create(vals)
return rec
Remember, each product in Odoo must have a unique serial number.