Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Real Estate
    • Real Estate Agency
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consulting
    • Accounting Firm
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Solar Energy Systems
    • Shoe Maker
    • Serveis de neteja
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Hiding buttons depending on state or value?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
hidestatebuttons
3 Respostes
22716 Vistes
Avatar
mike

I have implemented an audit feature for stock moves using a wizard. The shipments and moves are flagged for auditing depending on certain criteria and the flagged moves display buttons for the wizard. The stock.move model has new Boolean fields for audit flag and audit_fail. When audit flag is set True the Audit button is displayed in form and tree views. When audit_fail is set True then its corresponding button is displayed. However I need to hide audit flag when state is done and this is not happening. Refer to code.

<!-- Stock Move Form (inherit)-->
        <record id="stock_move_form_inherit" model="ir.ui.view">
            <field name="name">stock.move.form.inherit</field>
            <field name="model">stock.move</field>
            <field name="inherit_id" ref="stock.view_move_form" />
            <field eval="5" name="priority"/>
            <field name="arch" type="xml">
                <field name="date" position="after">
                  <field name="audit" invisible="1" />
                  <field name="audit_fail" invisible="1" />
                  <field name="note" />
                </field>
                <field name="product_uom" position="after">
                  <button name="%(vmi.move_audit)d" icon="gtk-find" type="action" class="oe_highlight" string="Audit" help="Audit" attrs="{'invisible': [('audit','&lt;&gt;', True)]}" states="draft,waiting,confirmed,assigned" />
                  <button name="fail_audit" icon="gtk-dialog-warning" type="object" class="oe_highlight" string="Failed Audit" help="Failed Audit" attrs="{'invisible': [('audit_fail','&lt;&gt;', True)]}" />            
                </field>
          </field>
        </record>
<!-- Stock Move Tree (inherit)-->
        <record id="stock_move_tree2_inherit" model="ir.ui.view">
            <field name="name">stock.move.tree2.inherit</field>
            <field name="model">stock.move</field>
            <field name="inherit_id" ref="stock.view_move_tree_reception_picking" />
            <field eval="5" name="priority"/>
            <field name="arch" type="xml">
                <field name="date" position="after">
                  <field name="audit" invisible="1" />
                  <field name="audit_fail" invisible="1" />
                </field>
                <field name="product_qty" position="after">
                  <button name="%(vmi.move_audit)d" icon="gtk-find" type="action" colspan="1" help="Audit" attrs="{'invisible': [('state','=','done'),('audit','&lt;&gt;', True)]}" />
                  <button name="fail_audit" icon="gtk-dialog-warning" type="object" colspan="1" help="Failed Audit" attrs="{'invisible': [('audit_fail','&lt;&gt;', True)]}" />
                </field>
            </field>
        </record>

class vmi_stock_move(osv.osv):
    """Override of stock.move"""
    _name = 'stock.move'
    _inherit = 'stock.move'
    _columns = {
        'audit': fields.boolean('Audit'),
        'audit_fail': fields.boolean('Failed Audit'),
        }
    _defaults = {
        'audit': False,
        'audit_fail': False,
        }

I try both states attribute and attrs with domain and neither hides the button when the field is true. Only the value of the field is being used to determine display. Can I use both the field value and the state like this or is it a conflict?


You can see in screenshot where moves in Done state still have audit buttons. They should not be there when Done but the flag needs to remain set regardless. Move form with audit buttonMove tree with audit button

1
Avatar
Descartar
Avatar
AJ Schrafel Paper Corp
Best Answer

You want to hide it when state is done OR audit is false?

audit is a boolean, keep it simple make it = False instead of <> True

Second add the OR | operator at the front, the default operator between tuples is AND & in this case.

['|',('state','=','done'),('audit','=', False)]
2
Avatar
Descartar
mike
Autor

Perfect. I added the OR operator and it works as desired. Now I can leave the boolean set for determining if a move was completed without the required audit being performed. Excellent! Thank you so much for the assistance!!!!

Avatar
Sehrish
Best Answer

Try this

<button name="your_button_name"  string="My Button"  type="object" class="oe_highlight" attrs="{'invisible':['|',('state','=','done'),('audit','=', False)]}"/>

1
Avatar
Descartar
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
desactiver le bouton envoyer par email pour des utilisateurs
hide buttons
Avatar
0
de set. 25
1879
button in a tree view is shown to the user that are not assigned to the user group
hide buttons usergroup
Avatar
0
de febr. 23
2380
How can I hide a <button ?
hide buttons odoo8.0
Avatar
Avatar
2
de jul. 16
5307
How to remove "View Delivery Order" button from confirmed sale orders for a specific user?
hide buttons remove
Avatar
Avatar
1
de març 15
9751
Hide buttons depending on the state of a checkbox that is in res.users[SOLVED] Solved
community hide buttons odoo
Avatar
Avatar
Avatar
Avatar
3
de juny 23
5342
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now