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
diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py
index 44dcd5f..0102edc 100644
--- a/erpnext/buying/doctype/supplier/supplier.py
+++ b/erpnext/buying/doctype/supplier/supplier.py
@@ -7,7 +7,7 @@
from frappe.utils import cint
from frappe import msgprint, _
-from frappe.model.doc import make_autoname
+from frappe.model.naming import make_autoname
from erpnext.accounts.party import create_party_account
from erpnext.utilities.transaction_base import TransactionBase
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 35234ce..3eac80f 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -121,17 +121,11 @@
from frappe.model import default_fields
tax_master = frappe.bean(tax_master_doctype, self.doc.fields.get(tax_master_field))
- for i, tax in enumerate(tax_master.doclist.get({"parentfield": tax_parentfield})):
+ for i, tax in enumerate(tax_master.get(tax_parentfield)):
for fieldname in default_fields:
- tax.fields[fieldname] = None
-
- tax.fields.update({
- "doctype": tax_doctype,
- "parentfield": tax_parentfield,
- "idx": i+1
- })
-
- self.doclist.append(tax)
+ tax.set(fieldname, None)
+
+ self.append(tax_parentfield, tax)
def get_other_charges(self):
self.set("other_charges", [])
@@ -410,9 +404,8 @@
self.set(parentfield, [])
for d in res:
- self.doclist.append({
+ self.append(parentfield, {
"doctype": child_doctype,
- "parentfield": parentfield,
"journal_voucher": d.jv_no,
"jv_detail_no": d.jv_detail_no,
"remarks": d.remark,
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 655b101..6392e58 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -230,7 +230,6 @@
for item in bom_items:
required_qty = flt(item.qty_consumed_per_unit) * flt(d.qty) * flt(d.conversion_factor)
rm_doclist = {
- "parentfield": raw_material_table,
"doctype": self.doc.doctype + " Item Supplied",
"reference_name": d.name,
"bom_detail_no": item.name,
@@ -248,7 +247,7 @@
"description": item.description,
})
- self.doclist.append(rm_doclist)
+ self.append(raw_material_table, rm_doclist)
raw_materials_cost += required_qty * flt(item.rate)
diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py
index 5e0ea65..a3d140b 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -59,9 +59,8 @@
shipping_amount = condition.shipping_amount
break
- self.doclist.append({
+ self.append("other_charges", {
"doctype": "Sales Taxes and Charges",
- "parentfield": "other_charges",
"charge_type": "Actual",
"account_head": shipping_rule.doc.account,
"cost_center": shipping_rule.doc.cost_center,
diff --git a/erpnext/home/__init__.py b/erpnext/home/__init__.py
index 2aae0b0..75fab1c 100644
--- a/erpnext/home/__init__.py
+++ b/erpnext/home/__init__.py
@@ -59,8 +59,7 @@
def make_feed(feedtype, doctype, name, owner, subject, color):
"makes a new Feed record"
#msgprint(subject)
- from frappe.model.doc import Document
- from frappe.utils import get_fullname
+ from frappe.utils import get_fullname
if feedtype in ('Login', 'Comment', 'Assignment'):
# delete old login, comment feed
@@ -72,7 +71,7 @@
where doc_type=%s and doc_name=%s
and ifnull(feed_type,'') != 'Comment'""", (doctype, name))
- f = Document('Feed')
+ f = frappe.get_doc('Feed')
f.owner = owner
f.feed_type = feedtype
f.doc_type = doctype
diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py
index aacb2aa..d6f1241 100644
--- a/erpnext/hr/doctype/employee/employee.py
+++ b/erpnext/hr/doctype/employee/employee.py
@@ -5,7 +5,7 @@
import frappe
from frappe.utils import getdate, validate_email_add, cstr, cint
-from frappe.model.doc import make_autoname
+from frappe.model.naming import make_autoname
from frappe import msgprint, throw, _
import frappe.permissions
from frappe.defaults import get_restrictions
diff --git a/erpnext/hr/doctype/holiday_list/holiday_list.py b/erpnext/hr/doctype/holiday_list/holiday_list.py
index c0f1b1b..80c1413 100644
--- a/erpnext/hr/doctype/holiday_list/holiday_list.py
+++ b/erpnext/hr/doctype/holiday_list/holiday_list.py
@@ -5,7 +5,7 @@
import frappe
from frappe.utils import add_days, add_years, cint, getdate
-from frappe.model.doc import make_autoname
+from frappe.model.naming import make_autoname
from frappe import msgprint, throw, _
import datetime
diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py
index 30f0cb7..cb8f77e 100644
--- a/erpnext/hr/doctype/leave_application/test_leave_application.py
+++ b/erpnext/hr/doctype/leave_application/test_leave_application.py
@@ -24,9 +24,8 @@
temp_session_user = frappe.session.user
frappe.set_user("Administrator")
employee = frappe.bean("Employee", employee)
- employee.doclist.append({
+ employee.append("employee_leave_approvers", {
"doctype": "Employee Leave Approver",
- "parentfield": "employee_leave_approvers",
"leave_approver": leave_approver
})
employee.save()
diff --git a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py
index f3aace2..bf91265 100644
--- a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py
+++ b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py
@@ -5,7 +5,6 @@
import frappe
from frappe.utils import cint, cstr, flt, nowdate
-from frappe.model.doc import Document
from frappe.model.code import get_obj
from frappe import msgprint, _
@@ -38,10 +37,9 @@
return e
def validate_values(self):
- meta = frappe.get_doctype(self.doc.doctype)
for f in ["fiscal_year", "leave_type", "no_of_days"]:
- if not self.doc.fields[f]:
- frappe.throw(_(meta.get_label(f)) + _(" is mandatory"))
+ if not self.get(f):
+ frappe.throw(_(self.meta.get_label(f)) + _(" is mandatory"))
def allocate_leave(self):
self.validate_values()
@@ -52,7 +50,8 @@
for d in self.get_employees():
try:
- la = Document('Leave Allocation')
+ la = frappe.get_doc('Leave Allocation')
+ la.set("__islocal", 1)
la.employee = cstr(d[0])
la.employee_name = frappe.db.get_value('Employee',cstr(d[0]),'employee_name')
la.leave_type = self.doc.leave_type
@@ -60,11 +59,8 @@
la.posting_date = nowdate()
la.carry_forward = cint(self.doc.carry_forward)
la.new_leaves_allocated = flt(self.doc.no_of_days)
- la_obj = get_obj(doc=la)
- la_obj.doc.docstatus = 1
- la_obj.validate()
- la_obj.on_update()
- la_obj.doc.save(1)
+ la.docstatus = 1
+ la.save()
leave_allocated_for.append(d[0])
except:
pass
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index a7c4f8d..e167835 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -5,7 +5,7 @@
import frappe
from frappe.utils import add_days, cint, cstr, flt, getdate, nowdate, _round
-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, _
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py
index ae10394..ab73a09 100644
--- a/erpnext/hr/doctype/salary_structure/salary_structure.py
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.py
@@ -5,7 +5,7 @@
import frappe
from frappe.utils import cstr, flt
-from frappe.model.doc import make_autoname
+from frappe.model.naming import make_autoname
from frappe import msgprint, _
diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.py b/erpnext/hr/doctype/upload_attendance/upload_attendance.py
index 844806e..8a54415 100644
--- a/erpnext/hr/doctype/upload_attendance/upload_attendance.py
+++ b/erpnext/hr/doctype/upload_attendance/upload_attendance.py
@@ -120,7 +120,7 @@
error = False
from frappe.utils.datautils import check_record, import_doc
- doctype_dl = frappe.get_doctype("Attendance")
+ doctype_dl = frappe.get_meta("Attendance")
for i, row in enumerate(rows[5:]):
if not row: continue
@@ -131,7 +131,7 @@
d["docstatus"] = frappe.db.get_value("Attendance", d.name, "docstatus")
try:
- check_record(d, doctype_dl=doctype_dl)
+ check_record(d)
ret.append(import_doc(d, "Attendance", 1, row_idx, submit=True))
except Exception, e:
error = True
diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
index 89fafbc..9f14b2c 100644
--- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
+++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
@@ -366,7 +366,7 @@
if items_to_be_requested:
for item in items_to_be_requested:
item_wrapper = frappe.bean("Item", item)
- pr_doclist = [{
+ pr_doc = frappe.get_doc({
"doctype": "Material Request",
"__islocal": 1,
"naming_series": "IDT",
@@ -376,12 +376,11 @@
"fiscal_year": fiscal_year,
"requested_by": frappe.session.user,
"material_request_type": "Purchase"
- }]
+ })
for sales_order, requested_qty in items_to_be_requested[item].items():
- pr_doclist.append({
+ pr_doc.append("indent_details", {
"doctype": "Material Request Item",
"__islocal": 1,
- "parentfield": "indent_details",
"item_code": item,
"item_name": item_wrapper.doc.item_name,
"description": item_wrapper.doc.description,
@@ -394,10 +393,9 @@
"sales_order_no": sales_order if sales_order!="No Sales Order" else None
})
- pr_wrapper = frappe.bean(pr_doclist)
- pr_wrapper.ignore_permissions = 1
- pr_wrapper.submit()
- purchase_request_list.append(pr_wrapper.doc.name)
+ pr_doc.ignore_permissions = 1
+ pr_doc.submit()
+ purchase_request_list.append(pr_doc.name)
if purchase_request_list:
pur_req = ["""<a href="#Form/Material Request/%s" target="_blank">%s</a>""" % \
diff --git a/erpnext/patches/4_0/update_user_properties.py b/erpnext/patches/4_0/update_user_properties.py
index 6dac125..262f7b8 100644
--- a/erpnext/patches/4_0/update_user_properties.py
+++ b/erpnext/patches/4_0/update_user_properties.py
@@ -39,7 +39,7 @@
doctype_matches.setdefault(doctype, []).append(match)
for doctype, user_matches in doctype_matches.items():
- meta = frappe.get_doctype(doctype)
+ meta = frappe.get_meta(doctype)
# for each user with roles of this doctype, check if match condition applies
for user in frappe.db.sql_list("""select name from `tabUser`
diff --git a/erpnext/projects/doctype/time_log/test_time_log.py b/erpnext/projects/doctype/time_log/test_time_log.py
index b6e2741..973e89b 100644
--- a/erpnext/projects/doctype/time_log/test_time_log.py
+++ b/erpnext/projects/doctype/time_log/test_time_log.py
@@ -8,7 +8,7 @@
class TestTimeLog(unittest.TestCase):
def test_duplication(self):
- ts = frappe.bean(frappe.copy_doclist(test_records[0]))
+ ts = frappe.bean(frappe.copy_doc(test_records[0]))
self.assertRaises(OverlapError, ts.insert)
test_records = [[{
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index 1fc2613..1ab827d 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -3,7 +3,7 @@
from __future__ import unicode_literals
import frappe
-from frappe.model.doc import Document, make_autoname
+from frappe.model.naming import make_autoname
from frappe import msgprint, _
import frappe.defaults
@@ -56,7 +56,8 @@
(self.doc.name, self.doc.customer_name, self.doc.lead_name))
lead = frappe.db.get_value("Lead", self.doc.lead_name, ["lead_name", "email_id", "phone", "mobile_no"], as_dict=True)
- c = Document('Contact')
+ c = frappe.get_doc('Contact')
+ c.set("__islocal", 1)
c.first_name = lead.lead_name
c.email_id = lead.email_id
c.phone = lead.phone
@@ -65,7 +66,7 @@
c.customer_name = self.doc.customer_name
c.is_primary_contact = 1
try:
- c.save(1)
+ c.save()
except NameError, e:
pass
diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py
index e325aeb..869350c 100644
--- a/erpnext/selling/doctype/sales_order/test_sales_order.py
+++ b/erpnext/selling/doctype/sales_order/test_sales_order.py
@@ -80,7 +80,7 @@
_insert_purchase_receipt(so.doclist[1].item_code)
- dn = frappe.bean(frappe.copy_doclist(dn_test_records[0]))
+ dn = frappe.bean(frappe.copy_doc(dn_test_records[0]))
dn.doclist[1].item_code = so.doclist[1].item_code
dn.doclist[1].against_sales_order = so.doc.name
dn.doclist[1].prevdoc_detail_docname = so.doclist[1].name
@@ -199,7 +199,7 @@
# change item in test so record
- test_record = frappe.copy_doclist(test_records[0])
+ test_record = frappe.copy_doc(test_records[0])
test_record[1]["item_code"] = "_Test Sales BOM Item"
# reset bin
@@ -248,7 +248,7 @@
from erpnext.selling.doctype.sales_bom.test_sales_bom import test_records as sbom_test_records
# change item in test so record
- test_record = frappe.copy_doclist(test_records[0])
+ test_record = frappe.copy_doc(test_records[0])
test_record[1]["item_code"] = "_Test Sales BOM Item"
# reset bin
diff --git a/erpnext/selling/page/sales_browser/sales_browser.py b/erpnext/selling/page/sales_browser/sales_browser.py
index e53515c..42839f3 100644
--- a/erpnext/selling/page/sales_browser/sales_browser.py
+++ b/erpnext/selling/page/sales_browser/sales_browser.py
@@ -21,8 +21,7 @@
@frappe.whitelist()
def add_node():
- # from frappe.model.doc import Document
- ctype = frappe.form_dict.get('ctype')
+ # ctype = frappe.form_dict.get('ctype')
parent_field = 'parent_' + ctype.lower().replace(' ', '_')
name_field = ctype.lower().replace(' ', '_') + '_name'
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index 9c98068..a7e884e 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -86,15 +86,13 @@
website_settings.doc.home_page = webpage.doc.name
website_settings.doc.brand_html = self.doc.name
website_settings.doc.copyright = self.doc.name
- website_settings.doclist.append({
+ website_settings.append("top_bar_items", {
"doctype": "Top Bar Item",
- "parentfield": "top_bar_items",
"label":"Contact",
"url": "contact"
})
- website_settings.doclist.append({
+ website_settings.append("top_bar_items", {
"doctype": "Top Bar Item",
- "parentfield": "top_bar_items",
"label":"Blog",
"url": "blog"
})
diff --git a/erpnext/setup/doctype/naming_series/naming_series.py b/erpnext/setup/doctype/naming_series/naming_series.py
index 454b38a..d1608fc 100644
--- a/erpnext/setup/doctype/naming_series/naming_series.py
+++ b/erpnext/setup/doctype/naming_series/naming_series.py
@@ -56,26 +56,27 @@
default = options[0]
# update in property setter
- from frappe.model.doc import Document
- prop_dict = {'options': "\n".join(options), 'default': default}
+ prop_dict = {'options': "\n".join(options), 'default': default}
for prop in prop_dict:
ps_exists = frappe.db.sql("""SELECT name FROM `tabProperty Setter`
WHERE doc_type = %s AND field_name = 'naming_series'
AND property = %s""", (doctype, prop))
if ps_exists:
- ps = Document('Property Setter', ps_exists[0][0])
+ ps = frappe.get_doc('Property Setter', ps_exists[0][0])
ps.value = prop_dict[prop]
ps.save()
else:
- ps = Document('Property Setter', fielddata = {
+ ps = frappe.get_doc({
+ 'doctype': 'Property Setter',
'doctype_or_field': 'DocField',
'doc_type': doctype,
'field_name': 'naming_series',
'property': prop,
'value': prop_dict[prop],
'property_type': 'Select',
+ '__islocal': 1
})
- ps.save(1)
+ ps.save()
self.doc.set_options = "\n".join(options)
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 3a20d8c..2074925 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -18,7 +18,7 @@
def autoname(self):
if frappe.db.get_default("item_naming_by")=="Naming Series":
- from frappe.model.doc import make_autoname
+ from frappe.model.naming import make_autoname
self.doc.item_code = make_autoname(self.doc.naming_series+'.#####')
elif not self.doc.item_code:
msgprint(_("Item Code (item_code) is mandatory because Item naming is not sequential."), raise_exception=1)
@@ -272,7 +272,7 @@
"in Item master") % {
"item_code": item_code,
"date": formatdate(end_of_life),
- "end_of_life_label": frappe.get_doctype("Item").get_label("end_of_life")
+ "end_of_life_label": frappe.get_meta("Item").get_label("end_of_life")
}
_msgprint(msg, verbose)
diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py
index c05a8d8..fda6849 100644
--- a/erpnext/stock/doctype/material_request/material_request.py
+++ b/erpnext/stock/doctype/material_request/material_request.py
@@ -177,7 +177,7 @@
for mr_name, mr_items in material_request_map.items():
mr_obj = frappe.get_obj("Material Request", mr_name, with_children=1)
- mr_doctype = frappe.get_doctype("Material Request")
+ mr_doctype = frappe.get_meta("Material Request")
if mr_obj.doc.status in ["Stopped", "Cancelled"]:
frappe.throw(_("Material Request") + ": %s, " % mr_obj.doc.name
diff --git a/erpnext/stock/doctype/price_list/price_list.py b/erpnext/stock/doctype/price_list/price_list.py
index 420c6c5..bf49a51 100644
--- a/erpnext/stock/doctype/price_list/price_list.py
+++ b/erpnext/stock/doctype/price_list/price_list.py
@@ -16,9 +16,8 @@
if not self.get("valid_for_territories"):
# if no territory, set default territory
if frappe.defaults.get_user_default("territory"):
- self.doclist.append({
+ self.append("valid_for_territories", {
"doctype": "Applicable Territory",
- "parentfield": "valid_for_territories",
"territory": frappe.defaults.get_user_default("territory")
})
else:
diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py
index d8bdb77..50b1d00 100644
--- a/erpnext/stock/doctype/serial_no/serial_no.py
+++ b/erpnext/stock/doctype/serial_no/serial_no.py
@@ -254,7 +254,7 @@
def update_serial_nos(sle, item_det):
if sle.is_cancelled == "No" and not sle.serial_no and sle.actual_qty > 0 and item_det.serial_no_series:
- from frappe.model.doc import make_autoname
+ from frappe.model.naming import make_autoname
serial_nos = []
for i in xrange(cint(sle.actual_qty)):
serial_nos.append(make_autoname(item_det.serial_no_series))
diff --git a/erpnext/stock/doctype/stock_ledger/stock_ledger.py b/erpnext/stock/doctype/stock_ledger/stock_ledger.py
index 452ad35..966e7ab 100644
--- a/erpnext/stock/doctype/stock_ledger/stock_ledger.py
+++ b/erpnext/stock/doctype/stock_ledger/stock_ledger.py
@@ -5,7 +5,6 @@
import frappe
from frappe.utils import add_days, cstr, flt, nowdate, cint, now
-from frappe.model.doc import Document
from frappe.model.bean import getlist
from frappe.model.code import get_obj
from frappe import session, msgprint
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 8bfc083..3cd49d9 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -158,7 +158,7 @@
return out
def get_price_list_rate(args, item_bean, out):
- meta = frappe.get_doctype(args.doctype)
+ meta = frappe.get_meta(args.doctype)
if meta.get_field("currency"):
validate_price_list(args)
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index 822c8f2..4628b5b 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -116,7 +116,7 @@
# rounding as per precision
from frappe.model.meta import get_field_precision
- meta = frappe.get_doctype("Stock Ledger Entry")
+ meta = frappe.get_meta("Stock Ledger Entry")
stock_value = flt(stock_value, get_field_precision(meta.get_field("stock_value"),
frappe._dict({"fields": sle})))
diff --git a/erpnext/support/doctype/support_email_settings/support_email_settings.py b/erpnext/support/doctype/support_email_settings/support_email_settings.py
index 65edf23..011a943 100644
--- a/erpnext/support/doctype/support_email_settings/support_email_settings.py
+++ b/erpnext/support/doctype/support_email_settings/support_email_settings.py
@@ -16,11 +16,10 @@
"""
if self.doc.sync_support_mails and self.doc.mail_server:
from frappe.utils.email_lib.receive import POP3Mailbox
- from frappe.model.doc import Document
- import _socket, poplib
+ import _socket, poplib
- inc_email = Document('Incoming Email Settings')
- inc_email.encode()
+ inc_email = frappe.get_doc('Incoming Email Settings')
+ # inc_email.encode()
inc_email.host = self.doc.mail_server
inc_email.use_ssl = self.doc.use_ssl
try:
diff --git a/erpnext/utilities/doctype/address/address.py b/erpnext/utilities/doctype/address/address.py
index b698658..778451b 100644
--- a/erpnext/utilities/doctype/address/address.py
+++ b/erpnext/utilities/doctype/address/address.py
@@ -56,7 +56,7 @@
if not isinstance(address_dict, dict):
address_dict = frappe.db.get_value("Address", address_dict, "*", as_dict=True) or {}
- meta = frappe.get_doctype("Address")
+ meta = frappe.get_meta("Address")
sequence = (("", "address_line1"),
("\n", "address_line2"),
("\n", "city"),
diff --git a/erpnext/utilities/doctype/sms_control/sms_control.py b/erpnext/utilities/doctype/sms_control/sms_control.py
index b160ad9..3a23558 100644
--- a/erpnext/utilities/doctype/sms_control/sms_control.py
+++ b/erpnext/utilities/doctype/sms_control/sms_control.py
@@ -6,7 +6,6 @@
from frappe.utils import nowdate, cstr
from frappe.model.code import get_obj
-from frappe.model.doc import Document
from frappe import msgprint, throw, _
from frappe.model.bean import getlist
@@ -109,11 +108,11 @@
# Create SMS Log
# =========================================================
def create_sms_log(self, arg, sent_sms):
- sl = Document('SMS Log')
+ sl = frappe.get_doc('SMS Log')
sl.sender_name = arg['sender_name']
sl.sent_on = nowdate()
sl.receiver_list = cstr(arg['receiver_list'])
sl.message = arg['message']
sl.no_of_requested_sms = len(arg['receiver_list'])
sl.no_of_sent_sms = sent_sms
- sl.save(new=1)
+ sl.save()
diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py
index 11dfc52..ee78ced 100644
--- a/erpnext/utilities/transaction_base.py
+++ b/erpnext/utilities/transaction_base.py
@@ -36,7 +36,7 @@
opts = frappe._dict(opts)
if self.doc.contact_date:
- event_doclist = [{
+ event_doclist = frappe.get_doc({
"doctype": "Event",
"owner": opts.owner or self.doc.owner,
"subject": opts.subject,
@@ -45,16 +45,15 @@
"event_type": "Private",
"ref_type": self.doc.doctype,
"ref_name": self.doc.name
- }]
+ })
if frappe.db.exists("User", self.doc.contact_by):
- event_doclist.append({
+ event_doclist.append("event_individuals", {
"doctype": "Event User",
- "parentfield": "event_individuals",
"person": self.doc.contact_by
})
- frappe.bean(event_doclist).insert()
+ event_doclist.insert()
def validate_uom_is_integer(self, uom_field, qty_fields):
validate_uom_is_integer(self.doclist, uom_field, qty_fields)