Hi David White,So far what I understand from your question is that, "you have a contactrelated with the company details and that company also has some child contactsrelated with this. So you want to show the first listed contact in thelocation_contact_id field." You can achieved this using compute field. below I have share the sample code.
from odoo import models,fields, api
class ResComapny(models.Model):
_inherit = 'res.company'
location_id = fields.Many2one('res.partner', string='Show Location')
location_contact_id = fields.Many2one('res.partner',string="ocation Contact Name", compute='_compute_location_contact_id')
@api.depends('location_id')
def _compute_location_contact_id(self):
for record in self:
if record.location_id.child_ids:
record.location_contact_id = record.location_id.child_ids[0].id
you can also store it. by adding parameter store=True in the location_contact_id fields and by the way if you want to showthe comapny dependent contacts only then res.company model already has partner_id. in this case you don't have to add this new field location_id. just replace location_id with partner_id field. Thank you.
Thanks & Regards,
Brain Station 23 Ltd.
Mobile: (+880) 1404055226
Email: sales@brainstation-23.com
Web: https://brainstation-23.com/
Address: (Building-1) 8th Floor, 2 Bir Uttam AK Khandakar Road, Mohakhali C/A, Dhaka 1212, Bangladesh