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.

0

Show Partner's Full Address in Treeview

By
grayson
on 2/2/16, 1:15 PM 631 views

Wondering if this is possible. I am specifically trying to do it with the customers shipping address in the Invoices Treeview.

I got it to work in formview like this: 

<field name="address_shipping_id" position="attributes" context="{'show_address': 1, 'default_type': 'delivery'}" options="{'always_reload': True}"/>

But I think it should be different in treeview to get this to work.


Thank you in advance for your time.

1

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


Ahmed M.Elmubarak
On 2/3/16, 3:57 AM

Hello,

 There may be a solution by adding a new functional field e.g:

'shipping_address': fields.function(_get_shipping_address, string='Shipping Address', type='char'),

Then the function could be such as:

 def _get_shipping_address(self, cr, uid, ids, name, arg, context=None):
res = {}
partner = self.pool['res.partner'] #if you're using the res.partner for address
for rec in self.browse(cr, uid, ids, context=context):
            ship_id = rec.address_shipping_id
            address = ship_id and partner.name_get(cr, uid, [ship_id.id], context={'show_address': 1}                )[0][1] or ''
            res[rec.id] = address
return res


Then add this new field in the tree view instead of address_shipping_id


This is an idea there may be a better one. and you can refine it ...


Regards

Thanks for the suggestion, I'll give that a try.

grayson
on 2/3/16, 9:00 AM

Works great. Thank you for your time, my friend.

grayson
on 2/3/16, 10:14 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: 2/2/16, 1:15 PM
Seen: 631 times
Last updated: 2/3/16, 10:12 AM