Mohammed Shekha(Open ERP) has proposed merging
lp:~openerp-dev/openobject-client-web/6.0-opw-381794-msh into
lp:openobject-client-web.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-client-web/6.0-opw-381794-msh/+merge/90074
Hello,
Fixed the issue of initial onchange trigger from m2o field.
Demo :- HR -> Expenses -> create new expense you will see onchange is not fired
from Employee field, employee field have onchange which sets department.
Reason :- Here in m2o.js we have removed attr callback from visible field
(there is always one hidden field for each visible field), to avoid calling
onChange two times one from hidden field and one from visible field(According
to Revision no. 4618) but due to this revision initial_onchange has been stop
working because we have called initial_onchange on form ready, when form have
been ready at that time m2o.js already removed the callback attr from visible
field so when initial_onchange is called it will not call the on_change of
employee field, initial_onchange is called only for visible fields not for
hidden fields, so due to removal of callback attr from visible employee m2o
onChange is not called.
If we remove this revision then initial onchange will be called but when user
change that field at that time onchange will be called two times because we
have bind all m2o field with on_change method of m2o.js, and one another
on_change is called for callback on visible field, so we need to remove
callback from visible field but we will remove after form load so when form is
loaded at that time one time initial_onchange is called and after that we will
remove callback from visible field so now when user change the field at that
time only binded field onChange called.
So Changed the code and removed the callback after form is loaded.
Thanks.
--
https://code.launchpad.net/~openerp-dev/openobject-client-web/6.0-opw-381794-msh/+merge/90074
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-client-web/6.0-opw-381794-msh.
=== modified file 'addons/openerp/static/javascript/m2o.js'
--- addons/openerp/static/javascript/m2o.js 2011-08-04 14:07:40 +0000
+++ addons/openerp/static/javascript/m2o.js 2012-01-25 11:01:42 +0000
@@ -72,7 +72,7 @@
keyup: jQuery.proxy(this, 'on_keyup'),
focus: jQuery.proxy(this, 'gotFocus'),
blur: jQuery.proxy(this, 'lostFocus')
- }).removeAttr('callback');
+ });
this.lastTextResult = this.text.value;
@@ -96,10 +96,12 @@
};
ManyToOne.prototype.gotFocus = function(evt) {
+ jQuery(this.text).removeAttr('callback');
this.hasFocus = true;
};
ManyToOne.prototype.lostFocus = function() {
+ jQuery(this.text).removeAttr('callback');
this.hasFocus = false;
if(this.selectedResult || this.lastKey == 9) {
this.lastKey = null;
@@ -233,6 +235,7 @@
};
ManyToOne.prototype.on_keyup = function() {
+ jQuery(this.text).removeAttr('callback');
// Stop processing if a special key has been pressed. Or if the last search requested the same string
if(this.specialKeyPressed || (this.text.value == this.lastSearch)) return false;
@@ -266,6 +269,7 @@
};
ManyToOne.prototype.on_keydown = function(evt) {
+ jQuery(this.text).removeAttr('callback');
this.lastKey = evt.which;
// Used to stop processing of further key functions
this.specialKeyPressed = false;
@@ -358,6 +362,7 @@
};
ManyToOne.prototype.on_keypress = function(evt) {
+ jQuery(this.text).removeAttr('callback');
// We use 'keyCode' instead if 'which' because keypress is only triggered on 'character' keys except in firefox.
if (evt.keyCode == 9 || evt.ctrlKey) {
return true;
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp