Odoo Help


This community 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.


Generate auto increment id with date ?

on 3/12/15, 7:22 AM 853 views

I need to generate an id with date
Format : AB{dd}{mm}{yy}00000 

I use an ir_sequence for the moment

Have you an idea to insert date in this num ?

in my class : 

 def _get_code(self, cr, uid,context, *args):
        obj_sequence = self.pool.get('ir.sequence')    
        return obj_sequence.next_by_code(cr, uid, 'project.issue.sequence', context=context)

 _columns = {
    _defaults = {
                'num': _get_code,



in data.xml : 

<data noupdate="0">
        <record model="ir.sequence.type" id="project_issue_code_sequence">
            <field name="name">Code sequence Issue</field>
            <field name="code">project.issue.sequence</field>
        <record model="ir.sequence" id="project_issue_sequence">
            <field name="name">Sequence For Issue</field>
            <field name="code">project.issue.sequence</field>
            <field name="active">TRUE</field>
            <field name="prefix">AB</field>
            <field name="number_increment">1</field>
            <field name="number_next">1000</field>
            <field name="implementation">standard</field>

On 3/12/15, 8:00 AM

Try use  AB{%(day)s}{%(month)s}{%(y)s}your_number as the prefix. This will solve your problem.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 3/12/15, 7:22 AM
Seen: 853 times
Last updated: 4/2/15, 8:27 PM