Show different columns / fields in list view based on state

I got an interesting question about the list view in the Tryton client. We have a list of machines and sorted them based on their state (same as the list from sale or purchase). The question is now:

Is it possible to show and hide columns / fields based on the state?

Example:
columns in state ‘draft’:
machine | list_price | sale_date

columns in state ‘inuse’:
machine | location

How would you do so, if in the list there is both document in the state draft and in the state inuse?
Which columns should be displayed?

Indeed if there is a domain (or tab domain) with the constraint field = <value> then the client hide the column for the field automatically.

Ah, do you call that a TAB domain :smile: We have that. So in our XML file we have

<record model="ir.action.act_window.domain" id="act_asset_domain_draft">
  <field name="name">Draft</field>
  <field name="sequence" eval="10"/>
  <field name="domain" eval="[('state', '=', 'draft')]" pyson="1"/>
  <field name="act_window" ref="asset.act_asset"/>
  <field name="count" eval="True"/>
</record>
<record model="ir.action.act_window.domain" id="act_review_domain_inuse">
  <field name="name">In Use</field>
  <field name="sequence" eval="50"/>
  <field name="domain" eval="[('state', '=', 'in_use')]" pyson="1"/>
  <field name="act_window" ref="asset.act_asset"/>
  <field name="count" eval="True"/>
</record>

In the models we have some fields:

  • name
  • list_price
  • sale_date
  • location

When the user clicks on the tab “in use”, the location is relevant because the machine is in use. When the machine is in “draft” it is just created so location does not matter because it’s empty.
Is it possible the hide location when the user clicks on the tab “draft”? For example in the tree XML add something like:

<field name="location" visible="[('state', '=', 'in_use')]" />

No it is not possible because there is not guarantee that the state is always the same for all the records.
You can only do that by applying a domain with equality on the field.

Thanks for clarifying.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.