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

[Solved] How do you auto increment a field? - Odoo 8

By
Siobhan
on 6/5/15, 4:35 AM 1,268 views

Hello

I want to increment a ticket number field every time a new ticket is created. I have looked on this site and found the following code for EPR7


.xml

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

<field name="name">Employee Number</field>

<field name="code">hr.employee</field>

</record>

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

<field name="name">Employee Number</field>

<field name="code">hr.employee</field>

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

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

</record>

.py

my_sequence = self.pool['ir.sequence'].get(cr, uid, seq_obj_name)

self.write(cr, uid, [picking.id], {'ur_emp_no_field': my_sequence})


My questions:

It this the same for Odoo8?

Can it be used for just one field?

Is there additional things I need to do to get this to work?

2
ahmad
On 6/5/15, 5:08 AM

it is the same for odoo8.


yes. change to your model name.

Do I just change "hr.employee" with my module name?

Siobhan
on 6/5/15, 5: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

1 follower(s)

Stats

Asked: 6/5/15, 4:35 AM
Seen: 1268 times
Last updated: 7/28/15, 10:09 PM