Odoo Help


Generate auto increment id with date ?

on 3/12/15, 7:22 AM 1,520 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.

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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


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