Allow "Mixin" views

We’ve got a case in which we created a Mixin that is used in several models (ie: https://bitbucket.org/nantic/trytond-farm/src/f52c2a7421bc3b5456dd25817d5b56ed274718e5/events/abort_event.py#lines-12). The mixin adds a bunch of fields.

As we want to keep views consistent among all those models inheriting the Mixin, what we did in previous versions of Tryton was to register the “abstract” model and add some views to it (such as https://bitbucket.org/nantic/trytond-farm/src/default/view/farm_event_form.xml and https://bitbucket.org/nantic/trytond-farm/src/default/view/farm_event_list.xml), so later, other “real” models could inherit those views.

We were forced to register the Mixin because Tryton does not allow us to register views that are not linked to a model (the “model” field is required), although it supports inheriting views from other models.

I think it makes perfect sense to make “model” field not required as it makes sense in cases such as the one in the example.

Thoughts?

I do not think it will be a good thing. If you have a view that goes with a Mixin, you can:

  • override ModelView._view_look_dom_arch to add tags
  • define view that uses the same XML

I don’t understand this point.

I think the idea is available a “base” view and other views inherit the “base” view to add more fields. Same as Mixin in python or “extends” in Jinja2 template.