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

Clickable "Contacts & Addresses" inside res.partner

Subscriure's

Get notified when there's activity on this post

This question has been flagged
contactsres.partnerpartners
8 Respostes
16125 Vistes
Avatar
David Todd

We have recently rolled out Odoo to our sales staff and one of the biggest features that they wish they could have is this. Basically when you create a contact in Odoo, you have the ability to create child contacts. This is great, except that the form to create the child contacts (inside the parent contact) has very little useful information available.

What I'm looking for is the ability to click one of the contacts, and instead of the "Open: Contacts" modal opening, to navigate to the contact in question (so it's the same view as the parent) possibly into a new tab. 

I have looked into the form view for res.partner and found a template where I could probably add more data, but that isn't helpful in my case. I have also looked at the page client side, but found that there is no information there that I can use to be able to redirect those clicks to a useful location.


Any help would be greatly appreciated 


0
Avatar
Descartar
Avatar
David Todd
Autor Best Answer

Well this is unfortunate. The only answer to this problem I was able to find was to create my own solution.

This required two modifications that can easily be put into a custom module that inherits res.partner. 


The first modification I had to make was to make the document IDs available on the client. Inside res.partner.form, scroll down until the template is defined. In here, we are going to use a field to make the ID available; This can be put pretty much anywhere within the markup for the actual kanban boxes.


The modification that I had to make to this view is

<a class="partnerCardID" style="display:none"><field name="id"/></a>

I chose to put the ID into an anchor because they are easy to work with. This is invisible to the end user (thanks to display:none) so we can manipulate this all we want with JS

I chose to put the modification just above 

<div class="oe_kanban_details">


The other part of the modification is, naturally a little bit of JavaScript magic. I'll include the code that made it work, but you'll have to set it up to work directly on your page/run automatically.

// Select all divs that have the classes ow_kanvan_global_click and o_kanban_record that have a child anchor with a class of partnerCardID (our tag containing the ID)

$('div.oe_kanban_global_click.o_kanban_record > a.partnerCardID').each(function(){

// Wrap the above div with a link that navigates to the correct partner in a new tab

$(this).parent().wrapInner('<a href="//odoo/web#model=res.partner&view_type=form&id='+$(this).text()+'" target="odoo-'+$(this).text()+'"></a>');

});

Change the location of the link above to your own host, run this javascript after the page has loaded and all of your Contacts & Addresses will be clickable, with the full information available. Style the link as you see fit.


Note: I am opening these links in a new tab (through the use of target) because the user's current context will not follow, so if they are working from a search or something else, it isn't lost by navigating away

1
Avatar
Descartar
Cliff Kujala

This is still a problem in v16 and v17. Why do Odoo want these limited pop up views? It just means we have to customize the contact card layouts and the pop-up layouts.

I would prefer to just always open the full view.

Has anyone found a better solution than the above by David Todd for v16 and/or v17?

Avatar
HIGHCO - Nicolas Clavier
Best Answer

Hi David,

If it's still of any help, to reformulate your question (for odoo 8 at least) :  

how can I instruct odoo to use a different view than the modal view displayed when clicking on a contact card from a Partner's form ?

And the answer lies in the partner_form_view code itself, below the kanban template, there is an inline form :

<form string="Contact"> 
 <sheet>
    <field name="image" widget='image' class="oe_avatar oe_left" options='{"preview_image": "image_medium"}'/>
<div class="oe_title">
...

The mechanism of choosing a view (when no action forces a specific one..)  is by evaluating the priority of a view (form or tree or any other one), the highest priority being given to the inline ones. View records with specific priorities defined in their code are then evaluated, and finally, if none of these are found, odoo will choose a default view (for example the only form view ever defined for a model) or again compose a default view with all existing fields for an object. 

Therefore what you have to do is force odoo to ignore this inline form by either forcing the priority of another view (impossible with partner view inside a partner view, it would lead to a mess). 

Or ... remove that inline view, and let odoo guess which default form should be used. In this case : the normal form.

It can be achieved by inheriting the base.view_partner_form and selecting / replacing with xpath the elements that are in your way:

<xpath expr="//sheet/notebook/page/field/form[@string='Contact']" position="replace"/>

Now, embed it in a record:

<record model="ir.ui.view" id="res_partner_form"> 
    <field name="name">res.partner.form</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="arch" type="xml">
        <xpath expr="//sheet/notebook/page/field/form[@string='Contact']" position="replace"/>
    </field>
</record>

Next you will need to heal other view records relying on the elements you just removed, and luckily by default there is only one in the sale module addons/sale/res_partner_view.xml :

You will have to overwrite that one (instead of inheriting it, up to you really there are pro's an con's..), here is the raw record :

