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

[v10] Pass active_id through button to fill fields

Suscribirse

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

Se marcó esta pregunta
actionmany2onebuttonautocompleteactive_id
9 Respuestas
10417 Vistas
Avatar
Bastien Bascou

Hello !

I get troubles to fill fields of my model opened in edit form view.

Here are some screens of the usecase :

http://imgur.com/G1ptWXN

http://imgur.com/lWrrDRj

http://imgur.com/1FvI25l

In the URL, I can see the active_id (or active_ids) of my products on the second screenshot. But my trouble is in filling the field Article with them (WITHOUT saving it : I want the user to choose to save or not)

Here is the code of my "new" button action right now :


def new_match(self):
    return{
        'name':("Save a new matching"),
        'view_mode': 'form',
        'view_type': 'form',
        'view_id': False,
        'res_model': 'label.label',
        'res_id': self.id,
        'type': 'ir.actions.act_window',
        'target': 'current',
        'domain': '[]',
        'flags': {'initial_mode': 'edit',} ,
        '_default':{'products':[(6,0,[self._context.get('active_ids')])]},
  }

I tried a lot of stuff that didn't work, without giving me any error or stuff. I'm a bit lost here

If someone could give me solution or part of it that'd be great ! :)

Thanks !

0
Avatar
Descartar
Bastien Bascou
Autor

The code of my list view :

<record model="ir.ui.view" id="label.tree_new_match">

<field name="name">Create Matching</field>

<field name="model">label.label</field>

<field name="view_type">form</field>

<field name="view_mode">tree</field>

<field name="arch" type="xml">

<tree colors="red:status=='OFFLINE';black:len(products)!=0;green:len(products)==0" default_order='len_products, real_id' create='false' delete='false'>

<button string="New" type="object" name="new_match"/>

<field name="description" string="Name"/>

<field name="real_id"/>

<field name="type"/>

<field name="products"/>

<field name="status"/>

<field name="len_products" invisible="context.get('len_products')!=1000"/>

</tree>

</field>

</record>

Avatar
Bastien Bascou
Autor Mejor respuesta

The only way i found to do this was to set the fields direclty in the action function, but that doesn't do what i wanted to do at first :'(

0
Avatar
Descartar
Avatar
Keyur Gajjar (kga)
Mejor respuesta

Hello Bastein,

You need to pass the context here instead of '_default':

    e.g. 'context': {},

And in context you need to pass fields which you want to set defaults with 'default_' prefix.

in your case its like 

    'context': {'default_partners': [(6,0, active_ids)]}, 

0
Avatar
Descartar
Bastien Bascou
Autor

Hi ! Thank you for the answer

I got the error : NameError: global name 'active_id' is not defined

when I put it between '' no mistakes but doesn't work.

Keyur Gajjar (kga)

sorry, my bad. Try using self.env.context.get('active_ids') instead of active_ids.

Bastien Bascou
Autor

Still doesn't work, i tried with self._context.get('active_ids') as well,replacing active_ids by active_id etc ...

Do I need to pass values trough context of my tree view ?

Keyur Gajjar (kga)

Yeah you need to pass that active_id in the context when clicking on the action in 'More' dropdown. which will be propagated to the "New" button action's context.

Bastien Bascou
Autor

Is it automatically propagated ? because as i said in my original post, in the url the active_id on my second screenshot is the products i want to match with my label, but in the third screenshot the active_id is the label itself. so i'm scared that i can't use the active_id of the product anymore at this point.

Bastien Bascou
Autor

Ok got some news :

def new_match(self):

context=self._context.copy()

if context.get('active_ids'):

context.update(default_products=[(6,0,context.get('active_ids'))])

else:

context.update(default_products=[(6,0,context.get('active_id'))])

return {

'name':_("Save a new matching"),

'view_mode': 'form',

'view_type': 'form',

'view_id': False,

'res_model': 'label.label',

'res_id': self.id,

'type': 'ir.actions.act_window',

'target': 'current',

'domain': '[]',

'context': context,

'flags': {'initial_mode': 'edit',},

}

with this action button, I manage to get the active_ids of my products in the 3rd screenshot. But still nothing filled where it should be. :)

Thank you again !

¿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
Active id Bug in odoo v15
action active_id
Avatar
0
may 22
3154
action button is disabled in the list view Resuelto
action button
Avatar
1
mar 21
5599
How set STATE=DONE? (Action & Button)
action button
Avatar
Avatar
Avatar
3
mar 15
11206
How to change string of the button without altering its action
action button string
Avatar
Avatar
Avatar
2
feb 23
4360
Custom back button no longer working. Resuelto
action button customization
Avatar
2
oct 20
6791
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 empresariales de código abierto que cubre 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