Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
9038 Widoki

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...

Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Autor

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.

Autor

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?

Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

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

Powiązane posty Odpowiedzi Widoki Czynność
2
gru 19
2518
0
lis 18
3087
1
paź 16
10547
2
lis 23
7183
2
maj 23
7335