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

how open custom type view from kanban and tree when click on record?

Suscribirse

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

Se marcó esta pregunta
actiontreeviewxmlkanbanodoo12
8 Respuestas
13371 Vistas
Avatar
Mark Okolov

hi all

a created a custom type view, for example 'form2'

created action when i add this type view without 'form'

in this case when click on any record do nothing

if add 'form' type into action, opening record in form view

how i can open my custom type view 'form2' from tree or kanban when i click on any record?

1
Avatar
Descartar
Avatar
Ravi Gadhia
Mejor respuesta

when you click on the list view record it triggers up 'open_record' and it bubbles up to an abstract controller.
it always open default from view as it's hardcoded. 
https://github.com/odoo/odoo/blob/12.0/addons/web/static/src/js/views/abstract_controller.js#L460
override you _onOpenRecord controller and switch to your view from(2)
and same for the kanban record

2
Avatar
Descartar
Mark Okolov
Autor

i created new file and included AbstractController, when check if in context available view_type:

src/custom_module/static/src/js/abstract_controller.js

odoo.define('custom_module.AbstractController', function (require) {

"use strict";

var AbstractController = require('web.AbstractController');

AbstractController.include({

_onOpenRecord: function (event, params) {

event.stopPropagation();

var record = this.model.get(event.data.id, {raw: true});

var view_type = 'form'

if (this.initialState.context.view_type) {

view_type = this.initialState.context.view_type

}

this.trigger_up('switch_view', {

view_type: view_type,

res_id: record.res_id,

mode: event.data.mode || 'readonly',

model: this.modelName,

});

},

});

});

and add context in my action when i need other type view instead form

src/custom_module/views/model_views.xml

<record id="action_view_id" model="ir.actions.act_window">

<field name="name">any name</field>

<field name="res_model">model</field>

<field name="context">{'view_type': 'form2'}</field>

<field name="view_ids"

eval="[(5, 0, 0),

(0, 0, {'view_mode': 'kanban'}),

(0, 0, {'view_mode': 'tree'}),

(0, 0, {'view_mode': 'form2', 'view_id': ref('custom_view_id_form2')}),

(0, 0, {'view_mode': 'calendar'}),

(0, 0, {'view_mode': 'pivot'}),

(0, 0, {'view_mode': 'graph'}),

(0, 0, {'view_mode': 'activity'})]"/>

</record>

and added a new js file to assets.xml

Avatar
Jake Robinson
Mejor respuesta

Hi Mark,

In the action, rather than just defining the view_mode, you should define view_ids. This allows you to specify the view to be used for each mode if you wish. Some can be defined while others can be blank, which will use the default.

<record id="action_res_company" model="ir.actions.act_window">
<field name="name">Company Test</field>
<field name="res_model">res.company</field>
<field name="view_mode">tree,form</field>
<field name="view_ids" eval="[(5, 0, 0),
(0, 0, {'view_mode': 'tree'}),
(0, 0, {'view_mode': 'form', 'view_id': ref('test.res_company_form2_view')})]"/>
</record>

Cheers
Jake Robinson

2
Avatar
Descartar
Mark Okolov
Autor

hi Jake, my view has type 'form2':

(0, 0, {'view_mode': 'form2', 'view_id': ref('test.res_company_form2_view')})]

if write

[(5, 0, 0),

(0, 0, {'view_mode': 'tree'}),

(0, 0, {'view_mode': 'form2', 'view_id': ref('test.res_company_form2_view')})]

from tree when click on any record - do nothing

Jake Robinson

Is there a reason for this? I don't think form2 is a valid view mode and I've never seen it used before. Have you tried changing it just to form?

Mark Okolov
Autor

i using created custom type view because the customer does not fit the current version form, it has other styles and there are no buttons to create and edit, if open this new custom form from any button that calling view, all correct working, but i need also open form2 from kanban and tree

Mark Okolov
Autor

By the way, in your version you can not write this line

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

because the next line

(5, 0, 0)

will delete all values ​​anyway

Jake Robinson

Sorry, I thought you meant you have just created a new view, I didn't realised you'd created a new type. You'll need to dig around the javascript, it will explicitly call the form view mode on click.

From a quick glance, clicking a kanban calls trigger_up('openRecord') which I think ends up calling odoo/addons/web/static/src/js/views/abstract_controller.js _onOpenRecord() but I can't be sure.

These are two separate fields and conventionally Odoo always defines both.

Mark Okolov
Autor

okay, thank you, I dig in there in the morning.

i testing this with and without <field name="view_mode">tree,form</field>, and both variants are working.

if i correct understood this line are equal to

<field name="view_ids" eval="[(0, 0, {'view_mode': 'tree'}),

(0, 0, {'view_mode': 'form'})"/>

¿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
how to make kanban view display no record until the user search ?
action views action.rule kanban odoo12
Avatar
0
jun 20
3656
how to get current value of a record line in a XML tree view
action module treeview xml odoov11
Avatar
1
oct 18
8609
Element cannot be located in parent view
xml odoo12
Avatar
0
feb 22
2540
Odoo 12 Action Menu
action odoo12
Avatar
Avatar
1
oct 19
6783
AssertionError: Element data has extra content: record, line 3 Resuelto
xml odoo12
Avatar
Avatar
Avatar
6
ago 19
11162
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