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:
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.
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?
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.
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”
One example is Merge list views of inventory line, 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.