Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
11744 Weergaven

Lets suppose I have a field in base module:

class base_module(osv.osv):
    _name="base.module"
    _columns={
                   'state':fields.selection([('open', 'No Recruitment'), ('recruit', 'Recruitement in Progress')], 'Status')                   
                   }

Now I want to override this same field by inheriting the above "base.module"

class inherit_module(osv.osv):
    _inherit="base.module"
    _columns={
                  'state':fields.selection([ ('open', 'No Recruitment'),\
                                         ('submitted','Submitted'),\
                                         ('hod_depart','HOD Approval'),\
                                         ('hr_approval','HR Approval'),\
                                         ('recruit','Recruitement in Progress'),\
                                         ],'Stages',)
                   }

I did this and when I check the table , I did not get the required result Am I doing right, or there is another way to achieve this , or is it not possible ?

Avatar
Annuleer
Auteur Beste antwoord

Well, I got the solution, it is :

class inherit_module(osv.osv):
          _inherit="base.module"
          def __init__(self,pool,cr):
                del super(hr_kanak_job_positions, self)._columns['state'].selection[:]
                new_selection=[('open', 'No Recruitment'),\
                                         ('submitted','Submitted'),\
                                         ('hod_depart','HOD Approval'),\
                                         ('hr_approval','HR Approval'),\
                                         ('recruit','Recruitement in Progress'),]

               super(inherit_module, self)._columns['state'].selection.extend(new_selection)
Avatar
Annuleer

Dear Nishanth,

Thanks for the solution. Can I change the type of the field also? If the field on base class is of type "char" , can I change it to "function" ?

Auteur

You can hide that default field in your inherited view and then you can make a new functional field labeling same as the hidden field, And I hope you can achieve what you asked...

Dear Nishanth,

I have to do this for "product.product"

Based on the selection of a boolean type field...the "Product Name" field's behaviour should be changed.

If the boolean field is True, then "Product Name" field should be of type "fields.function"

If False, then its type should be of that of "Parent class's" ie of product.product.

This is my intention

Auteur

This you can achieve by making two field and then showing them according to the boolean field selection using domain.For example: 'field1':fields.char('Field1',size=20) 'field2':fields.function('Field2' ..............) 'field3':fields.boolean('Field3') Now in the xml file: <field name="field3"/> <field name="field1" attrs="{'invisible': [('field3', '=', True)]}/> <field name="field2" attrs="{'invisible': [('field3', '=', False)]}/> In this way you can achieve what you are looking for ..

Dear Nishanth,

You are absolutely right. I could manage the visibility by "attrs" tag.

In my particular case, the -- The ""Product Name"" should be changed based on the selection. That means... CREATE and EDIT(write),...these functions should also be Overrided based on the Boolean Selection ?, Am I right?

Auteur

I think you should post your question so that the requirement is better understandable .

Gerelateerde posts Antwoorden Weergaven Activiteit
17
dec. 21
24782
1
dec. 18
19843
1
jul. 15
7278
2
mrt. 15
5633
2
mrt. 15
8988