def form_valid(self, form): form.instance.parent = self.parent_transaction form.instance.category = ExpenseCategory.get_commission() form.instance.account = self.parent_transaction.account form.instance.direction = Transaction.DIRECTION_OUT form.instance.bill_date = self.parent_transaction.bill_date return super(CommissionAddView, self).form_valid(form)
def form_valid(self, form): form.instance.created_by = self.request.user form.instance.category = ExpenseCategory.get_transfer() form.instance.direction = Transaction.DIRECTION_OUT response = super(TransferAddView, self).form_valid(form) Transaction.create_acceptor(self.object, form.cleaned_data['account_dst']) return response
def form_valid(self, form): form.instance.category = ExpenseCategory.get_payment() form.instance.direction = Transaction.DIRECTION_OUT form.instance.person = self.person return super(PaymentAddView, self).form_valid(form)
from core.models import Account, IncomeCategory, ExpenseCategory import json with open('data.json', 'r') as file: data = json.load(file) for acc in data['account']: account = Account(name=acc['name']) account.save() for in_c in data['incomeCategory']: incomeCategory = IncomeCategory(name=in_c['name']) incomeCategory.save() for ex_c in data['expenseCategory']: expenseCategory = ExpenseCategory(name=ex_c['name']) expenseCategory.save()