Odoo Help

Welcome!

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.

1

help with sequence (auto number)

By
Abdullah Sofan
on 12/1/14, 3:19 PM 570 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>

        <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>
        </record>

 

==================================================

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'),
}
    
intrac_students()

 

=====================================

 

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.

Ivan
on 12/1/14, 7:37 PM

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

3 follower(s)

Stats

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