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

Prevent tree view from sorting when clicking on headers (solved)

Odoberať

Get notified when there's activity on this post

This question has been flagged
sorttree_viewv15Javascript
3 Replies
3550 Zobrazenia
Avatar
Maximiliano Gamón

Update: Pushpendra solved it! Thanks an immense lot!! I would mark it as fixed or upvote but I can't because of karma. Thanks again! 

Hi! I'm new in the forums, this is my first post. I have been working as an Odoo technical developer for the last six months and it's a huge pleasure to be part of this awesome community. My name is Max, I'm from Argentina.

Right now I am trying to get a tree view (in Odoo 15) to stop sorting when its headers are clicked. So far I have tried this:



odoo.define('production_operator_missiongroup.custom_list_renderer', function (require) { "use strict";

console.log("Javascript works!")

var ListRenderer = require('web.ListRenderer');
var CustomListRenderer = ListRenderer.extend({
​ ​events: _.extend({}, ListRenderer.prototype.events, {
'click thead th.o_column_sortable': '_onSortColumn',
}),

_onSortColumn: function (ev) {
var viewId = 'production_operator_missiongroup.view_production_work_tree_operator';

if (this.state && this.state.id === viewId) {
ev.preventDefault();
​ ​ ​return false;
​}
return this._super.apply(this, arguments);
},
});
return CustomListRenderer;});

But that view is still getting sorted /sigh/. This .js file was successfully imported and that log is being logged. I would be veery grateful for some help with this, the Javascript framework is still a huge weak spot in my Odoo knowledge and can barely grasp it.

0
Avatar
Zrušiť
Avatar
Pushpendra
Best Answer

Hi Maximiliano Gamón,


Problem with your code is to check the viewID with the state id, List view renderer doesn't have viewID that you are expecting.


You can try these steps

1. Add a custom class in your tree view i.e. disable_sort

tree class="o_sale_order disable_sort" >

2. Override _onSortColumn function in list_renderer.js file like this


odoo.define('production_operator_missiongroup.custom_list_renderer', function (require) {

"use strict";

console.log("Javascript works!");

var ListRenderer = require('web.ListRenderer');
var CustomListRenderer = ListRenderer.include({

events: _.extend({}, ListRenderer.prototype.events, {
'click thead th.o_column_sortable': '_onSortColumn',
}),

_onSortColumn: function (ev) {
if (this.$el.hasClass('disable_sort')) {
ev.preventDefault();
return false;
}
return this._super.apply(this, arguments);
},
});

return CustomListRenderer;
});


I hope this solves your problem 😀.

3
Avatar
Zrušiť
Suryansh Pratap Singh

Thank You for your support

Avatar
Varun Singh
Best Answer

Thank You for your support Pushpendra

0
Avatar
Zrušiť
Avatar
Maximiliano Gamón
Autor Best Answer

Thanks a huge lot Pushpendra for your answer! 
I'm sorry to say it did not work, but I learned a lot from it.

I added the class, changed the _onSortColumn as you said, but nothing happened.

I added a console.log before the if just to see if it ever ran, and it is never logged. But the log at the start of the .js file is properly being logged, so it is being imported. 

Is it possible that _onSortColumn isn't what I should target? I've been checking out list_renderer.js and it would seem that it is. But I can barely understand. Luckily, I have permission to read the Javascript Framework at the Odoo docs, three full hours just to study. If you know of any other good source of knowledge on the topic, I would be really grateful too.

Updated .js file:

odoo.define('production_operator_missiongroup.custom_list_renderer', function (require) {    "use strict";

console.log("Javascript works!")

var ListRenderer = require('web.ListRenderer');
var CustomListRenderer = ListRenderer.extend({
​ ​events: _.extend({}, ListRenderer.prototype.events, {
'click thead th.o_column_sortable': '_onSortColumn',
}),

_onSortColumn: function (ev) {
​ ​ ​if (this.$el.hasClass('disable_sort')) {
ev.preventDefault();
​ ​ ​return false;
​}
return this._super.apply(this, arguments);
},
});
return CustomListRenderer;});

Updated tree view:


production.work.tree
production.work

​ ​class="disable_sort">
​ ​
​


0
Avatar
Zrušiť
Pushpendra


Hi Maximiliano Gamón,
There is an issue with your code, you are trying to extend the ListRenderer instead of extending you have to override the ListRenderer.
I have fixed your code JS code, check it and let me know if it is working

-----------------------------------------------------------------------------------------------------------
odoo.define('production_operator_missiongroup.custom_list_renderer', function (require) {

"use strict";

console.log("Javascript works!");

var ListRenderer = require('web.ListRenderer');
var CustomListRenderer = ListRenderer.include({

events: _.extend({}, ListRenderer.prototype.events, {
'click thead th.o_column_sortable': '_onSortColumn',
}),

_onSortColumn: function (ev) {
if (this.$el.hasClass('disable_sort')) {
ev.preventDefault();
return false;
}
return this._super.apply(this, arguments);
},
});

return CustomListRenderer;
});
-----------------------------------------------------------------------------------------------------------

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 get action id from javascript? (Odoo 15) Solved
v15 Javascript
Avatar
Avatar
2
apr 23
5161
how to get user object inside templates odoo 15
v15 Javascript
Avatar
Avatar
1
mar 22
2709
How to create Read Only tree view in odoo 15?
readonly tree_view v15
Avatar
Avatar
1
okt 22
9660
How to use AJAX request to update a field automatically in website form in Odoo15
ajax v15 Javascript
Avatar
0
júl 22
3704
How to inherit/override function in js odoo15 Solved
js v15 Javascript
Avatar
1
jún 22
7251
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