Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • e-learning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Cervecería
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y soporte técnico
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Explorar todos los sectores
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Servicios para partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar 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
  • Proyecto
  • 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

How to use a button to show a form to edit data?

Suscribirse

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

Se marcó esta pregunta
treeviewformvieweventbuttoneditpopup
2 Respuestas
8515 Vistas
Avatar
Ratmil Torres

I have inserted a button as a cell in a tree view for my model. When the button is clicked it is suppose to pop up a form to edit the current record, the record is in the same row where the button is.

This is the code to handle the clicking of the button:

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

def open_details(self, cr, uid, ids, context=None):
        view = {
            'name': _('Details'),
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'my.model',
            'view_id': False,
            'type': 'ir.actions.act_window',
            'target': 'new',
            'readonly': True,
            'res_id': ids[0],
        }
        return view

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

It is not working. The form is shown but no data is loaded, and there isn´t either save or cancel button.

What is wrong in this code?

0
Avatar
Descartar
Avatar
Ben Olsen
Mejor respuesta

Hey Ratmil, looks like I wasn't careful enough when copy-and-pasting my previous answer. Note that one of the options in that view you're creating is:

'readonly': True,

Obviously if the form is readonly it won't have save/cancel buttons. Sorry about that.

As for the data not loading, the rest of it looks right to me. Maybe the "ids" arg isn't getting passed in? Right before the "view = {" line, I'd put in a "print(ids)" and check the output when you load that page. If "ids" isn't getting passed in correctly, that's definitely a problem. And are you sure you're replacing "my.model" with the actual model name that you want to edit? Let us know what the output of print(ids) is and maybe we can help from there.

0
Avatar
Descartar
Ratmil Torres
Autor

Hi, Ben. Thanks again for your response. I printed the ids var and I got [86]. In any case, a list with one item that is the id of record to edit. I set readonly to false ('readonly':False) and same result came out. Yes, by 'my.model' I mean the full name of my model. Actually I get the right form. The only problem is that field values are not loaded. And there are no save nor cancel button.

Ben Olsen

Well that's very curious. That is a good value for ids, so "'res_id': ids[0]" should work. I'm doing this exact thing in one of my modules and it works fine. Sorry I can't be more help.

Ratmil Torres
Autor

Hi, Ben. Well, I was defining my own view for editing the module. So, I removed this view definition and let OpenERP create the form view it self. And now data is loaded correctly. The only issue is that save button is not showing. Thank you very much for your help.

Ratmil Torres
Autor

Anyway, your solution is perfect, but I guess I just have a different problem in my code. Thanks again.

Avatar
Ratmil Torres
Autor Mejor respuesta

Hi, Ben.

It all works fine except for the missing "save" and "discard" buttons.

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

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

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
What event is triggered when a form view is shown? Resuelto
form view event init
Avatar
Avatar
Avatar
6
dic 22
10263
Detail Form View with SQL View Model Resuelto
form view button sql
Avatar
Avatar
2
jul 21
10700
Show model data in popup opened from button Resuelto
action treeview button popup
Avatar
Avatar
1
mar 20
14599
How to hide form Edit button depends on field value? Resuelto
form hide button edit
Avatar
Avatar
Avatar
Avatar
Avatar
4
dic 23
24213
Disable Create button in Tree view but keep Import
import treeview view tree button
Avatar
0
jul 25
12135
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información 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 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