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

Clone a view with its modifications (extend res.partner)

Subscriure's

Get notified when there's activity on this post

This question has been flagged
viewsviewinheritanceres.partnerprogrammingcloneinheri
7585 Vistes
Avatar
Javier Matos Odut

Hello,

I am a developer and I have created some modules for OpenERP v7 that we use in our company. I have a difficult problem that I want to solve and that's why I am willing someone to share some knowledge with me.

I have a module that extends res.partner to add many fields that we need for our customers. The problem with this is that there are many entities or models that depend on res.parther (res.user for instance). When I add fields to res.partner and extend the form view, then views or models that depend on res.partner are also modified, even when they have nothing to do with customers. This is ugly, because providers and users get those new fields, and I don't want that to happen.

A second approach was to use _inherits in order to control an inner partner, but also add the fields that I want:

_name = 'mycompany.customer'
_inherits = {
    'res.partner': 'partner_id',
}
_columns = {
    ...
}

This approach is cleaner. Now my customers have the basic information in res.partner, but I also add extra fields in my mycompany.customer model. The bad thing is that I have to write my own views from the scratch. What I do for this is to copy res.partner views and extend them. The worst part of this is that when an additional module changes res.partner view, then the view for my customer is not modified, so I have to copy the modifications that this module does into my own code.

What is the best way to do what I want? I just want new fields to be added to a customer, but not to a provider nor a user. I thought about adding a "clone" feature to OpenERP to clone views and its modifications. This way I will be able to clone res.partner views and make some changes to include customer fields.

1
Avatar
Descartar
Leonardo Donelli

Can't you just extend the form view normally (as you did initially) and make the fields invisible when the partner is not a customer?

Javier Matos Odut
Autor

Thank you Leonardo, that is a good idea. How can I know when the partner is a customer? Can I just use domain with customer = 1? What I was trying now is to redefine the fields_view_get function, that is supposed to create a view dynamically. I will check your suggestion first, which seems to be easier. Thank you so much :)

Javier Matos Odut
Autor

Done, thank you so much Leonardo :)

Leonardo Donelli

Yes you can use [('customer', '=', 1)] assuming you correctly flagged customers. Personally, I would add a tab in the res_partner form view notebook (called 'Customer info'), with all the customers-only fields, and show that only when partner is a customer.

Javier Matos Odut
Autor

That is exactly what I had. There where also some minor changes that I made outside that customer notebook, but they were also hidden successfully. Thank you so much again, I was looking for an "Star Wars hiper-complex solution" doing meta programming to extend cloned views (with fields_view_get) but your proposal is just the easiest and most correct way to do it. Thank you again :)

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
attribute error in inherited view?
view inheritance res.partner
Avatar
Avatar
Avatar
2
de març 15
9710
I want to use res_partner view to another menu action with fields (not all) in res_partner
views inheritance res.partner odoo
Avatar
Avatar
1
de nov. 21
3997
inherited form does not display correctly?
view inheritance res.partner look
Avatar
Avatar
Avatar
3
d’oct. 20
6663
view inherit from res.partner appears all one page with no styling or formatting
view inheritance res.partner appearance
Avatar
Avatar
1
de març 15
7459
custom_function is not a valid action on... Solved
views view inheritance buttons odoo
Avatar
Avatar
1
de nov. 22
7995
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