Odoo Hilfe

0

1
4 Antworten
1
Avatar

Yenthe Van Ginneken Belgien

--Yenthe Van Ginneken--
24879
| 9 9 12
Turnhout, Belgien
--Yenthe Van Ginneken--


Yenthe Van Ginneken Belgien
09.05.17, 06:51

Hi Othmane,


Why do you have @api.multi above the @api.onchange? They should not be combined, you only need the onchange.
As for the value assigning: why don't you simply write on self right away? Your code should look like this:

@api.onchange(lgs)
def on_change_state(self):
    for record in self:
if record.lgs:
record.state = 'waiting'
else:
record.state = 'draft'
print self.state, self.lgs


Regards,

Yenthe

1 Kommentar
Menara Services, Othmane Ghandi Marokko
09.05.17, 06:56

@api.multi above the @api.onchange They should not be combined: You are right !! thanks !!

But it's working hhh

0
Avatar

Mohammed Amal N Indien

--Mohammed Amal N--

2277
| 6 4 9
Ernakulam, Indien
--Mohammed Amal N--

Email : mohammedamal.n@gmail.com

Blog: https://www.blogger.com/profile/14877879550922602186

Mohammed Amal N Indien
09.05.17, 06:48

You are not writing values to self,

Try this  self.write(values)

1 Kommentar
Menara Services, Othmane Ghandi Marokko
09.05.17, 07:09

I tried it but it doesn't solve my problem :(

0
Othmane Ghandi Marokko
09.05.17, 06:54

Mohammed Amal

I tried it but it didn't work.

I got the answer from a colleague "Maniganda" : in my case I removed the " readonly=True " attribute of the state fields and it work !!
 

0
zahid Marokko
09.05.17, 06:56

onchange method does not need to retrun a value. 

you can do this 

@api.multi
@api.onchange('lgs')
def on_change_state(self):
 
for record in self:
if record.lgs:
record.state = 'waiting'
else:
record.state = 'draft'
Fragen Sie
Writer
Keep Informed
1 Verfolger
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