Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion web_widget_open_tab/models/ir_ui_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ def fields_view_get(
arch = etree.fromstring(res["arch"])
model = self.env["ir.model"]._get(self._name)
if view_type == "tree" and model.add_open_tab_field:
res.setdefault("fields", {})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what situation could res["fields"] be missing?

if "id" not in res["fields"]:
res["fields"].update(self.fields_get(["id"]))
id_elem = """<field name="id" widget="open_tab" nolabel="1"/>"""
id_elem = etree.fromstring(id_elem)
tree = arch.xpath("//tree")[0]
name_field = self._get_name_field(tree)
if name_field:
tree = arch.xpath("//tree")[0]
tree.insert(name_field[0].getparent().index(name_field[0]) + 1, id_elem)
else:
tree.insert(0, id_elem)
Expand Down