Hi @Dr Obx
You need put the model of that query and the domain like:
location = self.env['sale.order.line'].search([('product_id','=',self.product_id.id)])
bolded are the changes to your code, the model is sale.order.line like every other api model method interaction and the domain need to be changed to pass exactly the id value of the product_id relation field because the domain parser will not do it for you, you need to pass exactly the value in the param #3 of the domain tuple.
Also if your item_location field is on the sale.order.line model you need to access it like:
location.item_location
if it's on the product.product model then you could get it (using your actual code) like:
location.product_id.item_location
but you could directly access the product if you don't need the sale.order.line changing your search like:
product = self.env['product.product'].search([('id','=',self.product_id.id)])
item_location = product.item_location
this last is guessing where is located the field item_location because was not clear to me in your answer
Hope this helps
********************************** Update*****************************************
Seeing your code changes seems that you are doing more than needed for get the item_location.
1- The item_location is on your sale.order.line so you could access it directly from the outside of the model, you don't need a computed field for that.
2- The search is not necessary because search usually is for get the ids and you already have the id, so a search with that domain will produce the same self.id value but with the browse applied so you could directly use the browse like:
location = self.env['sale.order.line'].browse(self.id)
But I repeat you could directly get the value from the outside without using a computed field. Also for the same thing there is a field definition way that will cause that Odoo get the value of others fields in the table or walking through many2one relations fields, like:
item_location = fields.Char(related='item_location', string = 'Item location')
And nothing more is needed
The thing appears to be that the sale order line doesn't have a value for the item_location field
I managed to make it works but for some reason I can't see it in order form(table), any ideas why ?
(I edited your code you readability.)
PY: Where ?
just the display, your code, can't you see the code is now in a proper code block (pre tag) ? easier to read when well indented and all
Yes I think everything is done correctly, I still cant see the content of 'location' field. But I can see "item_location" instead so 'location' is not required anymore ;) Thanks for help :)