Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Consulting
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

How to call a specific view of Odoo from JS In the current Window

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
view_idodoo9
4 Replies
25473 Rodiniai
Portretas
ABISHEK

I want to CALL a specific TREE VIEW from JS, I have tried the following code, But is not working as expected


var model_obj = new instance.web.Model('ir.model.data');

var view_id = model_obj.call('get_object_reference',["MY MODULE NAME", "TREE VIEW ID"]);



var action = {
                                            type: 'ir.actions.act_window',
                                            res_model: 'crm.lead',
                                            view_mode: 'tree',
                                            view_type: 'tree',
                                            views:[[view_id, 'tree']],
                                            target: 'new',
                                            domain: [['state', '=', state]],
                                            context: context,
                                    };
                             
                                    action_manager = new ActionManager(self);
                                    action_manager.do_action(action);


1) The same works properly when the view_id is hard coded (Taken from ir.ui.view in DB)

2) I am not able to open this view in the current window but it works in new (Wizard) window that too after hard coding tree view ID else it brings the generic tree view for that model (In th wizard)

 

when I try to open the specific  tree view in the same window (ie) "target:current"this is what I get,


Uncaught TypeError: Cannot read property 'get_bus' of undefined

http://localhost:7000/web/content/743-605a4c6/web.assets_backend.js:3142 Traceback:
TypeError: Cannot read property 'get_bus' of undefined
    at Class.push_action (http://localhost:7000/web/content/743-605a4c6/web.assets_backend.js:3142:161)
    at http://localhost:7000/web/content/743-605a4c6/web.assets_backend.js:3175:170
    at http://localhost:7000/web/content/438-8117096/web.assets_common.js:650:681
    at fire (http://localhost:7000/web/content/438-8117096/web.assets_common.js:644:299)
    at Object.add [as done] (http://localhost:7000/web/content/438-8117096/web.assets_common.js:645:467)
    at Array.<anonymous> (http://localhost:7000/web/content/438-8117096/web.assets_common.js:650:649)
    at Function.each (http://localhost:7000/web/content/438-8117096/web.assets_common.js:473:767)
    at Object.<anonymous> (http://localhost:7000/web/content/438-8117096/web.assets_common.js:650:560)
    at Function.Deferred (http://localhost:7000/web/content/438-8117096/web.assets_common.js:651:194)
    at Object.then (http://localhost:7000/web/content/438-8117096/web.assets_common.js:650:525)


I want to open the specific tree view in the current window , If any one knows please share......

1
Portretas
Atmesti
Portretas
OnLabs Dev Team
Best Answer

Hi

i resume this post because i had the same problem.

I've solved with this code in javascript:

var model_obj = new instance.web.Model('ir.model.data');
var view_id = false;
model_obj.call('get_object_reference',['MODEL','VIEWNAME']).then( function(result){
    view_id = result[1];
});

this.do_action({
    views: [[view_id, 'form']],
....

i hope it can be helpful for others

Bye
Sandro

0
Portretas
Atmesti
Nguyen Phu Vuong

Hi OnLabs Dev Team,

i tried your code but i got error: "Uncaught ReferenceError: instance is not defined". I don't know why and can u give me an answer? Thank ! :D

Portretas
XOLUTO
Best Answer

this worked for me in Odoo 17 =>

First the snippet from owl component (model in my case) that triggers the action to show the view

showView() {

​self = this.action; // has to be set in constructor

        self.rpc("/web/action/load", 

​ ​{ action_id: "my_module.my_action_id" })            

​ ​.then(function (result) {                

​ ​ ​const treeView = result.views.find((v) => v[1] === "list");

                ​ ​// Open view   with owl action service

             ​ ​self.action.doAction({                    

​ ​ ​ ​name: 'Standards des Partners',                    

​ ​ ​ ​type: 'ir.actions.act_window',                    

​ ​ ​ ​res_model: 'my_module.my_model', 

​ ​                  target: 'new',                    

​ ​ ​ ​domain: domain,                    

​ ​ ​ ​views: [[treeView[0], 'tree']], view id                

​ ​ ​});            

​ ​}).catch(function (error) { 

​ ​ ​console.log(error);                

​ ​ ​throw error;           

​ ​ });

Second the initialization of services used:

const myDashBoardService = {    

​dependencies: ["action", "effect", "notification", "orm", "rpc"],

    ​start(env, services) {        

​ ​const dashboardModel = new myDashboardModel(

​ ​ ​services["orm"], services["rpc"], services["action"]

​ ​);

        return dashboardModel;    }

};


registry.category("services").add("my_dashboard.service", myDashBoardService);

0
Portretas
Atmesti
Portretas
Alaa
Best Answer

Hello brother! I have tried your solution but I'm getting this error: 

Uncaught TypeError: self._rpc is not a function

0
Portretas
Atmesti
Portretas
Miguel Da Silva
Best Answer

This is the updated solution for version 14: 
Found these under the Odoo source code.

self._rpc({
    // Get view id
model:'ir.model.data',
method:'xmlid_to_res_model_res_id',
args: ['module_name.view_id'], // View id goes here
}).then(function(data){
    // Open view
    self.do_action({
    name: 'Example',
type: 'ir.actions.act_window',
res_model: 'your.module', // Module name goes here
target: 'new',
views: [[data[1], 'form']], // data[1] variable contains the view id
    });
});
0
Portretas
Atmesti
Enjoying the discussion? Don't just read, join in!

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

Registracija
Related Posts Replies Rodiniai Veikla
How to get data n view using custom widget in odoo 9
odoo9
Portretas
0
rugs. 23
2673
How to get data n view using custom widget in odoo 9
odoo9
Portretas
0
rugs. 23
2366
How to Remove " ADD NEW COLUMN " from task kanban view of Project Module? Solved
odoo9
Portretas
Portretas
Portretas
2
birž. 25
11978
How to edit the product website description Solved
odoo9
Portretas
Portretas
Portretas
Portretas
Portretas
6
spal. 23
23162
How can I restrict (deny) product creation for some users? Solved
odoo9
Portretas
Portretas
Portretas
Portretas
3
kov. 24
10322
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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