Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
10253 Представления

Hi,

I am a beginner in python programming,

please help me, 

how to make the button state invisible after clicking, and this is my current code :

<header>
<button name="action_close" type="object" string="Sesi Berakhir" state_id="in" class="btn-primary" />
<field name="state_id" widget="statusbar" statusbar_visible="in,out"/>
</header>

@api.multi
def action_close(self):

self.write({'state_id': 'out'})
self.write({'end_time':fields.Datetime.now(self)})
return self


this image : https://drive.google.com/file/d/1UIkZE6BcWr04lbNMYdtwT-IOSvkoBkfQ/view?usp=sharing


so when the status is "Sesi Berakhir" the "Sesi Berakhir" button is gone

Thanks before :D

Аватар
Отменить
Лучший ответ

The attribute you have passed to hide the button is wrong. You have used state_id as an attribute on the button but it should be states.

Ex:

<button name="action_close" type="object" 
string="Sesi Berakhir" states="in" class="btn-primary" />

States:

Shorthand for invisible attrs: a list of states, comma separated, requires that the model has a state field and that it is used in the view.

Makes the button invisible if the record is not in one of the listed states

Danger

Using states in combination with attrs may lead to unexpected results as domains are combined with a logical AND.

Reference: Odoo Documentation

Аватар
Отменить
Лучший ответ

hello, try like below code in xml.

add the attrs in button tag

<button name="action_close" type="object" string="Sesi Berakhir" state_id="in" class="btn-primary" 
    attrs="{'invisible': [('state_id', '=', 'out')]}"/>
Аватар
Отменить

I also have a problem, but is the edit button of the base. I want to ask about hiding the edit button after clicking the button and in a status

Related Posts Ответы Просмотры Активность
1
авг. 20
2796
5
дек. 19
11432
4
янв. 19
4402
1
янв. 19
7634
7
февр. 18
3771