This question has been flagged
1 Reply
5647 Views

Hallo everybody, please be kind and let me know, how to link a custom field from two tables/models, for example a new field from res.partner in sales.order

my case, I add a new field, family_name, in res.partner and then I want to call that field in sales.order. I did, many2one relationship in model sales.oder. but, it doesn't show the value.

Please show me how it works and wish you have a good Karma. Thanks In advance

Avatar
Discard
Best Answer

For that you can use fields.related in sale.order.

Try this:

' partner_family_name': fields.related('partner_id', ' family_name', type='char', string='Partner Family Name', readonly=True, store=True),

fields.related is a field that points to some data inside another field of the current record.

Example:

_columns = { 'partner_id': fields.many2one('res.partner', 'Partner'), 'partner_name': fields.related('partner_id', 'name', type='char', string='Partner Name'), }

Here Related Field you can find more about fields.related.

Avatar
Discard
Author

Hi Sudhir thank you so much for your respond. I'm not programmer. I do customizing in the Web platform. So I add a new field x_family_name which is custom field. How do I do that in the Setting? hope you can help me. Thank you!