Community mailing list archives

community@mail.odoo.com

Re: Dynamic O2M Tree View based on value of another field

by
Andre Kurniawan
- 07/14/2016 05:43:53
Hello Omal Bastin,

I'm afraid I can't do that since I have more than 5 selection (and more later), and it would cause the client to slows down to load all the O2M fields (although it is hidden, it would also loaded right?).


On 07/14/2016 04:37 PM, Omal Bastin wrote:

Try creating different one2many fields to the same parent key. If you have 5 selection, create 5 o2m fields.

<field name="sel_field" />

<field name="on2m_field1" attrs="{'invisible':[('sel_field','!=','first_option_in_sel_field')]}">

     <tree>

              <field name="field_a" />

              <field name="field_b"/>

              <field name="field_c"  />

              <!-- all all fields needed for this tree view -->

     </tree>

</field>

<field name="on2m_field2" attrs="{'invisible':[('sel_field','!=','second_option_in_sel_field')]}">

     <tree>

              <field name="field_a" />

              <field name="field_b"/>

              <field name="field_d"  />

              <!-- all all fields needed for this tree view -->

     </tree>

</field>

and so on.. But you need to take extra care in this so that adding data in any of these one2many field and then changing to other selection will hold the old data in the one2many. so you will need to clear that

On 14-Jul-2016 2:54 pm, "vak0160" <vak0160.work@gmail.com> wrote:

Hello Mohammad Alhashash,

I did try with attrs attributes and as you said, it didn't work. Is there any other way?

On 07/14/2016 02:12 PM, Mohammad Alhashash wrote:

I do not think it will work; 'attrs' attributes in list views work on individual rows, it will hide the value but the column will still be shown. Also, 'attrs' evaluation context does not include 'parent' variable (in Odoo v8.0 and below, not sure about v9.0)


On 14/07/16 06:37, nikesh panoth wrote:
Hello,

It is possible by adding condition for "invisible" attribute in each field in xml as:

<field name="sel_field" />
<field name="on2m_field">
     <tree>
              <field name="field_a" />
              <field name="field_b" attrs="{'invisible': [(parent.sel_field,'in',['view1','view2'])]}" />
              <field name="field_c" attrs="{'invisible': [(parent.sel_field,'in',['view1'])]}" />
              <field name="field_d" attrs="{'invisible': [(parent.sel_field,'in',['view2'])]}" />
              <field name="field_e" attrs="{'invisible': [(parent.sel_field,'in',['view3'])]}" />
              <field name="field_f" attrs="{'invisible': [(parent.sel_field,'in',['view3'])]}" />
     </tree>
</field>

Hope this will work .

Thanks & Regards

On Thu, Jul 14, 2016 at 6:36 AM, vak0160 <vak0160.work@gmail.com> wrote:

Hello Carlos,

I don't want to filter the result, but I want to set the visibility of field/column of a O2M field dynamically based on a selection field.

On 07/13/2016 09:46 PM, Carlos Rodríguez wrote:
Hello,

Isn't this covered with the search?, you can filter the value of the selection field, and the results in the tree view will match it.

Regards,

2016-07-12 23:47 GMT-05:00 vak0160 <vak0160.work@gmail.com>:

Hello Community,

I have a O2M field and a selection field. Can I set the visible fields for O2M field’s Tree based on the selection field?

For example:

  • Selection field = view1
field a field b field c
a b c
  • Selection field = view2
field a field b field d
a b d
  • Selection field = view3
field a field e field f
a e f
-- 
Regards,
Andre

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


-- 
Regards,
Andre

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


-- 
Regards,
Andre

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


-- 
Regards,
Andre