Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
4419 Tampilan

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
Buang

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

Penulis

Thank you, it worked.

Jawaban Terbai

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
Buang
Penulis

It worked. Thank you.

Post Terkait Replies Tampilan Aktivitas
1
Okt 23
2617
1
Agu 24
1111
1
Agu 24
1919
2
Agu 23
2865
1
Mei 23
5365