frappe/frappe#478
diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
index 9884b57..5727ed4 100644
--- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
+++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
@@ -389,19 +389,12 @@
jv.doc.company = doc.company
jv.doc.fiscal_year = doc.fiscal_year
- jv.doclist.append({
- "doctype": "Journal Voucher Detail",
- "parentfield": "entries"
- })
+ d1 = jv.append("entries")
+ d2 = jv.append("entries")
- jv.doclist.append({
- "doctype": "Journal Voucher Detail",
- "parentfield": "entries"
- })
-
if bank_account:
- jv.doclist[2].account = bank_account["account"]
- jv.doclist[2].balance = bank_account["balance"]
+ d2.account = bank_account["account"]
+ d2.balance = bank_account["balance"]
return jv
diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index 28bd2d1..c648c37 100644
--- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -174,9 +174,7 @@
jv.submit()
pi = frappe.bean(copy=test_records[0])
- pi.doclist.append({
- "doctype": "Purchase Invoice Advance",
- "parentfield": "advance_allocation_details",
+ pi.append("advance_allocation_details", {
"journal_voucher": jv.doc.name,
"jv_detail_no": jv.doclist[1].name,
"advance_amount": 400,
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 068d82c..c61df0e 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -9,7 +9,7 @@
get_first_day, get_last_day
from frappe.utils import comma_and, get_url
-from frappe.model.doc import make_autoname
+from frappe.model.naming import make_autoname
from frappe.model.bean import getlist
from frappe.model.code import get_obj
from frappe import _, msgprint
@@ -587,12 +587,6 @@
invoice_date = %s, territory = %s, net_total = %s,
grand_total = %s where invoice_no = %s and parent = %s""",
(self.doc.name, self.doc.amended_from, self.doc.c_form_no))
-
- @property
- def meta(self):
- if not hasattr(self, "_meta"):
- self._meta = frappe.get_doctype(self.doc.doctype)
- return self._meta
def validate_recurring_invoice(self):
if self.doc.convert_into_recurring_invoice:
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index a4a1f7b..1c67e71 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -139,16 +139,14 @@
def test_sales_invoice_discount_amount(self):
si = frappe.bean(copy=test_records[3])
si.doc.discount_amount = 104.95
- si.doclist.append({
+ si.append("other_charges", {
"doctype": "Sales Taxes and Charges",
- "parentfield": "other_charges",
"charge_type": "On Previous Row Amount",
"account_head": "_Test Account Service Tax - _TC",
"cost_center": "_Test Cost Center - _TC",
"description": "Service Tax",
"rate": 10,
"row_id": 8,
- "idx": 9
})
si.insert()
@@ -196,16 +194,14 @@
def test_discount_amount_gl_entry(self):
si = frappe.bean(copy=test_records[3])
si.doc.discount_amount = 104.95
- si.doclist.append({
+ si.append("other_charges", {
"doctype": "Sales Taxes and Charges",
- "parentfield": "other_charges",
"charge_type": "On Previous Row Amount",
"account_head": "_Test Account Service Tax - _TC",
"cost_center": "_Test Cost Center - _TC",
"description": "Service Tax",
"rate": 10,
- "row_id": 8,
- "idx": 9
+ "row_id": 8
})
si.insert()
si.submit()
@@ -369,7 +365,7 @@
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
import test_records as jv_test_records
- jv = frappe.bean(frappe.copy_doclist(jv_test_records[0]))
+ jv = frappe.bean(frappe.copy_doc(jv_test_records[0]))
jv.doclist[1].against_invoice = w.doc.name
jv.insert()
jv.submit()
@@ -385,7 +381,7 @@
tlb = frappe.bean("Time Log Batch", "_T-Time Log Batch-00001")
tlb.submit()
- si = frappe.bean(frappe.copy_doclist(test_records[0]))
+ si = frappe.bean(frappe.copy_doc(test_records[0]))
si.doclist[1].time_log_batch = "_T-Time Log Batch-00001"
si.insert()
si.submit()
@@ -444,7 +440,7 @@
self._insert_purchase_receipt()
self._insert_pos_settings()
- pos = frappe.copy_doclist(test_records[1])
+ pos = frappe.copy_doc(test_records[1])
pos[0]["is_pos"] = 1
pos[0]["update_stock"] = 1
pos[0]["posting_time"] = "12:05"
@@ -510,7 +506,7 @@
pr.insert()
pr.submit()
- si_doclist = frappe.copy_doclist(test_records[1])
+ si_doclist = frappe.copy_doc(test_records[1])
si_doclist[0]["update_stock"] = 1
si_doclist[0]["posting_time"] = "12:05"
si_doclist[1]["warehouse"] = "_Test Warehouse No Account - _TC"
@@ -555,7 +551,7 @@
self.clear_stock_account_balance()
set_perpetual_inventory()
- si_copy = frappe.copy_doclist(test_records[1])
+ si_copy = frappe.copy_doc(test_records[1])
si_copy[1]["item_code"] = None
si = frappe.bean(si_copy)
si.insert()
@@ -582,7 +578,7 @@
def test_sales_invoice_gl_entry_with_aii_non_stock_item(self):
self.clear_stock_account_balance()
set_perpetual_inventory()
- si_copy = frappe.copy_doclist(test_records[1])
+ si_copy = frappe.copy_doc(test_records[1])
si_copy[1]["item_code"] = "_Test Non Stock Item"
si = frappe.bean(si_copy)
si.insert()
@@ -640,9 +636,8 @@
jv.submit()
si = frappe.bean(copy=test_records[0])
- si.doclist.append({
+ si.append("advance_adjustment_details", {
"doctype": "Sales Invoice Advance",
- "parentfield": "advance_adjustment_details",
"journal_voucher": jv.doc.name,
"jv_detail_no": jv.doclist[1].name,
"advance_amount": 400,
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 3805ec3..260344c 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -242,7 +242,7 @@
if not value:
throw(_("Please mention default value for '") +
- _(frappe.get_doctype("company").get_label(fieldname) +
+ _(frappe.get_meta("Company").get_label(fieldname) +
_("' in Company: ") + company))
return value