Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odgovori
4457 Prikazi

I have added a custom field in res.partner. It is a site code which is needed on shipping addresses, but not on other types of partner addresses. Each customer can have multiple shipping addresses.

I added x_site_code to res.partner, it is hidden unless the address type is shipping.

I have successfully added the new field to my QWeb report from sale.order by using o.partner_shipping_id.x_site_code – This works fine.

What I also need to do is show the site code on the Sale Order Form view, dependant on which of the shipping addresses for the customer has been selected.

I have tried

x_site_code_id = fields.Many2one('res.partner.x_site_code', string='Site Code', readonly=True,

        help="Site Code from Shipping Address")

But it doesn’t populate the field. It needs to come from the shipping_id, but I’m not sure how to reach that. I need to get to the partner_id.shipping_partner_id.x_site_code is this possible?

Avatar
Opusti

Can't you define the custom field on the sale.order model as related to 'partner_shipping_id.x_site_code' ?

Avtor

Thank you, it worked.

Best Answer

Hello Gill Potter,

You can define the custom field on the sale.order model like this (related field)

x_site_code_id = fields.Char(related='partner_shipping_id.x_site_code', string='Site Code', readonly=True, help="Site Code from Shipping Address")
Avatar
Opusti
Avtor

It worked. Thank you.

Related Posts Odgovori Prikazi Aktivnost
1
okt. 23
2673
1
avg. 24
1182
1
avg. 24
2073
2
avg. 23
2924
1
maj 23
5445