Skip to Content
Menu
This question has been flagged
7 Replies
9362 Views

This is my code-------

class account_voucher(osv.Model):

_inherit = "account.voucher"

_columns={

'sequence_number':fields.char('Sequence Number'),

}

def create(self, cr, uid, vals, context=None):

vals['sequence_number'] = self.pool.get('ir.sequence').get(cr, uid,'account.voucher')

return super(account_voucher, self).create(cr, uid, vals, context=context)

_defaults={

'sequence_number': lambda obj, cr, uid, context: ' /',

}

account_voucher()


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






<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data noupdate="1">

<!-- Sequences for loan_id -->

<record id="seq_cloan_code_inh1" model="ir.sequence.type">

<field name="name">SEQ ID</field>

<field name="code">account.voucher</field>

</record>

<record id="seq_cloan_code_inh2" model="ir.sequence">

<field name="name">SEQ ID</field>

<field name="code">account.voucher</field>

<field name="prefix">SEQ</field>

<field name="padding">2</field>

</record>

</data>

</openerp>

Avatar
Discard
Best Answer

Hi,

For starting a sequence from a particular number you can give the starting number(number_next) when you define sequence(ir.sequence) in xml file.

For Eg (you want to start from 5000) :

<record id="seq_brand" model="ir.sequence">

<field name="name">Brand</field>

<field name="code">product.brand</field> # name of type

<field name="padding">5</field>

<field name="number_next">50000</field> # first number

<field name="number_increment">1</field> # increment by

</record>


Hope this helps....

Avatar
Discard
Author

Thanks it working........

Best Answer



Hello,

You can set your sequence next number from setting -> sequence and identifiers -> sequence.

Set next number field value as per your requirement.


This is also you can set by code when you define sequence.

Thanks.

Openies


Avatar
Discard
Author

Thanks

Best Answer

By using sql query to alter the sequence

ALTER SEQUENCE seq_cloan_code_inh2  RESTART WITH 5000;

Note:
When creating a sequence manually, the naming format used is  'ir_sequence_DATABASE_ID'  e.g. ir_sequence_071 for a sequence with db id=71.

Avatar
Discard
Author

Thanks