Pass context to other model
<xpath expr="//field[@name='product_ids']//field[@name='product_id']" position="after">
<field name="related_location_id" />
</xpath>
<xpath expr="//field[@name='product_ids']//field[@name='product_id']" position="attributes">
<attribute name="context">{'tree_view_ref': 'ktc_equipment.product_material_request_view_tree', 'related_location_id': related_location_id}</attribute>
</xpath>Get context and compute
free_qty_per_location = fields.Float("Available Qty", compute="_compute_free_qty_per_location")
def _compute_free_qty_per_location(self):
for record in self:
record.free_qty_per_location = 0
context = self._context
location_id = context.get('related_location_id', False)
if location_id:
# put you query here