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

I have a customer field in my module, which looks like this:

customer = fields.Many2one('res.partner', string='Customer')

In my form view, I display it like this:

<field name="customer" context="{'show_address': 1}" options="{'always_reload': True}"/>

This displays the address only after I save the record. But I want it to show the customer's address before the record is saved.

I could just create a few fields to represent the customer address, but I want to see if there is a better way of showing the address. Any ideas?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello you can apply a related field to see the address


customer = fields.Many2one('res.partner', string='Customer')

street = fields.Char(related='customer.street', string='Street')


<field name="customer"/>

<field name="street"/>

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi colinito, 

Actually what you see ( partner name and address is stored in field name ) is done by overriding name_get function that is triggered after Save and will reattribute name value based on given information: in your case context="{'show_address': 1}"

You're going to need other fields to achieve that.


Hope this helps.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 5 24
12812
1
thg 4 24
3432
0
thg 11 23
2080
1
thg 9 23
2236
2
thg 8 23
4658