Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Extending the Class in the web gantt

Subscriure's

Get notified when there's activity on this post

This question has been flagged
jsganttprototypeodoo8.0
1 Respondre
5717 Vistes
Avatar
napster

please find the code that i edited as marked as mycode ..Is this there is any other way to do this

openerp.gantt_view_custom = function(instance){
instance.gantt_view_custom = {};
var module = instance.web_gantt;
var _super_ = module.GanttTask.prototype.create;
gantt_view_custom.GanttTask.prototype.create = function(){ console.log('Hello!');
_super_.call(this);
};
}

console.log("this yyyyyyyy creae")
var containerTasks = this.Chart.oData.firstChild;
var containerNames = null;
if (this.Chart._showTreePanel) containerNames = this.Chart.panelNames.firstChild;
var predecessorTask = this.TaskInfo.PredecessorTask;
var parentTask = this.TaskInfo.ParentTask;
var isCParentTask = (this.TaskInfo.ChildTasks.length > 0);
var self = this;
this.cTaskItem = [];
this.cTaskNameItem = [];
//creation arrTasks if (!parentTask) { if (this.TaskInfo.previousParentTask) { this.previousParentTask = this.Project.getTaskById(this.TaskInfo.previousParentTask.Id);
var lastChildTask = this.Chart.getLastChildTask(this.previousParentTask);

// ######################## My code
// for moving the workorder bar to the manufactoring order
this.posY = this.Project.posY;
// #########################################
// this.posY = parseInt(lastChildTask.cTaskItem[0].style.top) + this.Chart.heightTaskItem + 11;
this.previousParentTask.nextParentTask = this;
} else {
// ######################## My code
// for moving the workorder bar to the manufactoring order
this.posY = this.Project.posY;
// #########################################
// this.posY = parseInt(this.Project.projectItem[0].style.top) + this.Chart.heightTaskItem + 11;
} }
if (parentTask) { var task = this.Project.getTaskById(this.TaskInfo.ParentTask.Id);
this.parentTask = task;
if (this.TaskInfo.previousChildTask) { this.previousChildTask = this.Project.getTaskById(this.TaskInfo.previousChildTask.Id);
var lastChildTask = this.Chart.getLastChildTask(this.previousChildTask);
this.posY = parseInt(lastChildTask.cTaskItem[0].style.top) + this.Chart.heightTaskItem + 11;
this.previousChildTask.nextChildTask = this;
} else { this.posY = parseInt(task.cTaskItem[0].style.top) + this.Chart.heightTaskItem + 11;
} task.childTask.push(this);
}
if (predecessorTask) { var task = this.Project.getTaskById(predecessorTask.Id);
this.predTask = task;
task.childPredTask.push(this);
}
//creation task item this.cTaskItem.push(this.createTaskItem());
containerTasks.appendChild(this.cTaskItem[0]);
if (this.Chart.panelNames) { this.cTaskNameItem.push(this.createTaskNameItem(isCParentTask));
this.Chart.panelNames.firstChild.appendChild(this.cTaskNameItem[0]);
}
if (this.Chart.isShowDescTask) { containerTasks.appendChild(this.createTaskDescItem());
}
//Create Connecting Lines var arrConnectingLines = [];
if (predecessorTask) arrConnectingLines = this.createConnectingLinesDS();
this.cTaskItem.push(arrConnectingLines);
if (this.Chart.panelNames) { //Create Connecting Lines var arrConnectingLinesNames = [];
if (parentTask) { this.cTaskNameItem[0].style.left = parseInt(this.parentTask.cTaskNameItem[0].style.left) + 15 + "px";
arrConnectingLinesNames = this.createConnectingLinesPN();
} this.checkWidthTaskNameItem();
var treeImg = null;
if (isCParentTask) treeImg = this.createTreeImg();
this.cTaskNameItem.push(arrConnectingLinesNames);
this.cTaskNameItem.push(treeImg);
} this.addDayInPanelTime();
// console.log("thissssssssssdddddddddddddssssssss",this) console.log("thissssssssssdddddddddddddssssssss",this.Project.posY)// console.log("thissssssssssdddddddddddddssssssss",this.posY)// this.posY = this.Project.posY// console.log("thissssssssssdddddddddddddssssssss",this.posY)//
// ######################## My code
if (this.Chart.Project){ var project_obj = this.Chart.Project;
} for (var key in project_obj) { if (project_obj.hasOwnProperty(key)) { console.log(key + " -> " , project_obj[key]['Id']);
var id_project = project_obj[key]['Id'] $("#"+id_project.toString()).css("display", "None");
} } $(".taskNameItem").css("display", "None"); //hiding the workorder// my code return this;

};

0
Avatar
Descartar
Avatar
Axel Mendoza
Best Answer

In odoo js framework you could change any widget class by using mostly 2 ways.

1- Using include function that it will change the properties(functions included) original class widget prototype

2- Using extend function that it will return a copy of the changes to the properties(functions included) original class widget prototype

In both cases you always will be able to access the overrides functions in the new ones using this.super or this._super (in newer versions) depending on the Odoo version. You could call it passing the same parameters received or just call it as using js prototype function apply to call it with arguments like:

 this._super.apply(this, arguments);

That is for example the case when you need to change a function like in your case but still need to call the original one and you could do it using the super call.

