Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5951 Lượt xem

Hi,

How do you hide field on a Form View

base on a field of another table?


Config Table field:  tble_config.showlocation

Form Table field optional:  customer.location_id

I want location_id to shown only when my tble_config.showlocation is true.


 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

In your model, where you need to hide the field optionally, add a new related field or computed field, which compute the value from the other table, then based on this field you can hide the field using the attributes in the XML.

Steps:

  1. Define new related/compute field in model A from model B

  2. Add this field to corresponding view and keep it invisible

  3. Based on the newly added control the visibility of the other field using the attrs in XML

Sample:

<field name="page_width" attrs="{'invisible': [('format','!=','custom')]}" />

Reference:

  1.   How to Write Compute Field and its Function in Odoo

  2.   How To Add Related Fields in Odoo

  3.   Hide Fields Based on Conditions in Odoo

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 3 15
4358
1
thg 2 21
13828
3
thg 3 15
6700
0
thg 2 25
1312
0
thg 1 25
1136