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

Update One2many field value without refreshing the page

Suscribirse

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

Se marcó esta pregunta
dataone2manysyncv17
1 Responder
3288 Vistas
Avatar
Daryl Chen

Hi Community,


I am working with Odoo 17, and I am wondering if there is a way to update the value in One2many without refreshing the page. For example, I have a One2many field in stock.picking related to the account.payment model. After manually creating the payment from the payment side, I would like to see the One2many field in another tab to have the payment information without refreshing the page.


Thank you 

0
Avatar
Descartar
Avatar
Shajahan
Mejor respuesta

In Odoo, updating the value of a One2many field without refreshing the page typically involves using client-side actions with JavaScript. Here's an approach you can take to achieve this functionality:

  1. Create a Server-Side Method: Define a server-side method that will update the One2many field with the payment information. This method will be called from the client-side.
  2. Update the One2many Field: Implement the logic in the server-side method to update the One2many field with the payment information.
  3. Call the Server-Side Method from the Client-Side: Trigger the server-side method using JavaScript when the payment is created. This can be done by sending an RPC (Remote Procedure Call) request to the server.
  4. Update the View: Once the server-side method has updated the One2many field, update the view on the client-side to reflect the changes without refreshing the page.

Here's an example implementation:

from odoo import models, api

class StockPicking(models.Model):
    _inherit = 'stock.picking'

    @api.model
    def update_payment_information(self, picking_id, payment_data):
        picking = self.browse(picking_id)
        picking.write({
            'account_payment_ids': [(0, 0, payment_data)]  # Update One2many field
        })

In your JavaScript file or XML template, you can call this server-side method using Odoo's JavaScript framework:

 odoo.define('your_module_name.payment_update', function (require) {
    "use strict";

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

    function updatePaymentInformation(picking_id, payment_data) {
        rpc.query({
            model: 'stock.picking',
            method: 'update_payment_information',
            args: [picking_id, payment_data],
        }).then(function () {
            // Update the view here if necessary
            // For example, refresh the One2many field
        });
    }

    // Call this function when payment is created
    // Pass picking_id and payment_data as arguments
    // For example:
    // updatePaymentInformation(picking_id, payment_data);

});

This script should be triggered when the payment is created. It will then call the server-side method update_payment_information, which updates the One2many field in the stock.picking model with the payment information. Finally, the view is updated to reflect the changes without refreshing the page.

0
Avatar
Descartar
Daryl Chen
Autor

Hi Shajahan,

Thank you so much for your reply.
May I ask how are you triggering the JS method, and what function can be used to refresh the One2many field?

I was trying to use this.props.record.load(), but it only works with the X2ManyField object. However, I cannot find this object anywhere in the Form Controller.

Nevertheless, One2many is not the only field that I want to refresh, I have a couple of fields that need to be refreshed like the state and payment widget info.

The result that I want to achieve is after I create the transfer, I stay in that tab. From another device, I will create the payment linking with that transfer. At this moment, the system will send a notification on all tabs(achieved) and the client side data of payment_ids(One2many), state(Selection) and the payment widget(JSON) should all be reloaded and align with the backend data.

Please let me know your thoughts.
Thank you

¿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
One2many Field Issue: Child Records Not Automatically Updating When Parent Field Changes Resuelto
one2many v17
Avatar
Avatar
Avatar
3
abr 25
1966
Equivalent Attributes in 17 for invisible
one2many v17
Avatar
Avatar
Avatar
2
mar 24
6385
Helpdesk Imports via API - Dates
import data api helpdesk v17
Avatar
0
oct 24
1665
How to Fill One2many field Resuelto
data one2many buttons transfer copy
Avatar
Avatar
Avatar
2
jun 18
13412
How to add data for backtracking relationships
data many2one one2many backtracking relationship
Avatar
Avatar
1
mar 15
8282
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.

Sitio web hecho con

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