← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 659782] [NEW] [5.0] conditionally required fields highlighted in 'view' mode

 

Public bug reported:

Thank you for your speedy fix to my last problem! :) Unfortunately I've
found another bug with conditional formatting:

We have a number of fields conditionally made required (using attrs).
When the form is shown in 'view' mode, these fields are incorrectly
highlighted blue.

The problem seems to be in the 'form_setRequired()' function in
static/javascript/form_state.js. It does not take into account whether
the form is editable or not (_terp_editable).

Please see my below suggested fix (starting from line 319 of
form_state.js):

var form_setRequired = function(container, field, required) {
    
    var editable = getElement('_terp_editable').value;

    if (editable == 'True') {
        if (required) {
            MochiKit.DOM.addElementClass(field, 'requiredfield');
        } else {
            MochiKit.DOM.removeElementClass(field, 'requiredfield');
        }
    }
    MochiKit.DOM.removeElementClass(field, 'errorfield');

    var kind = MochiKit.DOM.getNodeAttribute(field, 'kind');
    
    if (field.type == 'hidden' && kind == 'many2one') {
        form_setRequired(container, getElement(field.name + '_text'), required);
    }
}

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

-- 
[5.0] conditionally required fields highlighted in 'view' mode
https://bugs.launchpad.net/bugs/659782
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:
Thank you for your speedy fix to my last problem! :) Unfortunately I've found another bug with conditional formatting:

We have a number of fields conditionally made required (using attrs). When the form is shown in 'view' mode, these fields are incorrectly highlighted blue.

The problem seems to be in the 'form_setRequired()' function in static/javascript/form_state.js. It does not take into account whether the form is editable or not (_terp_editable).

Please see my below suggested fix (starting from line 319 of form_state.js):

var form_setRequired = function(container, field, required) {
    
    var editable = getElement('_terp_editable').value;

    if (editable == 'True') {
        if (required) {
            MochiKit.DOM.addElementClass(field, 'requiredfield');
        } else {
            MochiKit.DOM.removeElementClass(field, 'requiredfield');
        }
    }
    MochiKit.DOM.removeElementClass(field, 'errorfield');

    var kind = MochiKit.DOM.getNodeAttribute(field, 'kind');
    
    if (field.type == 'hidden' && kind == 'many2one') {
        form_setRequired(container, getElement(field.name + '_text'), required);
    }
}





Follow ups

References