Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

Update One2many field value without refreshing the page

Odebírat

Get notified when there's activity on this post

This question has been flagged
dataone2manysyncv17
1 Odpovědět
3293 Zobrazení
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
Zrušit
Avatar
Shajahan
Nejlepší odpověď

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
Zrušit
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

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
One2many Field Issue: Child Records Not Automatically Updating When Parent Field Changes Vyřešeno
one2many v17
Avatar
Avatar
Avatar
3
dub 25
1969
Equivalent Attributes in 17 for invisible
one2many v17
Avatar
Avatar
Avatar
2
bře 24
6397
Helpdesk Imports via API - Dates
import data api helpdesk v17
Avatar
0
říj 24
1671
How to Fill One2many field Vyřešeno
data one2many buttons transfer copy
Avatar
Avatar
Avatar
2
čvn 18
13413
How to add data for backtracking relationships
data many2one one2many backtracking relationship
Avatar
Avatar
1
bře 15
8284
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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