Skip to content

Commit

Permalink
fix: adjust attributeparser for considering undefined values in selec…
Browse files Browse the repository at this point in the history
…tion fields

Fix gisce/webclient#747
  • Loading branch information
mguellsegarra committed Dec 29, 2023
1 parent 40ddf3a commit dc448ca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/helpers/attributeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ const evaluateFieldComparison = ({
if (
valueInObject === undefined &&
fields[fieldName].type !== "boolean" &&
fields[fieldName].type !== "many2one"
fields[fieldName].type !== "many2one" &&
fields[fieldName].type !== "selection"
) {
return {
modifiedValueInObject: null,
Expand Down
18 changes: 18 additions & 0 deletions src/spec/Form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3288,4 +3288,22 @@ describe("A Form", () => {
const buttonWidget = form.findById("example_button") as Button;
expect(buttonWidget.readOnly).toBeFalsy();
});
it("Should be able to set an invisible group when attrs have a field that has not value", () => {
const arch = `<form>
<group name="group" colspan="4" col="4" attrs="{'invisible':[('formulari','!=','b1')]}">
<field name="at_prefix" />
<field name="bt_prefix" />
</group>
</form>`;
const form = new Form({
formulari: {
type: "selection",
},
at_prefix: { type: "char" },
bt_prefix: { type: "char" },
});
form.parse(arch);
const groupWidget = form.findById("group") as Group;
expect(groupWidget.invisible).toBeTruthy();
});
});

0 comments on commit dc448ca

Please sign in to comment.