def columns(self): div = lambda x, y: "%0.3f" % (float(x) / (float(y) or 1.0)) columns = [] if 'region_id' in self.config: columns.append(DatabaseColumn(_("District"), SimpleColumn('district_name'))) else: columns.append(DatabaseColumn(_("PPS"), SimpleColumn('PPS_name'))) columns.append(DatabaseColumn(_("Quantite produits entreposes au PPS"), MeanColumn('quantity_total', alias="quantity"), format_fn=self.format_data_and_cast_to_float)) columns.append(DatabaseColumn(_("CMM"), MeanColumn('cmm_total', alias="cmm"), format_fn=self.format_data_and_cast_to_float)) columns.append(AggregateColumn(_("Nombre mois stock disponible et utilisable"), div, [AliasColumn('quantity'), AliasColumn('cmm')])) return columns
def columns(self): columns = [] if 'region_id' in self.config: columns.append(DatabaseColumn(_("District"), SimpleColumn('district_name'))) else: columns.append(DatabaseColumn(_("PPS"), SimpleColumn('PPS_name'))) columns.append(DatabaseColumn(_("Consommation reelle"), MeanColumn('actual_consumption_total', alias="consumption"), format_fn=self.format_data_and_cast_to_float)) columns.append(DatabaseColumn(_("Stock apres derniere livraison"), MeanColumn('stock_total', alias="stock"), format_fn=self.format_data_and_cast_to_float)) columns.append(AggregateColumn(_("Taux consommation"), self.percent_fn, [AliasColumn('stock'), AliasColumn('consumption')])) return columns