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

[Solved] Is it possible to start automatic increments at a higher number? - Odoo8

By
Siobhan
on 6/8/15, 4:38 AM 496 views

Using the following code I am able to get a new ticket number when I create but it starts at 0:

.py code:


class helpdesk(models.Model):

_name = 'helpdesk.ticket'

name = fields.Char("Subject", size=128)

res_partner_id = fields.Many2one("res.partner", "Customer")

ticketnumber = fields.Integer("Tkt Num", readonly=True)



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

vals['ticketnumber'] = self.pool.get('ir.sequence').get(cr, uid, 'helpdesk.ticket')

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

_defaults = {

'ticketnumber': lambda obj, cr, uid, context: 0

}



XML code


<data noupdate="1">

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

<field name="name">ticketnumber</field>

<field name="code">helpdesk.ticket</field>

</record>

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

<field name="name">ticketnumber</field>

<field name="code">helpdesk.ticket</field>

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

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

</record>

</data>


Is there a way I can start the count at higher than zero e.g 20151000 and then the next time I create it gives 20151001


Changed code as advised, restarted and upgraded module but still not working:


<data noupdate="1">

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

<field name="name">ticketnumber</field>

<field name="code">helpdesk.ticket</field>

</record>

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

<field name="name">ticketnumber</field>

<field name="code">helpdesk.ticket</field>

<field name="number_next">20151000</field>

<field name="number_increment">1</field>

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

</record>

</data>


hi Siobhan Brand product.brand # name of type *5//padding size equal to your number* *50000 # first number* 1 # increment by Thank You

Ankit Gauri
on 6/8/15, 6:48 AM
3
Ankit Gauri
On 6/9/15, 2:55 AM

hi  Siobhan

this will work

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>

thank you

add my code above.. it won't let me add code in comments for some reason. Really appreciate your help on this.

Siobhan
on 6/9/15, 3:02 AM

hey i have checked it working properly

Ankit Gauri
on 6/9/15, 3:30 AM

dropdb nd try to create new it will work

Ankit Gauri
on 6/9/15, 3:31 AM

Works amazing.. thank you so much...

Siobhan
on 6/9/15, 4:02 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

1 follower(s)

Stats

Asked: 6/8/15, 4:38 AM
Seen: 496 times
Last updated: 6/9/15, 4:02 AM