Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Set readonly on a button

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
readonlybuttons
2 Respuestas
12304 Vistas
Avatar
Francisco Castro

Hi guys

I dont know what's going on here I tried to set as readonly two buttons when for example I click on it but this dont work.

I have 5 boolean fields to help and I store the True or False option on a database

I have a funtion to update the fields.

 

class account_invoice(osv.osv):
    _inherit = 'account.invoice'
    
    
    _columns = {
        'impressoori' : fields.boolean('Original ja foi impresso'),
        'impressodupl': fields.boolean('Duplicado Impresso'),
        'impressotri' : fields.boolean('Triplicado ja foi impresso'),
        'impressoall' : fields.boolean('Todas as vias ja foram impressas'),
        'impressoseg' : fields.boolean('Segunda via ja impressa')
    }
    
    _defaults = {
        'impressodupl': False,
        'impressoori': False,
        'impressotri': False,
        'impressoall': False,
        'impressoseg': False,
    }

def update_field_all(self, cr, uid, ids,context):
        for invoice in self.browse(cr, uid, ids):
             cr.execute("UPDATE account_invoice SET impressoall = True WHERE id = %d" %(invoice.id) )
             cr.execute("UPDATE account_invoice SET impressodupl = True WHERE id = %d" %(invoice.id) )
             cr.execute("UPDATE account_invoice SET impressotri = True WHERE id = %d" %(invoice.id) )
             cr.execute("UPDATE account_invoice SET impressoori = True WHERE id = %d" %(invoice.id) )
             
             #raise osv.except_osv(_('This is the error title'), _('This is the error message'))
        return True

My Xml file :

record model="ir.ui.view" id="account_invoice_rule_saft_inherit">
            <field name="name">account.invoice.rule.saft.inherit</field>
            <field name="model">account.invoice</field>
            <field name="inherit_id" ref="account.invoice_form"/>
            <field name="arch" type="xml">
        <notebook colspan="4" position="after">
            <!--<button name="%(account.account_invoices)d" position="replace">-->
        <group col="1">
                <field name="impressodupl" nolabel="0" invisible="False" />
                <field name="impressoori" nolabel="0" invisible="False" />
                <field name="impressotri" nolabel="0" invisible="False" />
                <field name="impressoall" nolabel="0" invisible="False" />
          <field name="impressoseg" nolabel="0" invisible="False" />
          
        </group>
     

                  <button name="%(account_invoices_tri_default)d" type="action" string="Triplicado" icon="gtk-print" states="open,paid,proforma,proforma2" attrs="{'readonly':[('impressoall', '=', True)]}"/>

                  <button name="account_invoices_all_default" type="action" string="Todas as Vias" icon="gtk-print" attrs="{'readonly':[('impressoall', '=', True)]}" states="open,paid,proforma,proforma2" />

                 
          </notebook>
               </field>
        </record>

0
Avatar
Descartar
Avatar
Luis Filipe Castanheira
Mejor respuesta

I don't know if it is possible to set the readonly attribute to a button. Why don't you try to make them invisible instead? If you don't want users to click on buttons, it would be less confusing not to show the buttons at all...

_____

Answering to your question. Working with the invisible attribute might be a little more chalenging (even more if you have a complex condition involving more fields). You have to think this way (it helps me): you previously wanted to lock a button when a condition was true. Now, what you want is to "not show" that same button. So, what you have to do to make it work, is to reverse your previous logic.

This way, where you had `attrs="{'readonly':[('impressoall', '=', True)]}"` you have to deny that and will have `attrs="{'invisible':[('impressoall', '!=', True)]}"` or `attrs="{'invisible':[('impressoall', '=', False)]}"

__________

Yep, you're right! Forgot that you have to remove the `states="open,paid,proforma,proforma2"` part (wich will transform into an 'invisible' attrs) and join that in your attrs declaration. It should look something like

`attrs="{'invisible':['|', ('impressoall', '=', False), ('state', 'not in', ['open','paid','proforma','proforma2'])]}"`

2
Avatar
Descartar
Avatar
Francisco Castro
Autor Mejor respuesta

But How? I put ttrs="{'invisible':[('impressoall', '=', True)]}" and it dont work... strange

-----------------------------------------------------------------------------------------------------------------------------------

ok the problem was the state..... It force the buttons apear all the time...

I put the state inside the attrs thx by the way you help me too :)

0
Avatar
Descartar
Alcaline

how did you add the states inside the attrs??

Alcaline

how did you add the states inside the attrs??

Luis Filipe Castanheira

@alcalinelee, read the final paragraph of my answer above. The `states="some_state` part will be converted into an invisible attribute, so you have to remove it from your button definition and insert it into the attrs part.

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Odoo Sales
readonly
Avatar
Avatar
1
oct 24
7825
Make field readonly after save it and only user creator and administrator can edit it.
field readonly buttons OdooStudio
Avatar
Avatar
Avatar
Avatar
4
jun 24
4092
Custom stat button (eo_stat_button) for a custom field on a partner
buttons
Avatar
Avatar
Avatar
2
mar 23
11075
Cacher le bouton "créer" d'une liste Resuelto
buttons
Avatar
Avatar
2
mar 23
3198
Add class to button from function Resuelto
buttons
Avatar
Avatar
2
may 22
5419
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

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