How to hide a field checking if there is a specific record inside?<group attrs="{'invisible':[('210220', 'in', 'events.type_event')]}">type_event = fields.Selection(<field name="events">
[('210200', u'Confirmação da Operação'),
('210210', u'Ciência da Emissão'),
('210220', u'Desconhecimento da Operação'),
('210240', u'Operação não Realizada'),
('110111', u'Cancelamento da Operação')],
string=u'Tipo de Evento',
required=True
)
<tree create="false">
<field name="type_event" readonly="1"/>
<field name="protocol" readonly="1"/>
<field name="write_date" readonly="1"/>
</tree>
</field>
<button name="event_desconhecimento" type="object"
string="Desconhecimento da Operação" class="btn-info btn-block"/>
</group>
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Hello, Michael.
I think we can't set a domain like that, the first parameter should be a field od the model, the second is the operator and the third one is the value.
So, if you want to hide the field depending on the availability of a value in the records of the one2many field, I recommend to create a new field in the model, maybe "type_event_invisible" of type Boolean.
I would define a method with @api.onchange('type_event') as decorator, this method should change the value of type_event_invisible field of the record. As I've tested, all onchange methods get executed at form loading.
Then, the domain for invisible attribute should be {'invisible':[('type_event_invisible', '=', True)]}
I'm not really good explaining, but I hope it can helps. Greetings.
That way I would create disposable fields in the database, so I did it this way:
ciencia = fields.Boolean(
compute='compute_display_view',
store=False,
default=False
)
confirmacao = fields.Boolean(
compute='compute_display_view',
store=False,
default=False
)
desconhecimento = fields.Boolean(
compute='compute_display_view',
store=False,
default=False
)
nao_realizada = fields.Boolean(
compute='compute_display_view',
store=False,
default=False
)
xml_entrada = fields.Boolean(
compute='compute_display_view',
store=False,
default=False
)
def compute_display_view(self):
for record in self:
for x in record.events:
if x.type_event == '210200':
record.confirmacao = True
record.ciencia = True
if x.type_event == '210220':
record.desconhecimento = True
record.ciencia = True
if x.type_event == '210240':
record.nao_realizada = True
record.ciencia = True
if x.type_event == '210210':
record.ciencia = True
for x in record.nsu:
if x.type_response == '1':
record.xml_entrada = True
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
Odoo Date Total In Version 11
Đã xử lý
|
|
3
thg 3 19
|
3452 | |
|
1
thg 5 20
|
6608 | ||
|
3
thg 12 18
|
8930 | ||
|
0
thg 11 18
|
5548 | ||
|
0
thg 5 22
|
3302 |