# Allow "Mixin" views

**URL:** https://discuss.tryton.org/t/allow-mixin-views/1463
**Category:** Ideas
**Created:** [June 11, 2019, 9:30am UTC](https://discuss.tryton.org/t/allow-mixin-views/1463 "2019-06-11T09:30:52Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![albert](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/albert/32/21_2.png) [@albert](https://discuss.tryton.org/u/albert)
#### Post date: [June 11, 2019, 9:30am UTC](https://discuss.tryton.org/t/allow-mixin-views/1463/1 "2019-06-11T09:30:52Z")

</div>

We’ve got a case in which we created a [Mixin](https://bitbucket.org/nantic/trytond-farm/src/f52c2a7421bc3b5456dd25817d5b56ed274718e5/events/abstract_event.py#lines-37) that is used in several models (ie: [https://bitbucket.org/nantic/trytond-farm/src/f52c2a7421bc3b5456dd25817d5b56ed274718e5/events/abort\_event.py#lines-12](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](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](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?

---

<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: [June 11, 2019, 9:59am UTC](https://discuss.tryton.org/t/allow-mixin-views/1463/2 "2019-06-11T09:59:30Z")

</div>

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

---

<div class="post-metadata">

### Author: ![resteve](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/resteve/32/823_2.png) [@resteve](https://discuss.tryton.org/u/resteve)
#### Post date: [June 11, 2019, 2:48pm UTC](https://discuss.tryton.org/t/allow-mixin-views/1463/3 "2019-06-11T14:48:27Z")

</div>

> [@ced](#):
>
> 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.
