콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
9456 화면

I would like to see a street + city of a partner underneath the delivery address selector on a sale order screen. I had another solution where I added a text field to sale.order and a onchange function, but I think theres a better way.


Here is what I have in the view:

<field name="partner_shipping_id">

                                <tree>

                                <field name="street" string="Street"/>

                                </tree>

                            </field>


I have also tried using mode=form but none of these seem to alter the default behavior of showing the delivery address contact name...

아바타
취소
베스트 답변

Rays way is one way, probably best if you are not wanting to write code.  But to make it display like the customer in the above screen shot then you just add the context key "show_address".  If you really wanted it like the above shot and just street and city on one line, then overriding name_get with a new context key say "show_street_city" is a more perfomant and neater way to do it as its all done in one function call.

Otherwise you end up with same issue when you want to do on pickings or invoices for example.

If you look at name_get in res_partner.py it will show you the already existing context keys and how they are formatted, so pretty straightforward.

아바타
취소
작성자

the show address attribute doesnt show for when sale is in a unsaved state. I want my users to see the address and confirm it with a customer before hitting confirm sale/save

True, thats because the edit widget is only one line tall. You could still set a context key, to display on one line mind you. We just do that, and also make the whole address searchable, but then we got 80,000 delivery addresses, no one is searching by name, always by street or GEO.

Works out quite nice because as they type the address the search list narrows and they can see the address to pick.

작성자

So you override get_name so that it displays street1+2+city etc, but what if the delivery address and base partner record are the same? How would you see the customer name?

베스트 답변

You can create a new field on the sale.order model to contain this data, and add that field to the view:


NEW FIELD:


ADDED TO THE VIEW:



Code for the field calculation:

for record in self:
  record['x_street_city'] = record.partner_shipping_id.street + " " + record.partner_shipping_id.city

아바타
취소
작성자

this was similar to my first attempt, except I used one of the on change method: I need it to show while the sale is in a draft so that the user can pick a customer and without saving, have it show the delivery address (to confirm with customer before sale is processed). I think there must be a way of showing this without having to add another field though

Hello,

Thanks for the above.

I am trying to do the some but its giving some error as dependencies is also required.

Can you please let me know what to add in dependencies?

Thanks

partner_shipping_id

관련 게시물 답글 화면 활동
2
12월 19
3281
0
11월 18
3506
1
10월 16
10971
2
11월 23
7822
2
5월 23
8163