DocMarty84 / atom-odoo-snippets

Odoo snippets for Atom editor
MIT License
14 stars 8 forks source link

Better complex fields. #4

Closed yajo closed 8 years ago

yajo commented 8 years ago

Some improvements:

DocMarty84 commented 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.

yajo commented 8 years ago

What do you mean by "non-blocking warning tool"?

DocMarty84 commented 8 years ago

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.

yajo commented 8 years ago

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.