Skip to content

Instantly share code, notes, and snippets.

@Altreus
Created October 28, 2014 12:43
Show Gist options
  • Save Altreus/4c8e20bb43b9b37f131f to your computer and use it in GitHub Desktop.
Save Altreus/4c8e20bb43b9b37f131f to your computer and use it in GitHub Desktop.
The best thing about python is how it forces you to write readable code
return reduce(lambda x,y: x+y, [ l.product_id.categ_id.name <> 'Margin' and l.price_subtotal or (l.price_unit * (l.product_uos and l.product_uos_qty or l.product_uom_qty)) for l in o.order_line ]) - (reduce(lambda x,y: x+y, [ reduce(lambda x, o: x + o.price_subtotal, i.invoice_line, 0) for i in o.invoice_ids if i.name and i.comment == 'PX' and i.state != 'cancel']) if [i for i in o.invoice_ids if i.name and i.comment == 'PX' and i.state != 'cancel'] else 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment