Skip to Content
Menu
This question has been flagged
5 Replies
9068 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.

Avatar
Discard
Best Answer
def get_partner_address(partner):
address = "{name}\nP.O Box : {zip}, {country}\nTel. : {phone}, Email : {email}".format(name = partner.display_name,
zip=partner.zip,
phone=partner.phone,
country=partner.country_id.name,
email=partner.email
)
return address
Avatar
Discard
Best Answer

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

Avatar
Discard
Author

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

Author

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

Best Answer

there is also a field 'contact_address' in the 'res.partner' model. Its the computed field, that calls '_display_address' method. As the same one, I guess, it could be possible to create another method, that will build the shipping address.

Avatar
Discard
Related Posts Replies Views Activity
1
Sep 23
4394
4
Aug 22
6624
3
Apr 15
2761
1
Feb 23
1656
3
Dec 22
1969