Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Clickable "Contacts & Addresses" inside res.partner

Subscribe

Get notified when there's activity on this post

This question has been flagged
contactsres.partnerpartners
8 Replies
16079 Views
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
Discard
Avatar
David Todd
Author 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
Discard
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
Discard
David Todd
Author

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
Discard
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
Discard
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
Discard
David Todd
Author

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!

Sign up
Related Posts Replies Views Activity
Need help with [v15] ValueError: Invalid field 'total_due' on model 'res.partner' Solved
contacts res.partner
Avatar
Avatar
1
Jun 23
5236
Partner_id name, name
contacts res.partner
Avatar
Avatar
1
Jun 22
7976
Restricting view of contact persons of a Partner
contacts partners
Avatar
0
May 19
3003
Make 'opt-out' checkbox settable per each contact of a company (partner)
contacts res.partner
Avatar
0
Mar 15
4959
prevent write on status field
contacts res.partner write
Avatar
Avatar
Avatar
Avatar
4
Jul 25
1777
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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