# Handling outdated view IDs in bookmarked Sao URLs

**URL:** <https://discuss.tryton.org/t/handling-outdated-view-ids-in-bookmarked-sao-urls/9465>\
**Category:** Developer\
**Created:** [November 9, 2026, 2:35pm UTC](https://discuss.tryton.org/t/handling-outdated-view-ids-in-bookmarked-sao-urls/9465 "2026-11-09T14:35:15Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![acaubet](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/acaubet/32/1493_2.png) [@acaubet](https://discuss.tryton.org/u/acaubet)\
**Post date:** [November 9, 2026, 2:35pm UTC](https://discuss.tryton.org/t/handling-outdated-view-ids-in-bookmarked-sao-urls/9465/1 "2026-11-09T14:35:16Z")

</div>

Sao URLs can contain explicit view IDs. A browser bookmark may therefore keep referring to a view that no longer matches the requested model.

When opening such a URL, `fields_view_get` loads the supplied view and fails while parsing a field that does not exist on the requested model. For example, requesting a sales view with the ID of a purchase form produces this traceback on Tryton 8.0:

```auto
  File "trytond/protocols/dispatcher.py", line 237, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "trytond/model/modelview.py", line 349, in fields_view_get
    result['arch'], result['fields'] = cls.parse_view(
  File "trytond/model/modelview.py", line 511, in parse_view
    fields_def = cls.__parse_fields(
  File "trytond/model/modelview.py", line 730, in __parse_fields
    fields_attrs = cls.__parse_fields(
  File "trytond/model/modelview.py", line 730, in __parse_fields
    fields_attrs = cls.__parse_fields(
  File "trytond/model/modelview.py", line 730, in __parse_fields
    fields_attrs = cls.__parse_fields(
  File "trytond/model/modelview.py", line 627, in __parse_fields
    field = cls._fields[fname]
KeyError: 'purchase_date'

```

Would it make sense to check whether the supplied view is applicable to the requested model and show a clearer error? Or should the client recover by opening the default view?

What would be the expected behaviour for outdated bookmarks?

I preferred to start a discussion before opening an issue, but please let me know if this should be reported as one.

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [November 9, 2026, 3:01pm UTC](https://discuss.tryton.org/t/handling-outdated-view-ids-in-bookmarked-sao-urls/9465/2 "2026-11-09T15:01:16Z")

</div>

> [@acaubet](#):
>
> Would it make sense to check whether the supplied view is applicable to the requested model and show a clearer error?

No because ID are not reused.

> [@acaubet](#):
>
> Or should the client recover by opening the default view?

No

> [@acaubet](#):
>
> What would be the expected behaviour for outdated bookmarks?

Failure

---

<div class="post-metadata">

**Author:** ![acaubet](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/acaubet/32/1493_2.png) [@acaubet](https://discuss.tryton.org/u/acaubet)\
**Post date:** [November 9, 2026, 4:14pm UTC](https://discuss.tryton.org/t/handling-outdated-view-ids-in-bookmarked-sao-urls/9465/3 "2026-11-09T16:14:27Z")

</div>

Calling `sale.sale.fields_view_get` with a purchase form ID reproduces the error. Failure is expected, but could the message explain the incompatible view selection? The `KeyError` led us to investigate missing fields and modules first.

Views can inherit across models, so I understand a simple model equality check would be insufficient. Would improving the error message be worth considering?

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [November 9, 2026, 4:26pm UTC](https://discuss.tryton.org/t/handling-outdated-view-ids-in-bookmarked-sao-urls/9465/4 "2026-11-09T16:26:33Z")

</div>

> [@acaubet](#):
>
> Failure is expected,

But should not happen as IDs are not reused.

---

<div class="post-metadata">

**Author:** ![acaubet](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/acaubet/32/1493_2.png) [@acaubet](https://discuss.tryton.org/u/acaubet)\
**Post date:** [November 9, 2026, 4:45pm UTC](https://discuss.tryton.org/t/handling-outdated-view-ids-in-bookmarked-sao-urls/9465/5 "2026-11-09T16:45:03Z")

</div>

> [@ced](#):
>
> But should not happen as IDs are not reused.

Sorry, I’m not understanding what you mean for reused, user can bookmark this url:  
`https://demo8.0.tryton.org/#demo8.0/model/sale.sale;tab_domain=[["Borrador",[["state","=","draft"]],true],["Presupuesto",[["state","=","quotation"]],true],["Confirmada",[["state","=","confirmed"]],true],["En proceso",[["state","=","processing"]],true],["Excepción",["OR",["invoice_state","=","exception"],["shipment_state","=","exception"]],true],["Todo",[],false]]&views=[642,646]`

This `&views=[642,646]` is causing an error on the server as view id 642 does not exist or it’s not for the correct model. Someone can change the id number intentionally as I did now, but most of the time, it’s because the user have the urls from previous migrations or whatever on browser bookmarks.

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [November 9, 2026, 4:57pm UTC](https://discuss.tryton.org/t/handling-outdated-view-ids-in-bookmarked-sao-urls/9465/6 "2026-11-09T16:57:54Z")

</div>

If user change the URL, it is normal that the URL does not work.  
Now show me a case where this can happen without altering the URL on purpose.

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [November 9, 2026, 5:02pm UTC](https://discuss.tryton.org/t/handling-outdated-view-ids-in-bookmarked-sao-urls/9465/7 "2026-11-09T17:02:04Z")

</div>

> [@acaubet](#):
>
> `KeyError: 'purchase_date'`

it would be better to raise ValueError

---

<div class="post-metadata">

**Author:** ![acaubet](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/acaubet/32/1493_2.png) [@acaubet](https://discuss.tryton.org/u/acaubet)\
**Post date:** [November 9, 2026, 5:14pm UTC](https://discuss.tryton.org/t/handling-outdated-view-ids-in-bookmarked-sao-urls/9465/8 "2026-11-09T17:14:10Z")

</div>

> [@ced](#):
>
> If user change the URL, it is normal that the URL does not work.

Yeah, I know, I was something usable to just show, because I suspected you did not get the point on telling me about “ids are not reused”

> [@ced](#):
>
> Now show me a case where this can happen without altering the URL on purpose.

One example is [Merge list views of inventory line](https://foss.heptapod.net/tryton/tryton/-/commit/0f9e76e519b3cef5d195bfbbb3fd174da12c4ad0), included in 7.6. It removes `stock.inventory_line_view_tree` and `stock.inventory_line_view_list_simple`, replacing them with `stock.inventory_line_view_list`.

A user could open Inventory lines in 7.4, bookmark the URL generated by sao, then open that same bookmark after upgrading to 7.6. The bookmark would still contain the deleted view ID, without anyone editing the URL.

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [November 9, 2026, 5:26pm UTC](https://discuss.tryton.org/t/handling-outdated-view-ids-in-bookmarked-sao-urls/9465/9 "2026-11-09T17:26:27Z")

</div>

But the ID have not been reused
