Odoo Help

0

Create selection type field dynamically?

By
dirtyHandsPHP
on 9/24/14, 2:16 PM 2,648 views

Is it possible to dynamically create selection type field using functional fields? 

For Example : I am having a maximum limit of leaves a person can take at one type

Casual Leave : 2

Sick Leave : 3

User can take these leave with 0.5 interval, means for CL 0.5,1,1.5 and 2

I am having around 10 types of leaves.

So is it possiblt to create a selection type field dynamically in OpenERP?

2

Vasiliy Birukov

--Vasiliy Birukov--
3491
| 7 6 8
Russian Federation
--Vasiliy Birukov--

Help develop and implement any project on base Odoo.

Vasiliy Birukov
On 9/25/14, 1:33 AM

You can use many2one with domain for this purpose.

You need create object "Leave" like:


    _columns = {
        'name': fields.char('Leave'),
        'type': fields.char('Type'),
        'interval': fields.char('interval'),
        }

Then create records for "Leave" with all available combination type and interval.

In object, where you need selection field, define instead many2one to "Leave" object (for example: leave_id).
And define selection filed for type (for example: type).
Now you can dinamically select available leaves, depend from type, like:

    <field name="type"/>
    <field name="leave_id" domain="[('type','=',type)]"/>

Hi Vasilliy ....Can u explain with an example

Odoo
on 9/25/14, 2:19 AM

Vasiliy, Thanks for your answer. It will be great if you can give me an example!!

dirtyHandsPHP
on 9/25/14, 5:00 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

1 follower(s)

Stats

Asked: 9/24/14, 2:16 PM
Seen: 2648 times
Last updated: 3/16/15, 8:10 AM