Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Reload or refresh the page/form on field change

Odoberať

Get notified when there's activity on this post

This question has been flagged
codeformrefreshreloadodoo16features
2 Replies
10558 Zobrazenia
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
Zrušiť
Avatar
Tran Van Minh
Best Answer
 bus_service.subscribe is not function. How to fix?
0
Avatar
Zrušiť
Avatar
odooUser
Best Answer

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
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
How to override FormController method?
form odoo16features
Avatar
Avatar
1
apr 24
3458
Button in all modules
form odoo16features
Avatar
Avatar
Avatar
3
jún 23
3267
odoo 16 method that can be overriden when a form opens
form view odoo16features
Avatar
Avatar
1
máj 24
2427
Send an email automatically
mail form odoo16features
Avatar
1
sep 23
3004
Reset some fields in a form to default value
form reset odoo16features
Avatar
Avatar
1
jún 23
4513
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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