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.


two sequences for same object

on 2/21/13, 10:16 AM 2,203 views

how I can get two sequences for same object?

for example :

i have an object with two field : name and name_two I would like to assign the sequence 1 for field 1 and sequence 2 for field 2

Please, provide details; at least an example would be nice. Also you can use tags (at least the version, perhaps a module)...

Antonin Bourguignon (abo)
on 2/21/13, 10:24 AM

I have created 2 sequences for sales.order and created type field "type1" , type2. If I select type1, i want sequence1, If I select type2, I want sequence2.

Jagdish Panchal
on 12/27/13, 9:39 AM

Given link is not working for me

Jagdish Panchal
on 12/30/13, 12:20 AM
David Béal
On 2/21/13, 11:23 AM

You have to define sequence in 'ir.sequence' and in 'ir.sequence.type' and then call this :

my_sequence = self.pool['ir.sequence'].next_by_code(cr, uid,
                                    'stock.picking_mine_sequence', context=context)
self.write(cr, uid, [picking.id], {'name_two': my_sequence})

this is an example on stock picking in 'action_done' method

Some example in the code use another method than 'next_by_code' to do it. But next_by_code is the right way

2 tables are used in sequences : ir_sequence and ir_sequence_type. I don't know why because but there is a one to one relation between them.

Akretion, David Béal
on 2/26/13, 4:38 AM


| 5 5 6
Colombo, Sri Lanka
Java Developer ORACLE Python J2EE Spring Hibernate Struts & Jquery............. :-)
On 3/26/13, 3:32 AM
<?xml version="1.0" encoding="utf-8"?>
    <data noupdate="1">
        <record id="seq_type_bpl_worker_registration" model="ir.sequence.type">
            <field name="name">bpl_worker_registration_sequence</field>
            <field name="code">bpl.worker</field>

        <record id="seq_type_bpl_employer_no_registration" model="ir.sequence.type">
            <field name="name">bpl_employer_no</field>
            <field name="code">bpl.employer</field>

        <record model="ir.sequence" id="seq_bpl_worker_registration">
            <field name="name">bpl_worker_registration_sequence</field>
            <field name="code">bpl.worker</field>
            <field name="prefix">W</field>
            <field name="padding">5</field>

        <record model="ir.sequence" id="seq_bpl_employer_no_registration">
            <field name="name">bpl_employer_no</field>
            <field name="code">bpl.employer</field>
            <!-- <field name="prefix">%(register_no)s/</field> -->
            <field name="prefix">E</field>
            <field name="padding">3</field>


def create(self, cr, uid, values, context=None):
    values['register_no'] = self.pool.get('ir.sequence').get(cr, uid, 'bpl.worker')
    values['employer_no'] = self.pool.get('ir.sequence').get(cr, uid, 'bpl.employer')
    return super(bpl_worker_registration, self).create(cr, uid, values, context=context)

_defaults = {
 'register_no': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'bpl.worker'),
 'employer_no': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'bpl.employer'),


You have used 2 different objects for a sequence. While in my case, only one object can say bpl.employer. And for that I need 2 sequence.

Jagdish Panchal
on 12/30/13, 12:18 AM

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

0 follower(s)


Asked: 2/21/13, 10:16 AM
Seen: 2203 times
Last updated: 3/16/15, 8:10 AM