Guys, I'm a beginner so sometimes I have a problem with some things. I would like to get a value from sale_order_line.
In my table I have a column named: item_location
How to get data from this column?
class sale_order_line(models.Model):
_inherit = 'sale.order.line'
item_location = fields.Char(compute='get_location', string = 'Item location', type='Char')
def get_location(self):
location = self.env['sale.order.line'].search([('product_id','=',self.product_id.id)])
print ' Self product ID :', self.product_id.id# Ok
print ' Self ID :', self.id # ok
print ' Location ID :', location.id # ok
print ' Location name :', location.item_location # False
res = location.item_location # this is what I need
return res
sale_order_line()
but I still missing something because I can't get a value from the item_location column.
How to do it with a new API ?
GOT IT!
You guys are right, I don't have to do it using Search or Browse in this case ;) because that field is available directly :)
Ii's another valuable lesson for me, THANK YOU GUYS
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 :)