Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
5 Replies
10000 Tampilan

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
Buang
Jawaban Terbai
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
Buang
Jawaban Terbai

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
Buang
Penulis

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

Penulis

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

Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
1
Sep 23
5326
4
Agu 22
7787
3
Apr 15
3717
1
Feb 23
3223
3
Des 22
3243