跳至內容
選單
此問題已被標幟
2 回覆
4483 瀏覽次數

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?

頭像
捨棄

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

作者

Thank you, it worked.

最佳答案

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")
頭像
捨棄
作者

It worked. Thank you.

相關帖文 回覆 瀏覽次數 活動
1
10月 23
2718
1
8月 24
1210
1
8月 24
2154
2
8月 23
2984
1
5月 23
5486