Anthony is right...
In my case I had to manage such kind of custom primary key generation... I
use onvalidation() make a callback and find the sequence field and
increment it... I have some function to generate the item id or custom
primary key that contains the logic to increment properly the seq
The problem with any solution that inspects the current records in the
database table in order to figure out the ID for a new record is that you
will not be able to account for deleted records (i.e., you might end up
re-using IDs that were previously used by records that were later deleted).
Th
For the trigger ... you could also consider using the web2py support for
on insert / on update callbacks:
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#callbacks-on-record-insert-delete-and-update
Kiran Subbaraman
http://su
Hey Brian,
Doing it on the fly won't work because I want the number to be set at
record creation and be a part of the dataset. Also, this is what I am
already doing.
Using a database trigger is something I don't know anything about. So thank
you for the nudge, I will research this option.
Paul
First of all, at the risk of asking a silly question - is there actually a
reason to store this secondary ID in the database rather than just have it
calculated on the fly as-needed using a virtual field? Assuming that you've
got a created_date field already in the table that'll give you the mon
perhaps you can use count
*e.g.*
count_invoice = db.invoice.id.count()
this_year = request.now.year
this_month = request.now.month
query_invoice = ((db.invoice.invoice_date.year() == this_year) &
(db.invoice.invoice_date.month() == this_month) )
query_count_invoice =
db(query_invoice).select(co
6 matches
Mail list logo