跳至内容
菜单
此问题已终结
2 回复
9240 查看

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
3022
0
11月 18
3282
1
10月 16
10752
2
11月 23
7558
2
5月 23
7862