[FIX] web: many2many_tags field support createDomain to be Boolean
Pass the options: `{'create': False}` to the a many2many_tags field in some arch
Before this commit, there was a crash because the API of the field's props did not
account for that use case.
After this commit, it does.
closes odoo/odoo#98050
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
@@ -145,7 +145,9 @@ export class Many2ManyTagsField extends Component {
|
||||
}
|
||||
|
||||
onBadgeClick(ev, record) {
|
||||
if (!this.canOpenColorDropdown) return;
|
||||
if (!this.canOpenColorDropdown) {
|
||||
return;
|
||||
}
|
||||
const isClosed = !document.querySelector(".o_tag_popover");
|
||||
if (isClosed) {
|
||||
this.currentPopoverEl = null;
|
||||
@@ -284,7 +286,7 @@ Many2ManyTagsField.props = {
|
||||
canEditColor: { type: Boolean, optional: true },
|
||||
canQuickCreate: { type: Boolean, optional: true },
|
||||
colorField: { type: String, optional: true },
|
||||
createDomain: { type: Array, optional: true },
|
||||
createDomain: { type: [Array, Boolean], optional: true },
|
||||
placeholder: { type: String, optional: true },
|
||||
relation: { type: String },
|
||||
nameCreateField: { type: String, optional: true },
|
||||
|
||||
@@ -481,7 +481,7 @@ QUnit.module("Fields", (hooks) => {
|
||||
});
|
||||
|
||||
// First checks that default color 0 is rendered as 0 color
|
||||
let badgeNode = target.querySelector(".o_tag.badge");
|
||||
const badgeNode = target.querySelector(".o_tag.badge");
|
||||
assert.strictEqual(badgeNode.dataset.color, "0", "first tag color should be 0");
|
||||
|
||||
// Update the color in readonly => write automatically
|
||||
@@ -1540,4 +1540,23 @@ QUnit.module("Fields", (hooks) => {
|
||||
"Placeholder"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Many2ManyTagsField supports 'create' props to be a Boolean", async (assert) => {
|
||||
patchWithCleanup(AutoComplete, {
|
||||
timeout: 0,
|
||||
});
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: `<form><field name="timmy" widget="many2many_tags" placeholder="Placeholder" options="{'create': False }"/></form>`,
|
||||
});
|
||||
|
||||
await click(target.querySelector(".o_field_many2many_tags input"));
|
||||
assert.strictEqual(
|
||||
target.querySelector(".o_field_many2many_tags .o-autocomplete--dropdown-menu")
|
||||
.textContent,
|
||||
"goldsilver"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user