Also you would have to requires the Field('ticket',...,unique=True) because 
this method it not thread safe and you should be prepared that inserts may 
fail.


On Tuesday, 10 November 2015 11:42:40 UTC-6, Niphlod wrote:
>
> if you want to have a number that strictly:
>
> - is incremental (no gaps, always sequential, etc)
> - the first two digits are the year
>
> I'd suggest to have a "last_tickets" table  (year(int) ,     
> ticket_no(int))
>
>  holding the current ticket.
>
> then, you can use _before_insert callback on the "tickets" table to:
>
> - fetch the last ticket_no for the current year
> - compute the next integer, update last ticket_no
> - use the computed value in the ticket_no of the "tickets" table
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to