Simplify declaration of views

While views are an important concept in Tryton, declaring views in .xml currently is somehow “overhead-ish” and involves quite some redundancy.

Here is an example for declaring tree different views for one model:

    <record model="ir.ui.view" id="station_view_form">
      <field name="model">delivery_tour.station</field>
      <field name="type">form</field>
      <field name="name">station_form</field>
    <record model="ir.ui.view" id="station_view_list">
      <field name="model">delivery_tour.station</field>
      <field name="priority" eval="20"/>
      <field name="type">tree</field>
      <field name="name">station_list</field>
    <record model="ir.ui.view" id="station_view_tree_sequence">
      <field name="model">delivery_tour.station</field>
      <field name="type">tree</field>
      <field name="priority" eval="10"/>
      <field name="name">station_tree_sequence</field>

I propose to add a “views” first-class element like this:

    <views model="delivery_tour.station">
      <view id="station_view_form" type="form">station_form</view>
      <view id="station_view_list" type="tree" priority="10">station_list</view>
      <view id="station_view_sequence" type="tree" priority="20">

or like this:

    <views model="delivery_tour.station">
      <form id="station_view_form" >station_form</form>
      <tree id="station_view_list" priority="10">station_list</free>
      <tree id="station_view_sequence" priority="20">

Of course for backward-compatibility the current structure should still be valid for some time.

What do you think?

I think it’s better to have a generic solution that may work on all XML structure and not only for views.

For me this is a specific use case of Templating the XML files

We’ve already thought about using a more complicated (yet more semantic) XML structure. But our current parser is actually quite simple and it has its kind of beauty in the fact that it’s a thin layer on top of the record creation.

But indeed, your view definitions are way more user friendly than what’s currently in tryton.

Of course the same should be done for other structures. I just focused in views here for briefness.