تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
4485 أدوات العرض

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
أكتوبر 23
2723
1
أغسطس 24
1211
1
أغسطس 24
2158
2
أغسطس 23
2989
1
مايو 23
5487