Community mailing list archives

community@mail.odoo.com

RE: Getting field in javascript

by
heba.fahmy
- 01/28/2015 12:19:40

Dear Borni,

Thanks for your reply

I have tried it but the alert does not display.

It does not through errors but the functionality of “alert” does not work. There are now any messages are displayed.

 

 

 

From: Borni DHIFI [mailto:dhifi.borni@gmail.com]
Sent: Wednesday, January 28, 2015 4:49 PM
To: Community
Subject: Re: Getting field in javascript

 

Hi,
try:

   var model = new instance.web.Model('survey.user_input');
   model.call('get_state', True,undefined,{ shadow:true }).done( function(result) { alert(result);} );

 

2015-01-28 14:27 GMT+01:00 Mohamed Mtloob <mtloob87@gmail.com>:

Dear sir

use "ir.cron" job under your condition i think it may help you ...

Thanks

 

On Wed, Jan 28, 2015 at 3:19 PM, Mohamed Magdy <moh.magdy40@gmail.com> wrote:

Dear Heba,

It will be nice if you format the text in your email, so that we can read it easily.

I reformatted it to make it easier for others to help.


I am working on odoo 8 and I want to get the value of  model field in javascript code to do certain action when this field has certain value.

I tried the following idea but it doesn’t work:

var model = new instance.web.Model("survey.user_input");

model.call("get_state", {context: new instance.web.CompoundContext()}).then(function(result) { alert(result)});

and in the field survey.user_input I created the following function

def get_state(self, cr, uid, automatic=False, context=None):

        user_input_ids = self.search(cr, uid, [],context=context)

        id = len(user_input_ids)-1

        survey_obj = self.browse(cr, uid, id, context=context)

        return {'state': survey_obj.state}

How can this be performed?

Thanks in advance.

 

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

 

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--

Thanks
Mohamed Mtloob

Team Leader.Odoo Developer @ Techorg CO

skype:mohamed.mtloob

whatsapp(020111366018,201025420653)

Linkedin

 

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--

 

Cordialement 

Borni DHIFI

Consultant Technico-Fonctionnel OpenERP/Odoo 

Mobile : 00 216 21809219

 

 

 

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe