Skip to content

Commit

Permalink
Merge 275906d into ff78c96
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriela Mogollón authored Nov 25, 2020
2 parents ff78c96 + 275906d commit 09ec870
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions stock_by_warehouse/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,20 @@ def _compute_get_quantity_warehouses_json(self):
# itself, we enable this context management
warehouse_id = self._context.get('warehouse_id')

for warehouse in self.env['stock.warehouse'].sudo().search([]):
# Just in case it's asked from only a group of warehouses
warehouse_ids = self._context.get('warehouse_ids', False)
some_wh = False
if warehouse_ids:
info['warehouse'] = 0.0
some_wh = not warehouse_id

for warehouse in warehouse_ids or self.env['stock.warehouse'].sudo().search([]):
product = self_origin.sudo().with_context(
warehouse=warehouse.id, location=False)
if warehouse_id and warehouse_id.id == warehouse.id:
info['warehouse'] = product.qty_available_not_res
if some_wh:
info['warehouse'] += product.qty_available_not_res
info['content'].append({
'warehouse': warehouse.name,
'warehouse_short': warehouse.code,
Expand All @@ -91,8 +100,7 @@ def _compute_get_quantity_warehouses_json(self):
'virtual': product.virtual_available,
'incoming': product.incoming_qty,
'outgoing': product.outgoing_qty,
'saleable':
product.qty_available - product.outgoing_qty
'saleable': product.qty_available - product.outgoing_qty
})
return json.dumps(info)

Expand Down

0 comments on commit 09ec870

Please sign in to comment.