Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Create sequences in OpenERP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 363
    Comment on it

    For any module or a part of the module we may have to have a field which is sequential and auto generated. For this we can create a sequence through the OpenERP UI and include in our model pragmatically through python code.

    1. First create a sequence from the UI, Go to Settings/Configuration/Sequences & Identifiers/Sequences.
    2. Then specify the name for the sequence like Mass Return Number.
    3. Select the code i.e model you want this sequence to work for like Mass Return.
    4. Provide prefix or suffx or both as you need, here we created prefix MR. %(month)s/%(y)s/.
    5. Provide next number, padding, increment number and implementation and save.

    Your sequence is ready and you can use it now in your module to show as a field. Just add the following field:

    'number': fields.char('Number', size=128, help="Company internal claim unique number"),
    

    and then in defaults define its value:

    'number': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'mass.return'),
    

    ir.sequence is the model where all the sequences are defined. So simple, isn't it.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: