Skip to content

Instantly share code, notes, and snippets.

@aliomattux
Created October 15, 2013 21:58
Show Gist options
  • Save aliomattux/6999295 to your computer and use it in GitHub Desktop.
Save aliomattux/6999295 to your computer and use it in GitHub Desktop.
def _get_product_bin_info(self, products):
result = []
for product in products:
product_tmpl_id = product.product_tmpl_id
result.append(self._get_brand_specific_items(product_tmpl_id))
return result
def _get_brand_specific_items(self, product_tmpl_id):
cr = self.cr
uid = self.uid
inv_obj = self.pool.get('stock.inventory')
bin_obj = self.pool.get('stock.location.bin')
result = {'internalid': product_tmpl_id.internalid}
for brand_item in product_tmpl_id.product_item_ids:
if brand_item.brand_id.name == 'Northern Brewer':
key_name = 'nb'
bin_name = 'loc1'
else:
key_name = 'mw'
bin_name = 'loc2'
bin_id = inv_obj.get_product_id_fixed_bin(cr, uid, \
brand_item.id, brand_item.brand_id.id)
if bin_id:
bin = bin_obj.browse(cr, uid, bin_id)
pick_bin = bin.name
else:
pick_bin = False
result.update({key_name: brand_item.sku,
bin_name: pick_bin or 'Empty'
})
if 'nb' not in result.keys():
result['nb'] = 'Empty'
result['loc1'] = 'Empty'
if 'mw' not in result.keys():
result['mw'] = 'Empty'
result['l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment