Skip to Content
Menu
This question has been flagged
2 Replies
3779 Views

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
Discard

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

Author

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
Discard
Author

It worked. Thank you.

Related Posts Replies Views Activity
1
Oct 23
1384
1
Aug 24
100
1
Aug 24
297
2
Aug 23
1378
1
May 23
3713