Odoo Help


help with sequence (auto number)

Abdullah Sofan
on 12/1/14, 3:19 PM 998 views

I wrote the sequnce as I read in various posts, but the number does not load. Can someone help me?

in the view.xml:

<record id="seq_type_student_number" model="ir.sequence.type">
            <field name="name">Student Number</field>
            <field name="code">intrac.students.number</field>

        <record id="seq_student_number" model="ir.sequence">
            <field name="name">Student Number</field>
            <field name="code">intrac.students.number</field>
            <field name="prefix">%(year)s%(month)s</field>
            <field name="padding">3</field>



and in the students.py

class intrac_students(osv.osv):
    _name = 'intrac.students'
    _columns = {
        'name': fields.many2one('res.partner', 'Student Name'),
        'student_number': fields.char('Student Number'),
        'student_image': fields.binary("Student Picture"),
        'student_id_type': fields.selection([('gid','Govt ID'),('passport','Passport')],'Identification Type'),
        'student_id_number': fields.char('ID Number', size=100),
        'student_gender': fields.selection([('m','Male'),('f','Female')], 'Gender'),
        'student_education_level': fields.selection([('hs','High School'),('c','College')], 'Education Level'),
        'student_notes': fields.one2many('intrac.students.notes', 'student_name', 'Student Notes'),
        'student_dob': fields.date('Date of Birth'),
_defaults = {
        'student_number': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'intrac.students.number'),




What am I missing?

try to replace in .py and .xml files: intrac.students.number by intrac.students

Med Said BARA
on 12/1/14, 5:30 PM

I can't see an error in your code. Maybe the error is in the rest of your code (Part of the code not posted, if any).

Med Said BARA
on 12/1/14, 5:49 PM

Have you put the XML file that generates the sequences in 'data' section of __openerp__.py? If you have, you should be able to see your sequence from Settings >> Technical >> Sequences & Identifiers >> Sequences (also Sequence Codes). Also you might have used noupdate="1" attribute and change your Sequence (Code) afterwards. Just check from that menu and see if the Sequence and Sequence Code exist and the data is as what you have defined. Also please note that get method of sequence has been deprecated, you might want to change it to next_by_code(cr, uid, sequence_code, context=context) instead.

on 12/1/14, 7:37 PM

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

3 follower(s)


Asked: 12/1/14, 3:19 PM
Seen: 998 times
Last updated: 3/16/15, 8:10 AM