Skip to Content
Menu
This question has been flagged
1049 Views

Hello !

I need your advice to populate field barcode in model employee with concatenation of field location_number in model work_location_id and sequence generated by automated action in odoo 15 ?

I want to automatically generate in the number field an identifier with this particular formatting (such as XX-YYYY-AAAAAAA) where X is generated from the number assigned instead of taking office of the employee since it is a company with several sites, Y is generated from the current year and A is generated from the number of files created

What did I do wrong in my code below ?


Avatar
Discard
Author

if not record.barcode:

xx = env['work.location.id'].get('location.number')
yyyy_aaaaaaa = env['ir.sequence'].next_by_code('matricule_')

record.write({

'barcode': xx + yyyy_aaaaaaa,

})

Hi, did you manage to figure this out?