(self, src__=0, optimisation__=True,
                       ignore_variation=0, standardise=0,
                       omit_simulation=0,
                       only_accountable=True,
                       default_stock_table='stock',
                       statistic=0, inventory_list=1,
                       precision=None, connection_id=None,
                       **kw)
return result
Returns a list of inventories for a single or multiple
      resources on a single or multiple nodes, grouped by resource,
      node, section, etc. Every line defines an inventory value for
      a given group of resource, node, section.
      NOTE: we may want to define a parameter so that we can select
      the kind of inventory statistics we want to display (ex. sum,
      average, cost, etc.)

      Optimisation queries.
      Optimisation of a stock lookup is done to avoid a table scan
      of all lines corresponding to a given node, section or payment,
      because they grow with time and query time should not.
      First query: Fetch fitting full inventory dates.
        For each node, section or payment, find the first anterior full
        inventory.
      Second query: Fetch full inventory amounts.
        Fetch values of inventory identified in the first query.
      Third query: Classic stock table read.
        Fetch all rows in stock table which are posterior to the inventory.
      Final result
        Add results of the second and third queries, and return it.

      Missing optimisations:
       - In a getInventory case where everything is specified for the
         resource, it's not required for the inventory to be full, it
         just need to be done for the right resource.
         If the resource isn't completely defined, we require inventory
         to be full, which is implemented.
       - Querying multiple nodes/categories/payments in one call prevents
         from using optimisation, it should be equivalent to multiple calls
         on individual nodes/categories/payments.
       -
Returns a list of inventories for a single or multiple
      resources on a single or multiple nodes, grouped by resource,
      node, section, etc. Every line defines an inventory value for
      a given group of resource, node, section.
      NOTE: we may want to define a parameter so that we can select
      the kind of inventory statistics we want to display (ex. sum,
      average, cost, etc.)
Returns a list of inventories for a single or multiple resources on a single or multiple nodes grouped by resource node section etc . Every line defines an inventory value for a given group of resource node section . NOTE : we may want to define a parameter so that we can select the kind of inventory statistics we want to display ( ex . sum average cost etc . )
def getInventoryList(self, src__=0, optimisation__=True,
                       ignore_variation=0, standardise=0,
                       omit_simulation=0,
                       only_accountable=True,
                       default_stock_table='stock',
                       statistic=0, inventory_list=1,
                       precision=None, connection_id=None,
                       **kw):
    """
      Returns a list of inventories for a single or multiple
      resources on a single or multiple nodes, grouped by resource,
      node, section, etc. Every line defines an inventory value for
      a given group of resource, node, section.
      NOTE: we may want to define a parameter so that we can select
      the kind of inventory statistics we want to display (ex. sum,
      average, cost, etc.)

      Optimisation queries.
      Optimisation of a stock lookup is done to avoid a table scan
      of all lines corresponding to a given node, section or payment,
      because they grow with time and query time should not.
      First query: Fetch fitting full inventory dates.
        For each node, section or payment, find the first anterior full
        inventory.
      Second query: Fetch full inventory amounts.
        Fetch values of inventory identified in the first query.
      Third query: Classic stock table read.
        Fetch all rows in stock table which are posterior to the inventory.
      Final result
        Add results of the second and third queries, and return it.

      Missing optimisations:
       - In a getInventory case where everything is specified for the
         resource, it's not required for the inventory to be full, it
         just need to be done for the right resource.
         If the resource isn't completely defined, we require inventory
         to be full, which is implemented.
       - Querying multiple nodes/categories/payments in one call prevents
         from using optimisation, it should be equivalent to multiple calls
         on individual nodes/categories/payments.
       -
    """
    getCategory = self.getPortalObject().portal_categories.getCategoryUid

    result_column_id_dict = {}

    metric_type = kw.pop('metric_type', None)
    quantity_unit = kw.pop('quantity_unit', None)
    quantity_unit_uid = None

    if quantity_unit is not None:

      if isinstance(quantity_unit, str):
        quantity_unit_uid = getCategory(quantity_unit, 'quantity_unit')
        if quantity_unit_uid is not None:
          result_column_id_dict['converted_quantity'] = None
          if metric_type is None:
            # use the default metric type
            metric_type = quantity_unit.split("/", 1)[0]
      elif isinstance(quantity_unit, (int, float)):
        # quantity_unit used to be a numerical parameter..
        raise ValueError('Numeric values for quantity_unit are not supported')


    convert_quantity_result = False
    if metric_type is not None:
      metric_type_uid = getCategory(metric_type, 'metric_type')

      if metric_type_uid is not None:
        convert_quantity_result = True
        kw['metric_type_uid'] = Query(
                                  metric_type_uid=metric_type_uid,
                                  table_alias_list=(("measure", "measure"),))

    if src__:
      sql_source_list = []
    # If no group at all, give a default sort group by
    kw.update(self._getDefaultGroupByParameters(**kw))
    base_inventory_kw = {
      'stock_table_id': default_stock_table,
      'src__': src__,
      'ignore_variation': ignore_variation,
      'standardise': standardise,
      'omit_simulation': omit_simulation,
      'only_accountable': only_accountable,
      'precision': precision,
      'inventory_list': inventory_list,
      'connection_id': connection_id,
      'statistic': statistic,
      'convert_quantity_result': convert_quantity_result,
      'quantity_unit_uid': quantity_unit_uid,
    }
    # Get cached data
    if getattr(self, "Resource_zGetInventoryCacheResult", None) is not None and \
            optimisation__ and (not kw.get('from_date')) and \
            'transformed_resource' not in kw:
      # Here is the different kind of date
      # from_date : >=
      # to_date   : <
      # at_date   : <=
      # As we just have from_date, it means that we must use
      # the to_date for the cache in order to avoid double computation
      # of the same line
      at_date = kw.pop("at_date", None)
      if at_date is None:
        to_date = kw.pop("to_date", None)
      else:
        # add one second so that we can use to_date
        to_date = at_date + MYSQL_MIN_DATETIME_RESOLUTION
      try:
        cached_result, cached_date = self._getCachedInventoryList(
            to_date=to_date,
            sql_kw=kw,
            **base_inventory_kw)
      except StockOptimisationError:
        cached_result = []
        kw['to_date'] = to_date
      else:
        if src__:
          sql_source_list.extend(cached_result)
        # Now must generate query for date diff
        kw['to_date'] = to_date
        kw['from_date'] = cached_date
    else:
      cached_result = []
    sql_kw, new_kw = self._generateKeywordDict(**kw)
    # Copy kw content as _generateSQLKeywordDictFromKeywordDict
    # remove some values from it
    try:
      new_kw_copy = deepcopy(new_kw)
    except TypeError:
      # new_kw contains wrong parameters
      # as optimisation has already been disable we
      # do not care about the deepcopy
      new_kw_copy = new_kw
    stock_sql_kw = self._generateSQLKeywordDictFromKeywordDict(
        table=default_stock_table, sql_kw=sql_kw, new_kw=new_kw_copy)
    stock_sql_kw.update(base_inventory_kw)
    delta_result = self.Resource_zGetInventoryList(
        **stock_sql_kw)
    if src__:
      sql_source_list.append(delta_result)
      result = ';\n-- NEXT QUERY\n'.join(sql_source_list)
    else:
      if cached_result:
        result = self._addBrainResults(delta_result, cached_result, new_kw)
      else:
        result = delta_result
    return result
