Trying to create a new Journal Entry using frappe.get_doc

hi all , i’m trying to create a new Journal Entry using frappe.get_doc and this is my backend code

def insert_new_journal_entry_fees(R_account,P_Account,student_sys_number,amount):

    doc = frappe.get_doc({

        'doctype': 'Journal Entry',

    })

    doc.append("Journal Entry Account", {

                "Account" : R_account , 

                "party_type" : 'Student',

                "party" : student_sys_number,

                "credit_in_account_currency" : int(amount)

                })

    doc.append("Journal Entry Account", {

                "Account" : P_Account , 

                "party_type" : 'Student',

                "party" : student_sys_number,

                "debit_in_account_currency" : int(amount)

                })

    doc.save(ignore_permissions=True)

    doc.submit()

    frappe.db.commit()

and i got this error

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 60, in application
    response = frappe.api.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 22, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 61, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1042, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/education/api.py", line 191, in insert_new_journal_entry_fees
    "credit_in_account_currency" : int(amount)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 149, in append
    value = self._init_child(value, key)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 184, in _init_child
    value["doctype"] = self.get_table_field_doctype(key)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 298, in get_table_field_doctype
    return self.meta.get_field(fieldname).options
AttributeError: 'NoneType' object has no attribute 'options'
1 Like

i’m also tried this :

jv = frappe.new_doc('Journal Entry')

    jv.voucher_type = 'Journal Entry'

    jv.naming_series = 'ACC-JV-.YYYY.-'

    jv.posting_date = '2020-11-22'

    jv.company = 'demo company'

    jv.remark = 'test'

    #Entry for Customer

    jv.append('Journal Entry Account', {

    'account': R_account ,

    'party_type' : 'Student',

    'party' : student_sys_number,

    'credit' : flt(amount),

    'debit' : flt(0),

    'debit_in_account_currency' : flt(0),

    'credit_in_account_currency' : flt(amount)

    })

    #Entry for Supplier

    jv.append('Journal Entry Account', {

    'account': P_Account ,

    'party_type' : 'Student',

    'party' : student_sys_number,

    'debit' : flt(amount),

    'credit' : flt(0),

    'credit_in_account_currency' : flt(0),

    'debit_in_account_currency' : flt(amount)

    })

    jv.save()

    jv.submit()

but i got the same issue

Use

jv.append('accounts', {

instead of

 jv.append('Journal Entry Account', {
1 Like