From 2860fe931c4afa70dc76130c474cd7f07ba84f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Sun, 18 Oct 2015 18:19:58 +0200 Subject: [PATCH] Permet le tri par fid ou aid pour les factures. --- tresorerie/controle_rapide.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tresorerie/controle_rapide.py b/tresorerie/controle_rapide.py index 01b4f4b5..2e99f490 100755 --- a/tresorerie/controle_rapide.py +++ b/tresorerie/controle_rapide.py @@ -105,9 +105,14 @@ def traiter_factures(ldap, args): while True: # On trie les factures par fid en ordre décroissant. - controle_ok.sort(cmp=lambda x, y: cmp(int(x['fid'][0]), int(y['fid'][0])), reverse=True) - controle_non.sort(cmp=lambda x, y: cmp(int(x['fid'][0]), int(y['fid'][0])), reverse=True) - sans_controle.sort(cmp=lambda x, y: cmp(int(x['fid'][0]), int(y['fid'][0])), reverse=True) + if args.tri == 'fid': + controle_ok.sort(cmp=lambda x, y: cmp(int(x['fid'][0]), int(y['fid'][0])), reverse=True) + controle_non.sort(cmp=lambda x, y: cmp(int(x['fid'][0]), int(y['fid'][0])), reverse=True) + sans_controle.sort(cmp=lambda x, y: cmp(int(x['fid'][0]), int(y['fid'][0])), reverse=True) + else: + controle_ok.sort(cmp=lambda x, y: cmp(int(x.proprio()._id()[0]), int(y.proprio()._id()[0])), reverse=True) + controle_non.sort(cmp=lambda x, y: cmp(int(x.proprio()._id()[0]), int(y.proprio()._id()[0])), reverse=True) + sans_controle.sort(cmp=lambda x, y: cmp(int(x.proprio()._id()[0]), int(y.proprio()._id()[0])), reverse=True) # Menu principal (code, tag) = dialog_interface.menu( @@ -403,6 +408,7 @@ if __name__ == '__main__': PARSER.add_argument("-l", "--last", help="Date de début, dans un format compréhensible par postgresql (\"AAAA/MM/JJ HH:MM:SS\" fonctionne bien)", type=str, action="store") PARSER.add_argument("-m", "--mode", help="Filtre sur le mode de paiement", type=str, action="store") PARSER.add_argument("-h", "--help", help="Affiche cette aide et quitte.", action="store_true") + PARSER.add_argument("-t", "--tri", help="Trie les factures suivant l'aid ou le fid", type=str, action="store") ARGS = PARSER.parse_args() LDAP = shortcuts.lc_ldap_admin()