Skip to content

Instantly share code, notes, and snippets.

@bwrsandman
Created October 18, 2013 14:20
Show Gist options
  • Save bwrsandman/7042268 to your computer and use it in GitHub Desktop.
Save bwrsandman/7042268 to your computer and use it in GitHub Desktop.
Index: ../../../Private/code/openerp/fruigor/bzr/pallet-delivery/purchase_lot_tracking/account.py
===================================================================
--- ../../../Private/code/openerp/fruigor/bzr/pallet-delivery/purchase_lot_tracking/account.py (revision )
+++ ../../../Private/code/openerp/fruigor/bzr/pallet-delivery/purchase_lot_tracking/account.py (revision )
@@ -52,17 +52,18 @@
def _estimated_tcu(self, cr, uid, ids, name, arg, context=None):
res = {}
-
for line in self.browse(cr, uid, ids):
if line.code.startswith('LOT'):
po_line_pool = self.pool.get('purchase.order.line')
- po_line_id = po_line_pool.search(cr, uid, [('account_analytic_id', '=', line.id)])[0]
+ po_line_ids = po_line_pool.search(cr, uid, [('account_analytic_id', '=', line.id)])
+ if po_line_ids:
+ po_line_id = po_line_ids[0]
- po_line = po_line_pool.browse(cr, uid, po_line_id, context)
+ po_line = po_line_pool.browse(cr, uid, po_line_id, context)
-
- res[line.id] = po_line.landed_costs / po_line.product_qty
- else:
- res[line.id] = 0.0
+ res[line.id] = po_line.landed_costs / po_line.product_qty
+ else:
+ res[line.id] = 0.0
-
+ else:
+ res[line.id] = 0.0
return res
_columns = {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment