← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 607499] Re: all onchange methods activated after any error message or after page reload

 

can you check if it's fixed or not in trunk ?

** Changed in: openobject-client-web
       Status: In Progress => Incomplete

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/607499

Title:
  all onchange methods activated after any error message or after page reload

Status in OpenObject Web Client:
  Incomplete

Bug description:
  This a bug that requires complicated settings.

I am using openerp-web version 5.0.11. firefox 3.5.9

I have a following form:
field A which is a many2one filed
field B which is a string
field C which is a string
button X that checks the correctness of field C and displays an error or changes the state if an object

On field A I have an onchange() function that automatically fills field B.
User can change field B afterwards.

Suppose the user fills field A, then changes field B and chooses a wrong option in field C.
When he clicks the button, An error page appears (I use standard raise osv.except_osv())

When he/she clicks "OK" he comes back to the form using history.back(javascript call)
What happens there is strange. Coming back using history (at least in firefox 3.5) reruns the onchange function of field A. This changes the value of field B. without any user action, which is wrong because user didn't want that and have already set up the value of the field. In other systems such behaviour migh have big bad implications.

The solutions that will satisfy me would be (maybe anyone knows how to do it)
1. changing the forms so that they execute onchange only when user chnges manually the value of the filed, not on reload or back/forward button. I think that this is the way in should be.
2. enable button functions to return {'warning':{}} like the onchange fuctions, which will make a popup window or giving any other way of making popups.
3. Make osv.except_osv() make a popup window (or enable this in the configuration)
4. Or at least make the form completely blank once you reload the page

The only solution (nasty workaround) I can think myself is to make a hidden variable that will be set to "error" if the button click results in an error (by setting it to "error" at the beginning of a function and setting to "no_error" at the end). If value is "error" than all onchange methods will not do anything. It is a really nasty hack and I would like to avoid it as long as I can.