Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Producție
    • Textile
    • Metal
    • Furnitures
    • Food
    • 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
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

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

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
view_idodoo9
4 Răspunsuri
25491 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Imagine profil
OnLabs Dev Team
Cel mai bun răspuns

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
Imagine profil
Abandonează
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

Imagine profil
XOLUTO
Cel mai bun răspuns

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
Imagine profil
Abandonează
Imagine profil
Alaa
Cel mai bun răspuns

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

Uncaught TypeError: self._rpc is not a function

0
Imagine profil
Abandonează
Imagine profil
Miguel Da Silva
Cel mai bun răspuns

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
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
How to get data n view using custom widget in odoo 9
odoo9
Imagine profil
0
sept. 23
2681
How to get data n view using custom widget in odoo 9
odoo9
Imagine profil
0
sept. 23
2369
How to Remove " ADD NEW COLUMN " from task kanban view of Project Module? Rezolvat
odoo9
Imagine profil
Imagine profil
Imagine profil
2
iun. 25
11984
How to edit the product website description Rezolvat
odoo9
Imagine profil
Imagine profil
Imagine profil
Imagine profil
Imagine profil
6
oct. 23
23179
How can I restrict (deny) product creation for some users? Rezolvat
odoo9
Imagine profil
Imagine profil
Imagine profil
Imagine profil
3
mar. 24
10329
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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