Odoo Help

0

How to start a sequence from a particular number like 5000 or 6000?

By
Odoo
on 4/17/15, 1:35 AM 1,018 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>

2
Baiju KS
On 4/17/15, 2:46 AM

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....

Thanks it working........

Odoo
on 4/17/15, 3:24 AM
1
Openies Services
On 4/17/15, 2:31 AM



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


Thanks

Odoo
on 4/17/15, 3:24 AM
0

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.

Thanks

Odoo
on 4/17/15, 3:24 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.

Register

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)

Stats

Asked: 4/17/15, 1:35 AM
Seen: 1018 times
Last updated: 4/17/15, 3:24 AM