Odoo Help

1

How to implement sequences [Closed]

By
cdn
on 3/29/13, 4:34 PM 16,621 views

The Question has been closed

by
Sudhir Arya (ERP Harbor Consulting Services)
on 04/18/2013 05:20:12

I'm new at openerp and a little bit confused about all.

I would like to add a sequence to automatically create customers ID. For that I need to create a xml file and implement this, right?

But I have no idea where I have to do this. Is there a manual for openerp, where this is explained?

Thank you

4

Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
11549
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 

LinkedIn

Blog

Stackoverflow

Sudhir Arya
ERP Harbor Consulting Services
skype: 
sudhir@erpharbor.com 
Sudhir Arya (ERP Harbor Consulting Services)
On 3/30/13, 10:42 AM

Create sequence.xml file and add it in data in __openerp__.py

Here is an example for sequence:

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

After creating sequence in xml, you can call that sequence from your code:

my_sequence = self.pool['ir.sequence'].get(cr, uid, seq_obj_name)
self.write(cr, uid, [picking.id], {'ur_emp_no_field': my_sequence})

You can call this sequence either from create or from your own function or from _defaults.

Hope this will sort out your confusion.

Thanks

Thanks for your answer, but this manual do not help me. I don't know where to call the sequence and also do not know the structure of a module. Isn't there sth. like an overview ? Thanks for your replies

cdn
on 3/30/13, 1:36 PM

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

what is [picking.id]? and also how can i use my current id without 'ids' in the argument field of the ORM create method

Atchuthan
on 7/1/13, 3:57 AM

Add this in your create method:

vals['your_field_name'] = my_sequence
Sudhir Arya (ERP Harbor Consulting Services)
on 7/1/13, 6:32 AM

yeah i tried... but this will provide the value after clicking on "SAVE" button.

Atchuthan
on 7/1/13, 6:41 AM

That is normal. When you create a new record and click on Save button, create method is called and then record is saved to database.

Sudhir Arya (ERP Harbor Consulting Services)
on 7/1/13, 6:54 AM

my requirement is to display the sequence generated in the form. If I use _defaults to provide the value... the sequence generated are always even numbers like E002, E004, E006, etc...

So how can I show the sequence at the same time the value must not change after clicking on "SAVE" button

Atchuthan
on 7/1/13, 7:14 AM

If you are generating sequence code from _default, then make sure you have removed get sequence code from create method.

Sudhir Arya (ERP Harbor Consulting Services)
on 7/1/13, 7:19 AM

If I use _default and display in the form, at the opening of the form the employee number is E001 and after adding values to other field. When "SAVE" button is clicked, the records employee number changes to E002.

Atchuthan
on 7/1/13, 7:27 AM

Did you remove code from create method for sequence?

Sudhir Arya (ERP Harbor Consulting Services)
on 7/1/13, 9:07 AM

I already removed it in create

Atchuthan
on 7/1/13, 11:06 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

4 follower(s)

Stats

Asked: 3/29/13, 4:34 PM
Seen: 16621 times
Last updated: 3/24/17, 9:22 AM