Odoo Help

2

1
1 Answer
7
Avatar

Sudhir Arya (ERP Harbor Consulting Services) India

--Sudhir Arya (ERP Harbor Consulting Services)--
27320
| 8 9 10
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & CTO at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert having 7+ years of Experience in Odoo ERP.

• 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

• Good knowledge and experience in payment gateway integration with Odoo

• Active Memeber on Stackoverflow 

LinkedIn

Blog

Stackoverflow

ERP Harbor Consulting Services

Skype:sudhir@erpharbor.com
Website: http://www.erpharbor.com
Sudhir Arya (ERP Harbor Consulting Services) India
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

10 Comments
cdn Germany
3/30/13, 1:36 PM

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

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

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

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

Add this in your create method:

vals['your_field_name'] = my_sequence
Atchuthan India
7/1/13, 6:41 AM

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

Sudhir Arya (ERP Harbor Consulting Services) India
7/1/13, 6:54 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.

Atchuthan India
7/1/13, 7:14 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

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

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

Atchuthan India
7/1/13, 7:27 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.

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

Did you remove code from create method for sequence?

Atchuthan India
7/1/13, 11:06 AM

I already removed it in create

Ask a Question
Writer
Tag
Keep Informed
4 follower(s)
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