class SaleOrderLine(self)
inherit = 'sale.order.line'
def check_lowest_qty(self):
for line in self:
#print line product_uom_qty with least or biggest negative quantity
Updated question with better grammar. I want to compare the quantity of each line and to print line which has the least quantity or biggest negative quantity.
For example.
If there are 2 lines and first lines quantity is 5 and second lines quantity is -2 I want to print line with -2.
You could use sorted()
on the recordset and just get the first entry if there is one:
def check_lowest_qty(self):
self.sorted(key=lambda line: line.product_uom_qty)
print self[0] if self else None
If you want the order reversed use self.sorted(key=lambda line: line.product_uom_qty, reverse=True)