Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
10079 Vizualizări

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

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Cel mai bun răspuns

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')]}"/>
Imagine profil
Abandonează

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 Răspunsuri Vizualizări Activitate
1
aug. 20
2639
5
dec. 19
11262
4
ian. 19
4242
1
ian. 19
7480
7
feb. 18
3631