OpenERP get next Sequence number [Closed]
The Question has been closedby
OpenERP gives a sequence number when we saved a record. i have done that module.as per that module when i create a worker then load employee number as EMP001,EMP002..
My requirment is this. When I'm going to create a new employee then need to show next sequence number as a read only field. for ex : when i'm going to create a 9th employee then need to show EMP009 in my emp no field.
my current codes uploaded to below location https://github.com/priyankahdp/openerp/tree/openerp
Dear Yannik, here is the code.is it correct .?
def _get_next_no(self, cr, uid, context=None): cr.execute("SELECT last_value + increment_by FROM ir_sequence_%03d;" % seq['id']) seq['number_next'] = cr.fetchone() return seq
There are no method to get this, you need to make your own by:
Getting your sequence id.
seq_id = self.pool.get('ir.sequence').search(cr, uid, [<search_cond>])
Then getting the next value based on
last_value column from the postgresql sequence
"SELECT last_value + increment_by FROM ir_sequence_%03d;" %seq_id
Then from this number you need to reconstruct the sequence according to your format. With preffix and suffix.
server/openerp/addons/base/ir/ir_sequence.py file you will see it in
Remind that if two users are creating a record at the same time, they will see the same value but for one of them it will change on create action.
About This Community
|Asked: 3/25/13, 9:14 AM|
|Seen: 5132 times|
|Last updated: 3/16/15, 8:10 AM|