Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
5 Trả lời
10124 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
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
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Tác giả

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

Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 23
5442
4
thg 8 22
8004
3
thg 4 15
3807
1
thg 2 23
3408
3
thg 12 22
3389