This question has been flagged
6 Replies
8124 Views

what is the code for auto increment in openerp-7.0?? can anyone give me sample code. something like mrp or manufacturing module? Manufacturing Order MO/00077. Please help me

Avatar
Discard
Best Answer

Hi Louie,

Here is your answer: Generate sequence from code.

Avatar
Discard
Author

hello, i try the code but its not working and can you step by step it. i add the detail in sequences also. i dont know if im doing it correctly.. kind you pls put it in step by step since i am new to openerp. i really appreciate if you gonna help me and put it in step by step procedure.. please help me. thanks.

Best Answer

It is called sequences in odoo/openerp world :) 
first check that your user has enabled Technical features under user's acces rights

check Setting -> Technical -> Sequences & identifiers -> Sequences
----> here you can find and modify all defined sequences on current database

edit:
as for coded example... 
1. create your own module, models and views in it.
2. in xml file create a custom sequence like:

<openerp>
    <data noupdate="1">
        <record id="some_sequence_type_id" model="ir.sequence.type">
            <field name="name">Name of Sequence Type</field>
            <field name="code">CODE</field>
        </record>
        <record id="some_sequence_id" model="ir.sequence">
            <field name="name">Name of Sequence</field>
            <field name="code">SEQ-CODE</field>
            <field name="prefix">PRE/%(y)s/</field>
            <field name="padding">5</field> <!-- number of zeroes when starting from 1 -.>
            <field name="company_id" eval="False"/>
        </record>
    </data>
</openerp>

3. from your code you can get next seq nubmer like:
...
...     seq_no = self.pool.get('ir.sequence').get(cr, uid, 'SEQ-CODE')

does it help now? 
p.s. 
take a look at create methods in sale, stock invoice models... there name is fetched in simmilar way...

Avatar
Discard
Author

i want a coded one. do you have code? something like mrp code module. but since i dont know where is the exact code there. because i've tried to get the code and make a new one module just to know if working but its nothing display on that field. please2 help me

Author

hello, i try the code but its not working and can you step by step it. i add the detail in sequences also. i dont know if im doing it correctly.. kind you pls put it in step by step since i am new to openerp. i really appreciate if you gonna help me and put it in step by step procedure.. please help me. thanks.