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.

0

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

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

--Baiju--
3154
| 5 4 8
Kochi, India
--Baiju--
ODOO technical and functional

        I like learning new thing, especially technical thing. I am a quick learner, I can learn technical things very fast. I have good logical skill,  I have immense interest in programming.

e-mail id : baijuks@hotmail.com

Baiju
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

--Openies Services--
925
| 2 2 4
Vadodara, India
--Openies Services--

We provide Odoo Services.

Contact us on : contact@openies.com

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

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3883
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 4/17/15, 1:58 AM

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

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: 4/17/15, 1:35 AM
Seen: 620 times
Last updated: 4/17/15, 3:24 AM