Odoo Help

Welcome!

This community 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.

1

@api.onchange set fields attributes

By
Nedas Zilinskas
on 5/19/15, 8:14 AM 996 views

I was wondering how to set field attributes (invisible, readonly, domain, ...) in form via @api.onchange (as it was returning the attributes from the method in v7)?


0

Jusab Sida (jsi)

--Jusab Sida (jsi)--
Tiny ERP Pvt Ltd
http://www.odoo.com
874
| 2 1 5
Gandhinagar, India
--Jusab Sida (jsi)--


Jusab Sida (jsi)
On 5/20/15, 9:03 AM

Hi Nedas,

   Right now in onchange no need to return anything(in new api), but there is a case when we want to return some warning, domain or other stuff. So, in this case we can return as old api style like.

--------------------------------------------------

@api.onchange('my_field')

def onchange_my_field(self):

     msg={}

     self.my_other_field = self.my_field #Here just copy whatever come with my_field into my_other_field

     if (self.warning==True):

         msg = { 'title': _('Waning!'), 'message' : 'You have just copy my field into my other field...'

                         }

   return {'warning': msg}

-----------------------------------------------         

same way we can return other stuff.

Hope this will help u as u want...

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/19/15, 8:14 AM
Seen: 996 times
Last updated: 5/20/15, 9:04 AM