Hi,
I have an external data source for Journal Entries. I am trying to get a python script in a custom app to read in this data, insert it into the Journal Entry table, and submit them. I’ve gotten as far as this (jeac variables are Journal Entry Account - credit, jead variables are Journal Entry Account - debit and je variables are Journal Entries).
It’s failing with the error “frappe.exceptions.ValidationError: Accounts table cannot be blank.” for a good reason: I can’t figure out how to attach accounts to the journal entry inside the script. Can anyone help?
jead_values_dict = {'name':jead_name,
'creation':jead_creation,
'modified':jead_modified,
'modified_by':jead_modified_by,
'owner':jead_owner,
'docstatus':jead_docstatus,
'parent':jead_parent,
'parentfield':jead_parentfield,
'parenttype':jead_parenttype,
'idx':jead_idx,
'account':jead_account,
'credit':jead_credit,
'party_balance':jead_party_balance,
'against_account':jead_against_account,
'is_advance':jead_is_advance,
'debit':jead_debit,
'debit_in_account_currency':jead_debit_in_account_currency,
'cost_center':jead_cost_center,
'balance':jead_balance,
'exchange_rate':jead_exchange_rate,
'account_type':jead_account_type,
'debit_in_account':jead_debit_in_account,
'currency':jead_currency,
'account_currency':jead_account_currency,
'credit_in_account_currency':jead_credit_in_account_currency,
'company':jead_company}
jeac_values_dict = {'name':jeac_name,
'creation':jeac_creation,
'modified':jeac_modified,
'modified_by':jeac_modified_by,
'owner':jeac_owner,
'docstatus':jeac_docstatus,
'parent':jeac_parent,
'parentfield':jeac_parentfield,
'parenttype':jeac_parenttype,
'idx':jeac_idx,
'account':jeac_account,
'credit':jeac_credit,
'party_balance':jeac_party_balance,
'against_account':jeac_against_account,
'is_advance':jeac_is_advance,
'debit':jeac_debit,
'debit_in_account_currency':jeac_debit_in_account_currency,
'cost_center':jeac_cost_center,
'balance':jeac_balance,
'exchange_rate':jeac_exchange_rate,
'account_type':jeac_account_type,
'debit_in_account':jeac_debit_in_account,
'currency':jeac_currency,
'account_currency':jeac_account_currency,
'credit_in_account_currency':jeac_credit_in_account_currency,
'company':jead_company}
je_values_dict = {"doctype":"Journal Entry",
"name": je_name,
"creation":je_creation,
"modified":je_modified,
"cheque_date":je_cheque_date,
"modified_by":je_modified_by,
"owner":je_owner,
"docstatus":je_docstatus,
"idx":je_idx,
"write_off_amount":je_write_off_amount,
"naming_series":je_naming_series,
"voucher_type":je_voucher_type,
"letter_head":je_letter_head,
"cheque_no":je_cheque_no,
"bill_no":je_bill_no,
"difference":je_difference,
"title":je_title,
"total_amount_in_words":je_total_amount_in_words,
"company":je_company,
"fiscal_year":je_fiscal_year,
"total_credit":je_total_credit,
"user_remark":je_user_remark,
"remark":je_remark,
"total_amount":je_total_amount,
"write_off_based_on":je_write_off_based_on,
"total_debit":je_total_debit,
"is_opening":je_is_opening,
"posting_date":je_posting_date,
"multi_currency":je_multi_currency,
"budgeting_account":je_budgeting_account}
record = frappe.get_doc(je_values_dict)
#record.append("accounts", {jeac_values_dict,jead_values_dict}) - Fails due to dict hashing error. Not sure how else to do this.
record.insert()
record.submit()