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 XX
is generated from the number assigned to location of taking office of the employee since it is a company with several sites, YYYY
is generated from the current year and AAAAAAA
is generated from the number of files created
What did I do wrong in my code below ?
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,
})
I need to add location_number
as prefix of the sequence...instead of XX