For the non widget classes created using js prototype like the case of GanttTask you could do what you are doing copying the original function to call it when you need to and just replace the original function in the class protoype but you need to put all your code inside the js odoo module like:

openerp.gantt_view_custom = function(instance){
    instance.gantt_view_custom = {};
    var module = instance.web_gantt;
    var _super_ = GanttTask.prototype.create;
    
    GanttTask.prototype.create = function(){
        var containerTasks = this.Chart.oData.firstChild;
        var containerNames = null;
        if (this.Chart._showTreePanel) containerNames = this.Chart.panelNames.firstChild;
        var predecessorTask = this.TaskInfo.PredecessorTask;
        var parentTask = this.TaskInfo.ParentTask;
        var isCParentTask = (this.TaskInfo.ChildTasks.length > 0);
        var self = this;
        
        this.cTaskItem = [];
        this.cTaskNameItem = [];
        
        //creation arrTasks
        if (!parentTask) {
            if (this.TaskInfo.previousParentTask) {
                this.previousParentTask = this.Project.getTaskById(this.TaskInfo.previousParentTask.Id);
                var lastChildTask = this.Chart.getLastChildTask(this.previousParentTask);
                this.posY = this.Project.posY;
                this.previousParentTask.nextParentTask = this;
            
            } else {
                this.posY = this.Project.posY;
            }
        }
        
        if (parentTask) {
            var task = this.Project.getTaskById(this.TaskInfo.ParentTask.Id);
            this.parentTask = task;
            
            if (this.TaskInfo.previousChildTask) {
                this.previousChildTask = this.Project.getTaskById(this.TaskInfo.previousChildTask.Id);
                var lastChildTask = this.Chart.getLastChildTask(this.previousChildTask);
                this.posY = parseInt(lastChildTask.cTaskItem[0].style.top) + this.Chart.heightTaskItem + 11;
                this.previousChildTask.nextChildTask = this;
            
            } else {
                this.posY = parseInt(task.cTaskItem[0].style.top) + this.Chart.heightTaskItem + 11;
            }
            task.childTask.push(this);
        }
        
        if (predecessorTask) {
            var task = this.Project.getTaskById(predecessorTask.Id);
            this.predTask = task;
            task.childPredTask.push(this);
        }
        
        //creation task item
        this.cTaskItem.push(this.createTaskItem());
        containerTasks.appendChild(this.cTaskItem[0]);
        
        if (this.Chart.panelNames) {
            this.cTaskNameItem.push(this.createTaskNameItem(isCParentTask));
            this.Chart.panelNames.firstChild.appendChild(this.cTaskNameItem[0]);
        }
        
        if (this.Chart.isShowDescTask) {
            containerTasks.appendChild(this.createTaskDescItem());
        }
        
        //Create Connecting Lines
        var arrConnectingLines = [];
        if (predecessorTask) arrConnectingLines = this.createConnectingLinesDS();
        this.cTaskItem.push(arrConnectingLines);
        
        if (this.Chart.panelNames) {
            //Create Connecting Lines
            var arrConnectingLinesNames = [];
            if (parentTask) {
                this.cTaskNameItem[0].style.left = parseInt(this.parentTask.cTaskNameItem[0].style.left) + 15 + "px";
                arrConnectingLinesNames = this.createConnectingLinesPN();
            }
            this.checkWidthTaskNameItem();
            
            var treeImg = null;
            if (isCParentTask) treeImg = this.createTreeImg();
            
            this.cTaskNameItem.push(arrConnectingLinesNames);
            this.cTaskNameItem.push(treeImg);
        }
        this.addDayInPanelTime();
        //    console.log("thissssssssssdddddddddddddssssssss",this)
        console.log("thissssssssssdddddddddddddssssssss",this.Project.posY)
        //    console.log("thissssssssssdddddddddddddssssssss",this.posY)
        //    this.posY = this.Project.posY
        //    console.log("thissssssssssdddddddddddddssssssss",this.posY)
        //    
        // ########################   My code
        if (this.Chart.Project){
            var project_obj = this.Chart.Project;
        }
        for (var key in project_obj) {
            if (project_obj.hasOwnProperty(key)) {
                console.log(key + " -> " , project_obj[key]['Id']);
                var id_project = project_obj[key]['Id']
                $("#"+id_project.toString()).css("display", "None");
            }
        }
        $(".taskNameItem").css("display", "None");
        //hiding the workorder
        // my code
        return this;
    }
});

Hope this helps

1
Avatar
Descartar
napster
Autor

Thank you It worked..!!!

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

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

Registrar-se
Related Posts Respostes Vistes Activitat
How to create a widget to render image in form view?
js odoo8.0
Avatar
0
de des. 15
5193
[Solved] [odoo8:JS]: Can we update value of that record which is being clicked from tree view?
web js odoo8.0
Avatar
Avatar
Avatar
3
de des. 17
6303
How to display alert on button onclick JS in odoo 8?
xml js python2.7 odooV8 odoo8.0
Avatar
Avatar
2
d’ag. 20
9497
how to implement joint piece in odoo 8 in one view
odoo8.0
Avatar
0
d’abr. 24
2662
what is the reason behind extra move? in stock
odoo8.0
Avatar
Avatar
Avatar
Avatar
4
de nov. 23
6861
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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