Pular para o conteúdo
Odoo Menu
  • Entrar
  • Experimente grátis
  • Aplicativos
    Finanças
    • Financeiro
    • Faturamento
    • Despesas
    • Planilhas (BI)
    • Documentos
    • Assinar Documentos
    Vendas
    • CRM
    • Vendas
    • PDV Loja
    • PDV Restaurantes
    • Assinaturas
    • Locação
    Websites
    • Criador de Sites
    • e-Commerce
    • Blog
    • Fórum
    • Chat ao Vivo
    • e-Learning
    Cadeia de mantimentos
    • Inventário
    • Fabricação
    • PLM - Ciclo de Vida do Produto
    • Compras
    • Manutenção
    • Qualidade
    Recursos Humanos
    • Funcionários
    • Recrutamento
    • Folgas
    • Avaliações
    • Indicações
    • Frota
    Marketing
    • Redes Sociais
    • Marketing por E-mail
    • Marketing por SMS
    • Eventos
    • Automação de Marketing
    • Pesquisas
    Serviços
    • Projeto
    • Planilhas de Horas
    • Serviço de Campo
    • Central de Ajuda
    • Planejamento
    • Compromissos
    Produtividade
    • Mensagens
    • Aprovações
    • Internet das Coisas
    • VoIP
    • Conhecimento
    • WhatsApp
    Aplicativos de terceiros Odoo Studio Plataforma Odoo Cloud
  • Setores
    Varejo
    • Loja de livros
    • Loja de roupas
    • Loja de móveis
    • Mercearia
    • Loja de ferramentas
    • Loja de brinquedos
    Comida e hospitalidade
    • Bar e Pub
    • Restaurante
    • Fast Food
    • Hospedagem
    • Distribuidor de bebidas
    • Hotel
    Imóveis
    • Imobiliária
    • Escritório de arquitetura
    • Construção
    • Administração de propriedades
    • Jardinagem
    • Associação de proprietários de imóveis
    Consultoria
    • Escritório de Contabilidade
    • Parceiro Odoo
    • Agência de marketing
    • Escritório de advocacia
    • Aquisição de talentos
    • Auditoria e Certificação
    Fabricação
    • Têxtil
    • Metal
    • Móveis
    • Alimentação
    • Cervejaria
    • Presentes corporativos
    Saúde e Boa forma
    • Clube esportivo
    • Loja de óculos
    • Academia
    • Profissionais de bem-estar
    • Farmácia
    • Salão de cabeleireiro
    Comércio
    • Handyman
    • Hardware e Suporte de TI
    • Sistemas de energia solar
    • Sapataria
    • Serviços de limpeza
    • Serviços de climatização
    Outros
    • Organização sem fins lucrativos
    • Agência Ambiental
    • Aluguel de outdoors
    • Fotografia
    • Aluguel de bicicletas
    • Revendedor de software
    Navegar por todos os setores
  • Comunidade
    Aprenda
    • Tutoriais
    • Documentação
    • Certificações
    • Treinamento
    • Blog
    • Podcast
    Empodere a Educação
    • Programa de educação
    • Scale Up! Jogo de Negócios
    • Visite a Odoo
    Obtenha o Software
    • Baixar
    • Comparar edições
    • Releases
    Colaborar
    • Github
    • Fórum
    • Eventos
    • Traduções
    • Torne-se um parceiro
    • Serviços para parceiros
    • Cadastre seu escritório contábil
    Obtenha os serviços
    • Encontre um parceiro
    • Encontre um Contador
    • Conheça um consultor
    • Serviços de Implementação
    • Referências de Clientes
    • Suporte
    • Upgrades
    Github YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Faça uma demonstração
  • Preços
  • Ajuda

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

  • CRM
  • e-Commerce
  • Financeiro
  • Inventário
  • PoS
  • Projeto
  • MRP
All apps
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
Ajuda

Override Many2ManyListView under web.form_relational !!

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
widgetjs
1 Responder
4922 Visualizações
Avatar
Pawan

Hello guys,

I have a requirement in which i have to override Many2ManyListView class from "web/static/src/js/views/form_relational_widget.js" under "web.form_relational"

