Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

[SOLVED] How to override the display_name of a kanban (res.partner.kanban)?

By
Juan Formoso
on 10/14/14, 4:05 AM 1,690 views

I know that there are exactly the same question here:

https://www.odoo.com/es_ES/forum/help-1/question/how-to-override-the-display-name-of-a-kanban-res-partner-view-23392

But I tried the answers with no result. In the standard kanban view of a partner, if this one is a person, their name is shown as following:

company, name

If I check the code of the kanban view, I find the line which is showing the name:

<h4 class="oe_partner_heading"><a type="open"><field name="name"/></a></h4>

But why is showing the column display_name instead of name?

I tried to remove that, and I cannot, because, let's show my example:

This works, and shows the phone just after the display_name (why display_name??? I specified name):

<xpath expr="//kanban/templates//div//div/h4" position="replace">
     <h4><a type="open"><field name="name"/> <field name="phone"/></a></h4> ...

This does not work:

<xpath expr="//kanban/templates//div//div/h4" position="replace">
     <h4><a type="open"><field name="phone"/></a></h4> ...

It seems that if I remove the field name, it will not work. Anyone knows about this problem? How can I remove the name of the company in the kanban view if the partner is a person?

EDIT

def name_get(self, cr, uid, ids, context=None):
        if context is None:
            context = {}
        if isinstance(ids, (int, long)):
            ids = [ids]
        res = []
        for record in self.browse(cr, uid, ids, context=context):
            name = record.name
            res.append((record.id, name))
        return res

1
Juan Formoso
On 10/14/14, 9:56 AM

I solved it (in my case, it was not necessary to override anything, only inherit from base.res_partner_kanban_view and modify the XML), in the next way:

                <xpath expr="//kanban/templates//div//div/h4" position="attributes">
                    <attribute name="invisible">1</attribute>
                </xpath>
                <xpath expr="//kanban/templates//div//div/h4" position="after">
                    <h4 class="oe_partner_heading"><a type="open"><field name="name"/></a></h4>
                </xpath>

0

Ludo - Neobis

--Ludo - Neobis--
2387
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--

Developer

Ludo - Neobis
On 10/14/14, 5:23 AM

Find the appropriate "name_get" method on the object the kanban is view. This will most likely tell you how the name is returned when OpenERP searches for this object on the background.

Override the method and provide your own defintion to see if it changes.

I cannot manage this, I edited my post with the override of the python function.

Juan Formoso
on 10/14/14, 6:40 AM

It's a bit unclear for me. Are you unable to override the method, or are you unable to see any changes once the overridden method works?

Ludo - Neobis
on 10/14/14, 9:00 AM

@Ludo - Neobis the second one. But I have just found a way to manage what I want. Instead of using replace in the XML view, I made that tag invisible and write after that.

Juan Formoso
on 10/14/14, 9:48 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/14/14, 4:05 AM
Seen: 1690 times
Last updated: 3/16/15, 8:10 AM