3
votes

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

NOW ITS SORTED I ADDED BELOW THERE

_defaults = {
     'register_no': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'bpl.worker'),
     }
1
You mean you want to make your field readonly. Am I right? If so then write readonly=True inside field declaration code in your py file.Sudhir Arya
@Arya thanks for the comment. yeah readonly.but how to load that next number on form load ?Anne Mary
You can fill it when create method is called.Sudhir Arya
when time need to trigger it.in default state.?Anne Mary
Please not that one should rather use obj.pool.get('ir.sequence').next_by_code(cr, uid, 'bpl.worker', context)adekock11

1 Answers

1
votes

You can make your field as readonly

'register_no': fields.char('Register No', size=32, help='Register No', readonly=True),

and mention that in _default

Please check in existing module like sale.py how they are getting default sequence for the next sales order number.

http://bazaar.launchpad.net/~openerp/openobject-addons/trunk/view/head:/sale/sale.py