def getInventoryList ( self , src__ = 0 , optimisation__ = True , ignore_variation = 0 , standardise = 0 , omit_simulation = 0 , only_accountable = True , default_stock_table = 'stock' , statistic = 0 , inventory_list = 1 , precision = None , connection_id = None , * * kw ) : getCategory = self . getPortalObject ( ) . portal_categories . getCategoryUid result_column_id_dict = { } metric_type = kw . pop ( 'metric_type' , None ) quantity_unit = kw . pop ( 'quantity_unit' , None ) quantity_unit_uid = None if quantity_unit is not None : if isinstance ( quantity_unit , str ) : quantity_unit_uid = getCategory ( quantity_unit , 'quantity_unit' ) if quantity_unit_uid is not None : result_column_id_dict [ 'converted_quantity' ] = None if metric_type is None : # use the default metric type metric_type = quantity_unit . split ( "/" , 1 ) [ 0 ] elif isinstance ( quantity_unit , ( int , float ) ) : # quantity_unit used to be a numerical parameter.. raise ValueError ( 'Numeric values for quantity_unit are not supported' ) convert_quantity_result = False if metric_type is not None : metric_type_uid = getCategory ( metric_type , 'metric_type' ) if metric_type_uid is not None : convert_quantity_result = True kw [ 'metric_type_uid' ] = Query ( metric_type_uid = metric_type_uid , table_alias_list = ( ( "measure" , "measure" ) , ) ) if src__ : sql_source_list = [ ] # If no group at all, give a default sort group by kw . update ( self . _getDefaultGroupByParameters ( * * kw ) ) base_inventory_kw = { 'stock_table_id' : default_stock_table , 'src__' : src__ , 'ignore_variation' : ignore_variation , 'standardise' : standardise , 'omit_simulation' : omit_simulation , 'only_accountable' : only_accountable , 'precision' : precision , 'inventory_list' : inventory_list , 'connection_id' : connection_id , 'statistic' : statistic , 'convert_quantity_result' : convert_quantity_result , 'quantity_unit_uid' : quantity_unit_uid , } # Get cached data if getattr ( self , "Resource_zGetInventoryCacheResult" , None ) is not None and optimisation__ and ( not kw . get ( 'from_date' ) ) and 'transformed_resource' not in kw : # Here is the different kind of date # from_date : >= # to_date   : < # at_date   : <= # As we just have from_date, it means that we must use # the to_date for the cache in order to avoid double computation # of the same line at_date = kw . pop ( "at_date" , None ) if at_date is None : to_date = kw . pop ( "to_date" , None ) else : # add one second so that we can use to_date to_date = at_date + MYSQL_MIN_DATETIME_RESOLUTION try : cached_result , cached_date = self . _getCachedInventoryList ( to_date = to_date , sql_kw = kw , * * base_inventory_kw ) except StockOptimisationError : cached_result = [ ] kw [ 'to_date' ] = to_date else : if src__ : sql_source_list . extend ( cached_result ) # Now must generate query for date diff kw [ 'to_date' ] = to_date kw [ 'from_date' ] = cached_date else : cached_result = [ ] sql_kw , new_kw = self . _generateKeywordDict ( * * kw ) # Copy kw content as _generateSQLKeywordDictFromKeywordDict # remove some values from it try : new_kw_copy = deepcopy ( new_kw ) except TypeError : # new_kw contains wrong parameters # as optimisation has already been disable we # do not care about the deepcopy new_kw_copy = new_kw stock_sql_kw = self . _generateSQLKeywordDictFromKeywordDict ( table = default_stock_table , sql_kw = sql_kw , new_kw = new_kw_copy ) stock_sql_kw . update ( base_inventory_kw ) delta_result = self . Resource_zGetInventoryList ( * * stock_sql_kw ) if src__ : sql_source_list . append ( delta_result ) result = ';\n-- NEXT QUERY\n' . join ( sql_source_list ) else : if cached_result : result = self . _addBrainResults ( delta_result , cached_result , new_kw ) else : result = delta_result return result