← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 659507] [NEW] [5.0] no span for empty text fields in view mode

 

Public bug reported:

We had a problem with a form with lots of fields conditionally hidden
(using attrs)

We were finding some of the fields were not being hidden in 'view' mode,
whereas all the fields were hidden correctly in 'edit' mode. Also a
JavaScript error was occuring ('obj' is undefined, on line 828 of
MochiKit/DOM.js)

Eventually tracked the problem down to the logic in
openerp/widgets/templates/text.mako  :

The original logic:

% if not editable and value:
<span kind="${kind}" id="${name}">
    % for line in value.split('\n'):
    <br>${line}</br>
    % endfor
</span>
% endif

This means a SPAN is only created if there is a value in the field. This
causes javascript errors as MochiKit cannot find the field placeholder
to modify its properties (i.e. to make it invisible). The fix is just to
move the check for 'value' inside of the span tag to ensure it is always
created:

% if not editable:
<span kind="${kind}" id="${name}">
  % if value:
    % for line in value.split('\n'):
    <br>${line}</br>
    % endfor
  % endif
</span>
% endif

Job done :)

** Affects: openobject-client-web
     Importance: Undecided
         Status: New

-- 
[5.0] no span for empty text fields in view mode
https://bugs.launchpad.net/bugs/659507
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to OpenERP OpenObject.

Status in OpenObject Web Client: New

Bug description:
We had a problem with a form with lots of fields conditionally hidden (using attrs)

We were finding some of the fields were not being hidden in 'view' mode, whereas all the fields were hidden correctly in 'edit' mode. Also a JavaScript error was occuring ('obj' is undefined, on line 828 of MochiKit/DOM.js)

Eventually tracked the problem down to the logic in openerp/widgets/templates/text.mako  :

The original logic:

% if not editable and value:
<span kind="${kind}" id="${name}">
    % for line in value.split('\n'):
    <br>${line}</br>
    % endfor
</span>
% endif

This means a SPAN is only created if there is a value in the field. This causes javascript errors as MochiKit cannot find the field placeholder to modify its properties (i.e. to make it invisible). The fix is just to move the check for 'value' inside of the span tag to ensure it is always created:

% if not editable:
<span kind="${kind}" id="${name}">
  % if value:
    % for line in value.split('\n'):
    <br>${line}</br>
    % endfor
  % endif
</span>
% endif

Job done :)





Follow ups

References