Odoo Help


How do i create sequence number in order when importing data with one2 many field in openerp7?

on 9/20/13, 4:55 AM 2,456 views


I am trying to import data to a form which is apparently the below

  • Seq No (sequence number field - am generating with openerp sequence)
  • Customer (Customer Reference field)
  • Services (one 2 many field)
    • contract Start Date
    • contract End Date

Data i import is something like this

Customer    Contract Start Date     Contract End Date

 ABC            13/02/12                12/05/14
                12/05/14                14/04/16
                12/08/16                14/06/18
 XYZ            15/04/12                18/08/14
                11/05/14                19/05/16

Now 2 records are generated in my form with sub records, but the id generated for first record is R001 and second is R004. i.e for every record of import an id is generated (but not used). so there's an interval. But this is the method i've identified to import form values with one2many.

Now i need to understand the below - Am i doing things right, or is there any other way to import one2many data - Is there a way to organize my sequence number while import - And last one(crooked) is that i can go to database update all values to a sequence. And when i create a form field manually the last id+1 generated by openerp is taken. So i need to update the sequence number to start with the last values + 1 that i've changed in the database.

Kindly guide me to do the necessary. And feel free to update the post if it's not that clear. Thanks for your time.


try to make a function for your sequence sample is this:

In your .py

def create(self, cr, uid, values, context=None): values['seq'] = self.pool.get('ir.sequence').get(cr, uid, 'change.order') return super(change_order, self).create(cr, uid, values, context=context)

and in your .xml

     <record model="ir.sequence.type" id="seq_type_project">
        <field name="name">Change Order</field>
        <field name="code">change.order</field>
    <record model="ir.sequence" id="seq_change_order">
        <field name="name">Change Order</field>
        <field name="code">change.order</field>
        <field name="prefix">CORBOM</field>
        <field name="padding">3</field>

Hope it will help :)

Thanks for your answer friend, i've already done that. My prob is with importing now. The records imported is having intervals between sequence number due to one2many records. How to avoid that is my question. Please guide me. Thank You.

on 9/20/13, 5:15 AM

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

0 follower(s)


Asked: 9/20/13, 4:55 AM
Seen: 2456 times
Last updated: 3/16/15, 8:10 AM