Auto Number Generate in OpenERP
Simply just create a new file .xml
lib.resource = table name
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<!-- Sequences for lib.resource -->
<record id="seq_type_library_sub_ resource" model="ir.sequence.type">
<field name="name">Library Resource</field>
<field name="code">lib.sub.resource</ field>
</record>
<record id="seq_library_sub_resource" model="ir.sequence">
<field name="name">Library Resource</field>
<field name="code">lib.sub.resource</ field>
<field name="prefix">BC</field>
<field name="padding">10</field>
</record>
</data>
</openerp>
Or
simply write below code in your view.xml file
<record id="seq_type_library_sub_ resource" model="ir.sequence.type">
<field name="name">Library Resource</field>
<field name="code">lib.sub.resource</ field>
</record>
<record id="seq_library_sub_resource" model="ir.sequence">
<field name="name">Library Resource</field>
<field name="code">lib.sub.resource</ field>
<field name="prefix">BC</field>
<field name="padding">10</field>
</record>
and in your .py file in _default simply write the below code
_defaults :
{
'number': lambda obj, cr, uid, context: obj.pool.get('ir.sequence'). get(cr, uid, 'lib.resource'),
}
Simply just create a new file .xml
lib.resource = table name
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<!-- Sequences for lib.resource -->
<record id="seq_type_library_sub_
<field name="name">Library Resource</field>
<field name="code">lib.sub.resource</
</record>
<record id="seq_library_sub_resource" model="ir.sequence">
<field name="name">Library Resource</field>
<field name="code">lib.sub.resource</
<field name="prefix">BC</field>
<field name="padding">10</field>
</record>
</data>
</openerp>
Or
simply write below code in your view.xml file
<record id="seq_type_library_sub_
<field name="name">Library Resource</field>
<field name="code">lib.sub.resource</
</record>
<record id="seq_library_sub_resource" model="ir.sequence">
<field name="name">Library Resource</field>
<field name="code">lib.sub.resource</
<field name="prefix">BC</field>
<field name="padding">10</field>
</record>
and in your .py file in _default simply write the below code
_defaults :
{
'number': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').
}
Thanks Pinakin...u saved my whole day :-)
ReplyDeleteI tried to do this but when the page loads the sequence number is not loaded. Is there something missing?
ReplyDeletehi Pinakin! thank you.. it worked!!!.. but there is an error when i try to save it :( "DataError: invalid input syntax for integer: "CRN00015"
ReplyDeleteLINE 1: ...3, 2, 1, 'none', 1, 'draft', 'out_invoice', NULL, 'CRN00015'..." ....... is there a way that I can use button to generate the sequence when i click a button?
may be you have to change the type of field to char
ReplyDeletethank youuu... it worked :)..very helpful
ReplyDeleteHow can I insert a number that is generated in automatic for a specific model the code that you have already applied and I did not work that another solution exists
ReplyDelete