Hello I am trying to make an autoincrement field for the traceability of purchases requests.
I have called the field
code = fields.Char('Code', size=32, required=True,readonly=True, default=_get_default_name, track_visibility='onchange')
Using the function next_by_code for the autoincrement
def _get_default_name(self): return self.env['ir.sequence'].next_by_code('sprogroup.purchase.request')
But this method doesn't work. In my idea I would like to make the field CODE a field that is called like RA2020001 for the first then RA2020002 for the second and so on. But I cannot do it. Any suggests?
Have a nice day
https://www.youtube.com/watch?v=ZfKzmfiqeg0&list=PLqRRLx0cl0hoJhjFWkFYowveq2Zn55dhM&index=8
Please make clear what exactly not working? like are you missing sequence in between or sequence not generated so on. it will be helpful to get your question answered.
You can do this by sequence in odoo: https://learnopenerp.blogspot.com/2020/08/generate-create-sequence-number-odoo.html
have a look