<record id="res_partner_address_type" model="ir.ui.view"> 
<field name="name">res.partner.view.address_type</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr="//label[@for='type']" position="attributes">
<attribute name="groups">sale.group_delivery_invoice_address</attribute>
<attribute name="invisible">False</attribute>
</xpath>
<xpath expr="//div[@name='div_type']" position="attributes">
<attribute name="invisible">False</attribute>
<attribute name="groups">sale.group_delivery_invoice_address</attribute>
</xpath>
<!-- Version-specific hacks to avoid breaking view inheritance when the sale module is installed on top of an older 7.0 version of the base module (as the second embedded div_type was added later in the 7.0 release) TODO: remove the hacks in trunk -->
<xpath expr="//div[@name='div_type'][field[@name='use_parent_address']] | //field[@name='child_ids']//div[@name='div_type']" position="attributes">
<attribute name="invisible">False</attribute>
<attribute name="groups">sale.group_delivery_invoice_address</attribute>
</xpath>
<xpath expr="//label[@for='type'][following-sibling::div[@name='div_type']/field[@name='use_parent_address']] | //field[@name='child_ids']//label[@for='type']" position="attributes">
<attribute name="invisible">False</attribute>
<attribute name="groups">sale.group_delivery_invoice_address</attribute>
</xpath>
</field>
</record>

override it by taking out path selectors pointing to the code you just removed, here is the result:

<record id="sale.res_partner_address_type" model="ir.ui.view"> 
    <field name="name">res.partner.view.address_type</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_form" />
    <field name="arch" type="xml">
        <xpath expr="//label[@for='type']" position="attributes">
            <attribute name="groups">sale.group_delivery_invoice_address</attribute>
            <attribute name="invisible">False</attribute>
        </xpath>
        <xpath expr="//div[@name='div_type']" position="attributes">
            <attribute name="invisible">False</attribute>
            <attribute name="groups">sale.group_delivery_invoice_address</attribute>
        </xpath>
    </field>
</record>

Make a custom module with this code, think of dependencies in the manifest (base, sale), load, force update with command line -u my_custom_module, and test..

Hope this helps, as this quick create view is nothing but a bogger, it leads people to enter incomplete partner records.

- Nicolas -

1
Avatar
Descartar
David Todd
Autor

Thank you for this incredibly concise answer! I'll definitely have to keep it in mind when I have to re-visit this part of the system for our Sales team to give them new features.

HIGHCO - Nicolas Clavier

Cheers - you can mark this post as the right answer if you are satisfied with it. tx.

Avatar
Remy
Best Answer

A solution for Odoo 11, where instead of making the whole box clickable, I add a small link to it.

<!-- Add small "link button" to existing view. -->
<record model="ir.ui.view" id="partner_vendor_form_view">
<field
name="name">res.partner.with.buttons</field>
<field
name="model">res.partner</field>
<field
name="inherit_id" ref="base.view_partner_form"/>
<field
name="arch" type="xml">
<data>
<!-- Make sure that template has access to the 'id' value, before "Name". !-->
<xpath expr="//field[@name='child_ids']/kanban/field[@name='name']" position="before">
<field
name="id"/>
</xpath>
<!-- Add the actual link to the template. !-->
<xpath expr="//field[@name='child_ids']/kanban/templates//div[@class='oe_kanban_details']/field[@name='name']" position="before">
<a
t-att-href="'#id='+record.id.raw_value+'&amp;model=res.partner'" class="fa fa-fw o_button_icon fa-pencil-square-o pull-right">
</a>
</xpath>
</data>
</field>
</record>
0
Avatar
Descartar
Avatar
dbvieira
Best Answer

What is really anoying is that it was working on V7... on V8+ disapeared... The new form is trully uselless as one need to get out and either update the contact OR get out of the partner to create a new contact with the propper form and assign it to the account.


Im waiting for V11 to see what happens...odoo has some really nice features, its a pitty on each new version they mess with something...


0
Avatar
Descartar
Avatar
Ray Carnes
Best Answer

https://apps.openerp.com/apps/modules/8.0/web_tree_many2one_clickable/

Can you show the contacts in treeview instead of kanban view, and install the module to allow them to be clicked?


0
Avatar
Descartar
David Todd
Autor

I looked at the module that you linked and I'm pretty sure it won't do what I need. If you have an instance of Odoo available to you, if you go into Contacts and select any contact, you'll be taken into the form view for that specific contact. Now there is a notebook at the bottom of the form with a page that says "Contacts & Addresses". Normally when there are contacts in this page, they are their own contacts with their parent_id set. These specific contacts are what I'm looking to be able to click to be brought into the same form view that the parent was on. The reason being is that we have a couple extra pages in the notebook I mentioned above that contains information that we need access to when looking specifically at the contact from the company page. Thanks for the suggestion though, it might come in handy further down the line.

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
Need help with [v15] ValueError: Invalid field 'total_due' on model 'res.partner' Solved
contacts res.partner
Avatar
Avatar
1
de juny 23
5265
Partner_id name, name
contacts res.partner
Avatar
Avatar
1
de juny 22
8022
Restricting view of contact persons of a Partner
contacts partners
Avatar
0
de maig 19
3010
Make 'opt-out' checkbox settable per each contact of a company (partner)
contacts res.partner
Avatar
0
de març 15
4968
prevent write on status field
contacts res.partner write
Avatar
Avatar
Avatar
Avatar
4
de jul. 25
1794
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