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
    • eLearning
    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 taberna
    • 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
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • 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
    Browse all Industries
  • 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
    • Services for 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

Reload or refresh the page/form on field change

Suscribirse

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

Se marcó esta pregunta
codeformrefreshreloadodoo16features
2 Respuestas
10533 Vistas
Avatar
Paolo Franchi

Hello, I am working with Odoo 16, and I was wondering if there is a way to update the entire web page, or to reload just the form view, when a field in the form changes (in my specific case, a Many2one field called "bank").

I'm asking this because I have a "documents" One2many field, in the same form where "bank" is, that automatically updates when "bank" changes.
In the Python method, decorated with @api.onchange('bank'), there are instructions that create documents in the database based on the selected bank.
The issue is that if I change "bank", after manually adding a document, the new documents created by the function are not displayed until I save the form or reload the page.


I tried using JavaScript, writing the following snippet:

odoo.define('my_crm.reload_on_bank_change', function (require) {
"use strict";

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

FormController.include({
_onFieldChanged: function (record, changes) {
if ('bank' in changes) {
// Reload the page if the "bank" field has changed
location.reload(true);
}
},
});
});

And also Python, using @api.onchange('bank') on my method and making it return the following:

return {
    'type': 'ir.actions.client',
    'tag': 'reload',
}


I have searched everywhere online and in the documentation, but I haven't been able to find a solution, and unfortunately, the above methods didn't work.
Thanks to anyone who will answer.

0
Avatar
Descartar
Avatar
Tran Van Minh
Mejor respuesta
 bus_service.subscribe is not function. How to fix?
0
Avatar
Descartar
Avatar
odooUser
Mejor respuesta

try this
at the end of python method:

self.env['bus.bus']._sendone(self.create_uid.partner_id, 'page_refresh', {
'type': response_type,
'title': "Reload",
'message': _(response_message),
'sticky': True,
'model_name': self._name,
'rec_id': self.id
})

in js:

=/* @odoo-module */

import { registry } from "@web/core/registry";
import { browser } from "@web/core/browser/browser";

export const simplePageRefresh = {
dependencies: ["bus_service", "notification"],
start(env, { bus_service, notification: notificationService }) {
bus_service.subscribe("page_refresh", ({ message, sticky, title, type, model_name, rec_id }) => {

if (`${browser.location}`.includes(`id=${rec_id}`) && `${browser.location}`.includes(`model=${model_name}`)) {
browser.location.reload();
} else {
console.log('cant locate correct page');
}

notificationService.add(message, { sticky, title, type });
});
bus_service.start();
},
};

registry.category("services").add("refresh_page", simplePageRefresh);


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
How to override FormController method?
form odoo16features
Avatar
Avatar
1
abr 24
3456
Button in all modules
form odoo16features
Avatar
Avatar
Avatar
3
jun 23
3262
odoo 16 method that can be overriden when a form opens
form view odoo16features
Avatar
Avatar
1
may 24
2422
Send an email automatically
mail form odoo16features
Avatar
1
sept 23
3002
Reset some fields in a form to default value
form reset odoo16features
Avatar
Avatar
1
jun 23
4509
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