Skip to Content
Menu
This question has been flagged
2 Replies
6513 Views

Hi all,

In discrete manufacturing, when the products undergo manufacturing we manually enter the lot number / unique serial number to record production

But in our industry we do higher volume of quantity 1000/day  in this case ,we have to auto generate the serial number / lot number.

So give possible solution 

 

Avatar
Discard

Will you please explain in detail how to insert this code ?

Best Answer


Hi, here's my case. I'm creating serial number for my parking inventory on basis of 'sector_id' which is Floors in my model. Here's how i'm creating automatically serial number whenever inventory is created.

my.py

@api.model
def create(self, vals):
if vals.get('serial_number', _('New')) == _('New'):
sector_id = self.env['sector'].search([('id', '=', vals['sector_id'])])

record = self.env['ir.sequence'].search([('code', '=', 'park.inventory.%s' % (sector_id.code))])
if record:
vals['serial_number'] = self.env['ir.sequence'].next_by_code(record.code) or _('New')
else:
new_record = self.env['ir.sequence'].create({
'name': '%s' % (sector_id.code),
'code': 'plot.inventory.%s' % (sector_id.code),
'prefix': "%s/" % (sector_id.code),
'padding': 3,
'company_id': False
})

vals['serial_number'] = self.env['ir.sequence'].next_by_code(new_record.code) or _('New')

rec = super(ParkInventory, self).create(vals)

return rec

Let me know if u need further help.

Avatar
Discard
Related Posts Replies Views Activity
2
Dec 24
51
2
Dec 24
48
1
Dec 24
56
1
Dec 24
55
0
Dec 24
29