But as web.form_relational does not return 'Many2ManyListView'(so i can't use '.' notation to access) nor its adding it in form_registery(to access it from registery), i am not getting the correct  way to override 'Many2ManyListView'


Any help would be appreciated...


Thanks!

0
Avatar
Cancelar
Avatar
Axel Mendoza
Melhor resposta

*** update that works directly without more investigation, i will left the original answer as a reference ***

Odoo class/widget functions extend and include have something in common. That is that both functions apply the received javascript object properties to the class/widget. The difference between those Odoo class/widget functions is that the extend function is used to get a copy of the Odoo class/widget with the modifications without been modify the original class/widget by returning the modifications in a new class/widget. The include function will do the modifications in place to the class/widget without returning anything new.

To reach the class/widget Many2ManyListView for been able to use extend or include functions the best way is using the following code:

var core = require('web.core');

var FieldMany2Many = core.form_widget_registry.get('many2many')

var extention_not_done = false;

FieldMany2Many.include({

init: function() {

this._super.apply(this, arguments);

//if(extention_not_done){

     if(!extention_not_done){

var Many2ManyListView = this.x2many_views.list;

// use include to modify the original

Many2ManyListView.include({

});

// or use extend to create a copy with the modifications

var Many2ManyListView_New = Many2ManyListView.extend({

});

extention_not_done = true;

}

}

});

That technique consist of using an include extension to the FieldMany2Many init and call the original init function by calling the super so the class widget will be initialized and you could then access to the original Many2ManyListView class/widget. Just need a check due the init of the FieldMany2Many will be called by many times and we don't wanna applying the extension to the Many2ManyListView several times, we just need one.

*** original answer ***

Try it this way:

var core = require('web.core');

var FieldMany2Many = core.form_widget_registry.get('many2many')

var Many2ManyListView = new FieldMany2Many(args).x2many_views.list

/*** examples ***/

Many2ManyListView.include({

});

var Many2ManyListView_New = Many2ManyListView.extend({

});

With tha code you just need to investigate what need to be passed as args for the FieldMany2Many instantiation and you will be able to call the include or extend on the retrieved Many2ManyListView 

1
Avatar
Cancelar
Pawan
Autor

Thanks a lot axel, frankly i was expecting an answer from you....

what i have done is returned Many2ManyListView also from form_relational(knowing that is not the correct way, but it worked somehow.)

anyway will try it soon and update u...

thanks

Pawan
Autor

One more thing, can just explain a difference between this include n extend.. how it works programmaticaly ...

Axel Mendoza

sure, let me answer your question about the difference of include and extend with an answer update since I found a direct solution to the original problem that directly works

Axel Mendoza

check it now the previous answer updates

Pawan
Autor

Thanks Axel, it worked very well, just a modification needed(inplace of "if(extention_not_done)", it should be "if(!extention_not_done)", which i have updated), rest everything is fine..

Thanks once again...

Axel Mendoza

please don't forget to accept and upvote the answer if it was helpful

Pawan
Autor

And regarding extend and include i have noticed one more thing, when we use 'extend' it is not calling the overriding method as in above case for Many2ManyListView, i was trying to override do_activate_record by extending Many2ManyListView, but it is not calling overriding method(still going with the base method),

do you have any idea why is ti happening so...?

Axel Mendoza

read carefully what I wrote about that, extend will not modify the original class/widget, it will return a new class/widget with the modifications

Pawan
Autor

oh.. ok , i missed, thanks once again...

Está gostando da discussão? Não fique apenas lendo, participe!

Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!

Inscreva-se
Publicações relacionadas Respostas Visualizações Atividade
Extending/Overriding public widgets.
widget js
Avatar
Avatar
1
mai. 23
8476
problem with bind a js widget and xml Template to add it in html dev
widget templates js
Avatar
Avatar
1
jun. 23
3822
Sign App won't display PDF while custom JS widget added to the SystrayMenu
widget js sign
Avatar
0
jan. 21
3544
Error: "Could not find client action MyWidget" in widget [Odoo 12.0alpha1+e]
widget js master
Avatar
Avatar
Avatar
2
dez. 19
9292
How to Inheirt SectionAndNoteListRenderer function to include my custom code Resolvido
widget js render
Avatar
Avatar
1
dez. 19
6499
Comunidade
  • Tutoriais
  • Documentação
  • Fórum
Open Source
  • Baixar
  • Github
  • Runbot
  • Traduções
Serviços
  • Odoo.sh Hosting
  • Suporte
  • Upgrade
  • Desenvolvimentos personalizados
  • Educação
  • Encontre um Contador
  • Encontre um parceiro
  • Torne-se um parceiro
Sobre nós
  • Nossa empresa
  • Ativos da marca
  • Contato
  • Empregos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidade
  • Segurança
الْعَرَبيّة 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 é um conjunto de aplicativos de negócios em código aberto que cobre todas as necessidades de sua empresa: CRM, comércio eletrônico, contabilidade, estoque, ponto de venda, gerenciamento de projetos, etc.

A proposta de valor exclusiva Odoo é ser, ao mesmo tempo, muito fácil de usar e totalmente integrado.

Site feito com

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