Odoo Help

0

Can we override default form controls?

By
Julian Solorzano
on 9/15/14, 2:25 PM 1,039 views

I know that we can create new javascript modules with new widgets, but is there a way to replace functionality of the already existing default form controls? Say, if I wanted that all text fields in the system automatically converted their input to uppercase, could I do this by extending FieldChar? (and not having to modify the actual views in the system, just that my new code overrided the default field)

One can override default widget, No doubt ... but am not sure whether you can achieve for input data... Alternate option, use Onchange Event...

deep
on 9/16/14, 1:12 AM

Thanks! Yes, it can be done with the onchange event, but the problem is that if I wanted to affect every single field in the system, I would have to extend every single view to add the "onchange" attribute in every single field. Not really an option.

Zenpar S.A. de C.V., Julian Solorzano
on 9/16/14, 1:17 AM
3

Solanki Shamji

--Solanki Shamji--
1298
| 5 2 6
Baroda, India
--Solanki Shamji--

Hello!

Solanki Shamji
On 9/16/14, 5:54 AM

Hello,

You can also use python code for this,

_inherit = 'dummy.dummy'
_columns =
    {
        'dummy_field': fields.char('Dummy', size=80, select=True, required=True)
    }
    
def onchange_case(self, cr, uid, ids, dummy_field, context=None):
    result = {
              'value': { 'dummy_field': str(dummy_field).upper() }
    }
    return result

And call oncahnge function in xml.

Thanks.

 

 

 

0

Ivan

--Ivan--
3235
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 9/16/14, 5:22 AM

Julian, yes you can override FieldChar for that purpose.

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

2 follower(s)

Stats

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