Closed yajo closed 8 years ago
Thanks a lot! Some remarks:
Onchange methods usually should raise warnings instead of returning them
I don't agree. Returning warnings in an onchange is actually the only non-blocking warning tool available in Odoo, so I would keept it. Moreover, I would keep vals['domain']
and vals['warning']
, and return vals
, for clarity.
What do you mean by "non-blocking warning tool"?
What do you mean by "non-blocking warning tool"?
A raise
will stop the execution of the Python code, and do a rollback. On the other hand, when you return a warning, it will just display a pop-up and continue the execution of the Python code. In an onchange, you usually don't want to trigger a raise.
Well actually AFAIK in onchanges, Wanings have special behavior in onchanges. I think they serve to stop execution, while the returned value is for not stopping it, but I'm not sure, but since this is just a snippet, I'll add it.
Some improvements:
@api.one
is deprecated. Using@api.multi
.self
.