mirror of https://github.com/nanoy42/coope
5 changed files with 55 additions and 5 deletions
@ -0,0 +1,34 @@ |
|||
# Generated by Django 2.1 on 2019-06-23 14:56 |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
def update(apps, schema_editor): |
|||
User = apps.get_model('auth', 'User') |
|||
ConsumptionHistory = apps.get_model('gestion', 'ConsumptionHistory') |
|||
for u in User.objects.all(): |
|||
chs = ConsumptionHistory.objects.filter(customer=u).filter(paymentMethod__affect_balance=False) |
|||
u.profile.direct_debit = sum([x.amount for x in chs]) |
|||
u.profile.save() |
|||
|
|||
def reverse(apps, schema_editor): |
|||
pass |
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('users', '0009_auto_20190623_1437'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='historicalprofile', |
|||
name='direct_debit', |
|||
field=models.DecimalField(decimal_places=2, default=0, max_digits=7, verbose_name='Débit (non compte)'), |
|||
), |
|||
migrations.AddField( |
|||
model_name='profile', |
|||
name='direct_debit', |
|||
field=models.DecimalField(decimal_places=2, default=0, max_digits=7, verbose_name='Débit (non compte)'), |
|||
), |
|||
migrations.RunPython(update, reverse) |
|||
] |
|||
Loading…
Reference in new issue