need to create an auto increamet Field that reset to 1 every Year.
db.define_table('protocol',Field('n_protocol'),Field('year_protocol',type='datetime', writable = False, readable = False, default=request.now, requires=(IS_DATETIME(timezone=pytz.timezone("Europe/Gibraltar"),format=('%Y')))) The field 'n_protocol' must start to 1 auto increment and return to 1 next year. Why the date is correct when i insert data but is not correct when i see the data stored in db the date is wrong? I also tried this: ultimo_protocollo= db(db.protocollo.data_protocollo).select().last() ieri = ultimo_protocollo.year data = datetime.datetime oggi = data.year db.protocollo.n_protocollo = Field.Virtual('n_protocollo', lambda n_protocollo: (n_protocollo ++ 1) if (ieri == oggi) else (db.protocollo.n_protocollo =="1")) but i recive error. Can you please help me? Thank you guys -- 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.