Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
hello, lately i have successfully get the auto number. now. everytime i create a new record then im going to cancel then create a new one again the auto number is continiuosly add. what i want is everytime i click create button then i need to exit then add again. i want it to become a efault or back to the original number. can anyone help me please? for example. the new number is SN/00001 on the field if ever im going to exit it should be go back in SN/00001. Please help me.
Well good example for your problem is in two common odoo modules: sales orders and invoices...
Sales orders : takes next sequence number on object create ( every created order get its own sequence number)
Invoices : on create default value for number is '/' (or draft) and only when you validate invoice it triggers wkf activity and gets the next sequence number.. .
Wise thing is to decide in wich exact moment the sequence needs to be assigned...
As i can see, you need invoice - like beahviour, that assignes number but not until you are sure in all the data...
Check methods in those two modules and you will soon find the correct way to use sequences
may the source be with you !
Here I define a custom module code sample you can use any of your custom field....
--------define your model here-------
-------------first override create method
def create(self, cr, uid, vals, context=None):
vals['installment_number'] = self.pool.get('ir.sequence').get(cr, uid,'lending.info')
return super(lending_info, self).create(cr, uid, vals, context=context)
'installment_number': lambda obj, cr, uid, context: '/',
define .xml file for auto increment //auto_id.xml
<openerp><data noupdate="1"><!-- Sequences for loan_id --><record id="seq__loan_code_inh1" model="ir.sequence.type"><field name="name">Lending info1 ID</field><field name="code">lending.info</field></record>
<record id="seq_cloan_code_inh2" model="ir.sequence"><field name="name">Lending info1 ID</field><field name="code">lending.info</field><field name="prefix">LN</field><field name="padding">2</field></record></data></openerp>
check openerp.py,init.py also
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 9/21/14, 8:11 AM|
|Seen: 1652 times|
|Last updated: 3/28/15, 3:13 AM|