def downgrade(): for p in PaymentMode.query(): DBSESSION().delete(p) for p in Payment.query(): if p.mode == u"par chèque": p.mode = u"cheque" elif p.mode == u"par virement": p.mode = u"virement" elif p.mode == u"en liquide": p.mode = u"liquide" else: p.mode = "inconnu" DBSESSION().merge(p)
def downgrade(): from autonomie.models.task.invoice import PaymentMode, Payment for p in PaymentMode.query(): DBSESSION().delete(p) for p in Payment.query(): if p.mode == u"par chèque": p.mode = u"cheque" elif p.mode == u"par virement": p.mode = u"virement" elif p.mode == u"en liquide": p.mode = u"liquide" else: p.mode = "inconnu" DBSESSION().merge(p)
def upgrade(): for payment in Payment.query(): if payment.mode in (u"cheque", u"CHEQUE"): payment.mode = u"par chèque" elif payment.mode in (u"virement", u"VIREMENT"): payment.mode = u"par virement" elif payment.mode in (u"liquide", u"LIQUIDE"): payment.mode = u"en liquide" else: payment.mode = "mode de paiement inconnu" DBSESSION().merge(payment) for mode in (u"par chèque", u"par virement", u"en liquide"): pmode = PaymentMode(label=mode) DBSESSION().add(pmode)