Skip to content

Commit

Permalink
Merge branch 'feat/add-height-to-2many-widgets' into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra committed Feb 1, 2024
2 parents 8df8fd5 + f08558b commit c5107c4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/One2many.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ class One2many extends Field {
this._mustExpand = value;
}

/**
* Height
*/
_height?: number;
get height(): number | undefined {
return this._height;
}

set height(value: number) {
this._height = value;
}

constructor(props: any) {
super(props);

Expand Down Expand Up @@ -105,6 +117,14 @@ class One2many extends Field {
if (props.inv_field) {
this._inv_field = props.inv_field;
}

if (props.height) {
try {
this._height = parseInt(props.height);
} catch (e) {
this._height = undefined;
}
}
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/spec/Form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Reference from "../Reference";
import Button from "../Button";
import ButtonGroup from "../ButtonGroup";
import { it, expect, describe } from "vitest";
import One2many from "../One2many";

const XML_VIEW_FORM = `<?xml version="1.0"?>
<form string="Partner Address">
Expand Down Expand Up @@ -3306,4 +3307,20 @@ describe("A Form", () => {
const groupWidget = form.findById("group") as Group;
expect(groupWidget.invisible).toBeTruthy();
});
it("Should be able to parse a o2m with height ", () => {
const arch = `<form>
<group name="group" colspan="4" col="4" attrs="{'invisible':[('formulari','!=','b1')]}">
<field name="o2m" height="50" />
</group>
</form>`;
const form = new Form({
formulari: {
type: "selection",
},
o2m: { type: "one2many" },
});
form.parse(arch);
const o2mField = form.findById("o2m") as One2many;
expect(o2mField.height).toBe(50);
});
});

0 comments on commit c5107c4

Please sign in to comment.