This commit is contained in:
Rushabh Mehta 2014-03-27 17:51:41 +05:30
parent d2b34dc30c
commit e88bc8b12a
36 changed files with 81 additions and 124 deletions

View File

@ -389,19 +389,12 @@ def get_payment_entry(doc):
jv.doc.company = doc.company jv.doc.company = doc.company
jv.doc.fiscal_year = doc.fiscal_year jv.doc.fiscal_year = doc.fiscal_year
jv.doclist.append({ d1 = jv.append("entries")
"doctype": "Journal Voucher Detail", d2 = jv.append("entries")
"parentfield": "entries"
})
jv.doclist.append({
"doctype": "Journal Voucher Detail",
"parentfield": "entries"
})
if bank_account: if bank_account:
jv.doclist[2].account = bank_account["account"] d2.account = bank_account["account"]
jv.doclist[2].balance = bank_account["balance"] d2.balance = bank_account["balance"]
return jv return jv

View File

@ -174,9 +174,7 @@ class TestPurchaseInvoice(unittest.TestCase):
jv.submit() jv.submit()
pi = frappe.bean(copy=test_records[0]) pi = frappe.bean(copy=test_records[0])
pi.doclist.append({ pi.append("advance_allocation_details", {
"doctype": "Purchase Invoice Advance",
"parentfield": "advance_allocation_details",
"journal_voucher": jv.doc.name, "journal_voucher": jv.doc.name,
"jv_detail_no": jv.doclist[1].name, "jv_detail_no": jv.doclist[1].name,
"advance_amount": 400, "advance_amount": 400,

View File

@ -9,7 +9,7 @@ from frappe.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdate,
get_first_day, get_last_day get_first_day, get_last_day
from frappe.utils import comma_and, get_url 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.bean import getlist
from frappe.model.code import get_obj from frappe.model.code import get_obj
from frappe import _, msgprint from frappe import _, msgprint
@ -588,12 +588,6 @@ class SalesInvoice(SellingController):
grand_total = %s where invoice_no = %s and parent = %s""", grand_total = %s where invoice_no = %s and parent = %s""",
(self.doc.name, self.doc.amended_from, self.doc.c_form_no)) (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): def validate_recurring_invoice(self):
if self.doc.convert_into_recurring_invoice: if self.doc.convert_into_recurring_invoice:
self.validate_notification_email_id() self.validate_notification_email_id()

View File

@ -139,16 +139,14 @@ class TestSalesInvoice(unittest.TestCase):
def test_sales_invoice_discount_amount(self): def test_sales_invoice_discount_amount(self):
si = frappe.bean(copy=test_records[3]) si = frappe.bean(copy=test_records[3])
si.doc.discount_amount = 104.95 si.doc.discount_amount = 104.95
si.doclist.append({ si.append("other_charges", {
"doctype": "Sales Taxes and Charges", "doctype": "Sales Taxes and Charges",
"parentfield": "other_charges",
"charge_type": "On Previous Row Amount", "charge_type": "On Previous Row Amount",
"account_head": "_Test Account Service Tax - _TC", "account_head": "_Test Account Service Tax - _TC",
"cost_center": "_Test Cost Center - _TC", "cost_center": "_Test Cost Center - _TC",
"description": "Service Tax", "description": "Service Tax",
"rate": 10, "rate": 10,
"row_id": 8, "row_id": 8,
"idx": 9
}) })
si.insert() si.insert()
@ -196,16 +194,14 @@ class TestSalesInvoice(unittest.TestCase):
def test_discount_amount_gl_entry(self): def test_discount_amount_gl_entry(self):
si = frappe.bean(copy=test_records[3]) si = frappe.bean(copy=test_records[3])
si.doc.discount_amount = 104.95 si.doc.discount_amount = 104.95
si.doclist.append({ si.append("other_charges", {
"doctype": "Sales Taxes and Charges", "doctype": "Sales Taxes and Charges",
"parentfield": "other_charges",
"charge_type": "On Previous Row Amount", "charge_type": "On Previous Row Amount",
"account_head": "_Test Account Service Tax - _TC", "account_head": "_Test Account Service Tax - _TC",
"cost_center": "_Test Cost Center - _TC", "cost_center": "_Test Cost Center - _TC",
"description": "Service Tax", "description": "Service Tax",
"rate": 10, "rate": 10,
"row_id": 8, "row_id": 8
"idx": 9
}) })
si.insert() si.insert()
si.submit() si.submit()
@ -369,7 +365,7 @@ class TestSalesInvoice(unittest.TestCase):
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \ from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
import test_records as jv_test_records 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.doclist[1].against_invoice = w.doc.name
jv.insert() jv.insert()
jv.submit() jv.submit()
@ -385,7 +381,7 @@ class TestSalesInvoice(unittest.TestCase):
tlb = frappe.bean("Time Log Batch", "_T-Time Log Batch-00001") tlb = frappe.bean("Time Log Batch", "_T-Time Log Batch-00001")
tlb.submit() 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.doclist[1].time_log_batch = "_T-Time Log Batch-00001"
si.insert() si.insert()
si.submit() si.submit()
@ -444,7 +440,7 @@ class TestSalesInvoice(unittest.TestCase):
self._insert_purchase_receipt() self._insert_purchase_receipt()
self._insert_pos_settings() 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]["is_pos"] = 1
pos[0]["update_stock"] = 1 pos[0]["update_stock"] = 1
pos[0]["posting_time"] = "12:05" pos[0]["posting_time"] = "12:05"
@ -510,7 +506,7 @@ class TestSalesInvoice(unittest.TestCase):
pr.insert() pr.insert()
pr.submit() 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]["update_stock"] = 1
si_doclist[0]["posting_time"] = "12:05" si_doclist[0]["posting_time"] = "12:05"
si_doclist[1]["warehouse"] = "_Test Warehouse No Account - _TC" si_doclist[1]["warehouse"] = "_Test Warehouse No Account - _TC"
@ -555,7 +551,7 @@ class TestSalesInvoice(unittest.TestCase):
self.clear_stock_account_balance() self.clear_stock_account_balance()
set_perpetual_inventory() 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_copy[1]["item_code"] = None
si = frappe.bean(si_copy) si = frappe.bean(si_copy)
si.insert() si.insert()
@ -582,7 +578,7 @@ class TestSalesInvoice(unittest.TestCase):
def test_sales_invoice_gl_entry_with_aii_non_stock_item(self): def test_sales_invoice_gl_entry_with_aii_non_stock_item(self):
self.clear_stock_account_balance() self.clear_stock_account_balance()
set_perpetual_inventory() 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_copy[1]["item_code"] = "_Test Non Stock Item"
si = frappe.bean(si_copy) si = frappe.bean(si_copy)
si.insert() si.insert()
@ -640,9 +636,8 @@ class TestSalesInvoice(unittest.TestCase):
jv.submit() jv.submit()
si = frappe.bean(copy=test_records[0]) si = frappe.bean(copy=test_records[0])
si.doclist.append({ si.append("advance_adjustment_details", {
"doctype": "Sales Invoice Advance", "doctype": "Sales Invoice Advance",
"parentfield": "advance_adjustment_details",
"journal_voucher": jv.doc.name, "journal_voucher": jv.doc.name,
"jv_detail_no": jv.doclist[1].name, "jv_detail_no": jv.doclist[1].name,
"advance_amount": 400, "advance_amount": 400,

View File

@ -242,7 +242,7 @@ def get_company_default(company, fieldname):
if not value: if not value:
throw(_("Please mention default value for '") + throw(_("Please mention default value for '") +
_(frappe.get_doctype("company").get_label(fieldname) + _(frappe.get_meta("Company").get_label(fieldname) +
_("' in Company: ") + company)) _("' in Company: ") + company))
return value return value

View File

@ -7,7 +7,7 @@ import frappe.defaults
from frappe.utils import cint from frappe.utils import cint
from frappe import msgprint, _ 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.accounts.party import create_party_account
from erpnext.utilities.transaction_base import TransactionBase from erpnext.utilities.transaction_base import TransactionBase

View File

@ -121,17 +121,11 @@ class AccountsController(TransactionBase):
from frappe.model import default_fields from frappe.model import default_fields
tax_master = frappe.bean(tax_master_doctype, self.doc.fields.get(tax_master_field)) 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: for fieldname in default_fields:
tax.fields[fieldname] = None tax.set(fieldname, None)
tax.fields.update({ self.append(tax_parentfield, tax)
"doctype": tax_doctype,
"parentfield": tax_parentfield,
"idx": i+1
})
self.doclist.append(tax)
def get_other_charges(self): def get_other_charges(self):
self.set("other_charges", []) self.set("other_charges", [])
@ -410,9 +404,8 @@ class AccountsController(TransactionBase):
self.set(parentfield, []) self.set(parentfield, [])
for d in res: for d in res:
self.doclist.append({ self.append(parentfield, {
"doctype": child_doctype, "doctype": child_doctype,
"parentfield": parentfield,
"journal_voucher": d.jv_no, "journal_voucher": d.jv_no,
"jv_detail_no": d.jv_detail_no, "jv_detail_no": d.jv_detail_no,
"remarks": d.remark, "remarks": d.remark,

View File

@ -230,7 +230,6 @@ class BuyingController(StockController):
for item in bom_items: for item in bom_items:
required_qty = flt(item.qty_consumed_per_unit) * flt(d.qty) * flt(d.conversion_factor) required_qty = flt(item.qty_consumed_per_unit) * flt(d.qty) * flt(d.conversion_factor)
rm_doclist = { rm_doclist = {
"parentfield": raw_material_table,
"doctype": self.doc.doctype + " Item Supplied", "doctype": self.doc.doctype + " Item Supplied",
"reference_name": d.name, "reference_name": d.name,
"bom_detail_no": item.name, "bom_detail_no": item.name,
@ -248,7 +247,7 @@ class BuyingController(StockController):
"description": item.description, "description": item.description,
}) })
self.doclist.append(rm_doclist) self.append(raw_material_table, rm_doclist)
raw_materials_cost += required_qty * flt(item.rate) raw_materials_cost += required_qty * flt(item.rate)

View File

@ -59,9 +59,8 @@ class SellingController(StockController):
shipping_amount = condition.shipping_amount shipping_amount = condition.shipping_amount
break break
self.doclist.append({ self.append("other_charges", {
"doctype": "Sales Taxes and Charges", "doctype": "Sales Taxes and Charges",
"parentfield": "other_charges",
"charge_type": "Actual", "charge_type": "Actual",
"account_head": shipping_rule.doc.account, "account_head": shipping_rule.doc.account,
"cost_center": shipping_rule.doc.cost_center, "cost_center": shipping_rule.doc.cost_center,

View File

@ -59,7 +59,6 @@ feed_dict = {
def make_feed(feedtype, doctype, name, owner, subject, color): def make_feed(feedtype, doctype, name, owner, subject, color):
"makes a new Feed record" "makes a new Feed record"
#msgprint(subject) #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'): if feedtype in ('Login', 'Comment', 'Assignment'):
@ -72,7 +71,7 @@ def make_feed(feedtype, doctype, name, owner, subject, color):
where doc_type=%s and doc_name=%s where doc_type=%s and doc_name=%s
and ifnull(feed_type,'') != 'Comment'""", (doctype, name)) and ifnull(feed_type,'') != 'Comment'""", (doctype, name))
f = Document('Feed') f = frappe.get_doc('Feed')
f.owner = owner f.owner = owner
f.feed_type = feedtype f.feed_type = feedtype
f.doc_type = doctype f.doc_type = doctype

View File

@ -5,7 +5,7 @@ from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import getdate, validate_email_add, cstr, cint 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, _ from frappe import msgprint, throw, _
import frappe.permissions import frappe.permissions
from frappe.defaults import get_restrictions from frappe.defaults import get_restrictions

View File

@ -5,7 +5,7 @@ from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import add_days, add_years, cint, getdate 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, _ from frappe import msgprint, throw, _
import datetime import datetime

View File

@ -24,9 +24,8 @@ class TestLeaveApplication(unittest.TestCase):
temp_session_user = frappe.session.user temp_session_user = frappe.session.user
frappe.set_user("Administrator") frappe.set_user("Administrator")
employee = frappe.bean("Employee", employee) employee = frappe.bean("Employee", employee)
employee.doclist.append({ employee.append("employee_leave_approvers", {
"doctype": "Employee Leave Approver", "doctype": "Employee Leave Approver",
"parentfield": "employee_leave_approvers",
"leave_approver": leave_approver "leave_approver": leave_approver
}) })
employee.save() employee.save()

View File

@ -5,7 +5,6 @@ from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import cint, cstr, flt, nowdate from frappe.utils import cint, cstr, flt, nowdate
from frappe.model.doc import Document
from frappe.model.code import get_obj from frappe.model.code import get_obj
from frappe import msgprint, _ from frappe import msgprint, _
@ -38,10 +37,9 @@ class LeaveControlPanel(Document):
return e return e
def validate_values(self): def validate_values(self):
meta = frappe.get_doctype(self.doc.doctype)
for f in ["fiscal_year", "leave_type", "no_of_days"]: for f in ["fiscal_year", "leave_type", "no_of_days"]:
if not self.doc.fields[f]: if not self.get(f):
frappe.throw(_(meta.get_label(f)) + _(" is mandatory")) frappe.throw(_(self.meta.get_label(f)) + _(" is mandatory"))
def allocate_leave(self): def allocate_leave(self):
self.validate_values() self.validate_values()
@ -52,7 +50,8 @@ class LeaveControlPanel(Document):
for d in self.get_employees(): for d in self.get_employees():
try: try:
la = Document('Leave Allocation') la = frappe.get_doc('Leave Allocation')
la.set("__islocal", 1)
la.employee = cstr(d[0]) la.employee = cstr(d[0])
la.employee_name = frappe.db.get_value('Employee',cstr(d[0]),'employee_name') la.employee_name = frappe.db.get_value('Employee',cstr(d[0]),'employee_name')
la.leave_type = self.doc.leave_type la.leave_type = self.doc.leave_type
@ -60,11 +59,8 @@ class LeaveControlPanel(Document):
la.posting_date = nowdate() la.posting_date = nowdate()
la.carry_forward = cint(self.doc.carry_forward) la.carry_forward = cint(self.doc.carry_forward)
la.new_leaves_allocated = flt(self.doc.no_of_days) la.new_leaves_allocated = flt(self.doc.no_of_days)
la_obj = get_obj(doc=la) la.docstatus = 1
la_obj.doc.docstatus = 1 la.save()
la_obj.validate()
la_obj.on_update()
la_obj.doc.save(1)
leave_allocated_for.append(d[0]) leave_allocated_for.append(d[0])
except: except:
pass pass

View File

@ -5,7 +5,7 @@ from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import add_days, cint, cstr, flt, getdate, nowdate, _round 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.bean import getlist
from frappe.model.code import get_obj from frappe.model.code import get_obj
from frappe import msgprint, _ from frappe import msgprint, _

View File

@ -5,7 +5,7 @@ from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import cstr, flt from frappe.utils import cstr, flt
from frappe.model.doc import make_autoname from frappe.model.naming import make_autoname
from frappe import msgprint, _ from frappe import msgprint, _

View File

@ -120,7 +120,7 @@ def upload():
error = False error = False
from frappe.utils.datautils import check_record, import_doc 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:]): for i, row in enumerate(rows[5:]):
if not row: continue if not row: continue
@ -131,7 +131,7 @@ def upload():
d["docstatus"] = frappe.db.get_value("Attendance", d.name, "docstatus") d["docstatus"] = frappe.db.get_value("Attendance", d.name, "docstatus")
try: try:
check_record(d, doctype_dl=doctype_dl) check_record(d)
ret.append(import_doc(d, "Attendance", 1, row_idx, submit=True)) ret.append(import_doc(d, "Attendance", 1, row_idx, submit=True))
except Exception, e: except Exception, e:
error = True error = True

View File

@ -366,7 +366,7 @@ class ProductionPlanningTool(Document):
if items_to_be_requested: if items_to_be_requested:
for item in items_to_be_requested: for item in items_to_be_requested:
item_wrapper = frappe.bean("Item", item) item_wrapper = frappe.bean("Item", item)
pr_doclist = [{ pr_doc = frappe.get_doc({
"doctype": "Material Request", "doctype": "Material Request",
"__islocal": 1, "__islocal": 1,
"naming_series": "IDT", "naming_series": "IDT",
@ -376,12 +376,11 @@ class ProductionPlanningTool(Document):
"fiscal_year": fiscal_year, "fiscal_year": fiscal_year,
"requested_by": frappe.session.user, "requested_by": frappe.session.user,
"material_request_type": "Purchase" "material_request_type": "Purchase"
}] })
for sales_order, requested_qty in items_to_be_requested[item].items(): for sales_order, requested_qty in items_to_be_requested[item].items():
pr_doclist.append({ pr_doc.append("indent_details", {
"doctype": "Material Request Item", "doctype": "Material Request Item",
"__islocal": 1, "__islocal": 1,
"parentfield": "indent_details",
"item_code": item, "item_code": item,
"item_name": item_wrapper.doc.item_name, "item_name": item_wrapper.doc.item_name,
"description": item_wrapper.doc.description, "description": item_wrapper.doc.description,
@ -394,10 +393,9 @@ class ProductionPlanningTool(Document):
"sales_order_no": sales_order if sales_order!="No Sales Order" else None "sales_order_no": sales_order if sales_order!="No Sales Order" else None
}) })
pr_wrapper = frappe.bean(pr_doclist) pr_doc.ignore_permissions = 1
pr_wrapper.ignore_permissions = 1 pr_doc.submit()
pr_wrapper.submit() purchase_request_list.append(pr_doc.name)
purchase_request_list.append(pr_wrapper.doc.name)
if purchase_request_list: if purchase_request_list:
pur_req = ["""<a href="#Form/Material Request/%s" target="_blank">%s</a>""" % \ pur_req = ["""<a href="#Form/Material Request/%s" target="_blank">%s</a>""" % \

View File

@ -39,7 +39,7 @@ def update_user_match():
doctype_matches.setdefault(doctype, []).append(match) doctype_matches.setdefault(doctype, []).append(match)
for doctype, user_matches in doctype_matches.items(): 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 each user with roles of this doctype, check if match condition applies
for user in frappe.db.sql_list("""select name from `tabUser` for user in frappe.db.sql_list("""select name from `tabUser`

View File

@ -8,7 +8,7 @@ from erpnext.projects.doctype.time_log.time_log import OverlapError
class TestTimeLog(unittest.TestCase): class TestTimeLog(unittest.TestCase):
def test_duplication(self): 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) self.assertRaises(OverlapError, ts.insert)
test_records = [[{ test_records = [[{

View File

@ -3,7 +3,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.model.doc import Document, make_autoname from frappe.model.naming import make_autoname
from frappe import msgprint, _ from frappe import msgprint, _
import frappe.defaults import frappe.defaults
@ -56,7 +56,8 @@ class Customer(TransactionBase):
(self.doc.name, self.doc.customer_name, self.doc.lead_name)) (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) 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.first_name = lead.lead_name
c.email_id = lead.email_id c.email_id = lead.email_id
c.phone = lead.phone c.phone = lead.phone
@ -65,7 +66,7 @@ class Customer(TransactionBase):
c.customer_name = self.doc.customer_name c.customer_name = self.doc.customer_name
c.is_primary_contact = 1 c.is_primary_contact = 1
try: try:
c.save(1) c.save()
except NameError, e: except NameError, e:
pass pass

View File

@ -80,7 +80,7 @@ class TestSalesOrder(unittest.TestCase):
_insert_purchase_receipt(so.doclist[1].item_code) _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].item_code = so.doclist[1].item_code
dn.doclist[1].against_sales_order = so.doc.name dn.doclist[1].against_sales_order = so.doc.name
dn.doclist[1].prevdoc_detail_docname = so.doclist[1].name dn.doclist[1].prevdoc_detail_docname = so.doclist[1].name
@ -199,7 +199,7 @@ class TestSalesOrder(unittest.TestCase):
# change item in test so record # 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" test_record[1]["item_code"] = "_Test Sales BOM Item"
# reset bin # reset bin
@ -248,7 +248,7 @@ class TestSalesOrder(unittest.TestCase):
from erpnext.selling.doctype.sales_bom.test_sales_bom import test_records as sbom_test_records from erpnext.selling.doctype.sales_bom.test_sales_bom import test_records as sbom_test_records
# change item in test so record # 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" test_record[1]["item_code"] = "_Test Sales BOM Item"
# reset bin # reset bin

View File

@ -21,8 +21,7 @@ def get_children():
@frappe.whitelist() @frappe.whitelist()
def add_node(): 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(' ', '_') parent_field = 'parent_' + ctype.lower().replace(' ', '_')
name_field = ctype.lower().replace(' ', '_') + '_name' name_field = ctype.lower().replace(' ', '_') + '_name'

View File

@ -86,15 +86,13 @@ class Company(Document):
website_settings.doc.home_page = webpage.doc.name website_settings.doc.home_page = webpage.doc.name
website_settings.doc.brand_html = self.doc.name website_settings.doc.brand_html = self.doc.name
website_settings.doc.copyright = self.doc.name website_settings.doc.copyright = self.doc.name
website_settings.doclist.append({ website_settings.append("top_bar_items", {
"doctype": "Top Bar Item", "doctype": "Top Bar Item",
"parentfield": "top_bar_items",
"label":"Contact", "label":"Contact",
"url": "contact" "url": "contact"
}) })
website_settings.doclist.append({ website_settings.append("top_bar_items", {
"doctype": "Top Bar Item", "doctype": "Top Bar Item",
"parentfield": "top_bar_items",
"label":"Blog", "label":"Blog",
"url": "blog" "url": "blog"
}) })

View File

@ -56,26 +56,27 @@ class NamingSeries(Document):
default = options[0] default = options[0]
# update in property setter # 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: for prop in prop_dict:
ps_exists = frappe.db.sql("""SELECT name FROM `tabProperty Setter` ps_exists = frappe.db.sql("""SELECT name FROM `tabProperty Setter`
WHERE doc_type = %s AND field_name = 'naming_series' WHERE doc_type = %s AND field_name = 'naming_series'
AND property = %s""", (doctype, prop)) AND property = %s""", (doctype, prop))
if ps_exists: 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.value = prop_dict[prop]
ps.save() ps.save()
else: else:
ps = Document('Property Setter', fielddata = { ps = frappe.get_doc({
'doctype': 'Property Setter',
'doctype_or_field': 'DocField', 'doctype_or_field': 'DocField',
'doc_type': doctype, 'doc_type': doctype,
'field_name': 'naming_series', 'field_name': 'naming_series',
'property': prop, 'property': prop,
'value': prop_dict[prop], 'value': prop_dict[prop],
'property_type': 'Select', 'property_type': 'Select',
'__islocal': 1
}) })
ps.save(1) ps.save()
self.doc.set_options = "\n".join(options) self.doc.set_options = "\n".join(options)

View File

@ -18,7 +18,7 @@ class Item(DocListController):
def autoname(self): def autoname(self):
if frappe.db.get_default("item_naming_by")=="Naming Series": 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+'.#####') self.doc.item_code = make_autoname(self.doc.naming_series+'.#####')
elif not self.doc.item_code: elif not self.doc.item_code:
msgprint(_("Item Code (item_code) is mandatory because Item naming is not sequential."), raise_exception=1) msgprint(_("Item Code (item_code) is mandatory because Item naming is not sequential."), raise_exception=1)
@ -272,7 +272,7 @@ def validate_end_of_life(item_code, end_of_life=None, verbose=1):
"in Item master") % { "in Item master") % {
"item_code": item_code, "item_code": item_code,
"date": formatdate(end_of_life), "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) _msgprint(msg, verbose)

View File

@ -177,7 +177,7 @@ def update_completed_qty(bean, method):
for mr_name, mr_items in material_request_map.items(): for mr_name, mr_items in material_request_map.items():
mr_obj = frappe.get_obj("Material Request", mr_name, with_children=1) 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"]: if mr_obj.doc.status in ["Stopped", "Cancelled"]:
frappe.throw(_("Material Request") + ": %s, " % mr_obj.doc.name frappe.throw(_("Material Request") + ": %s, " % mr_obj.doc.name

View File

@ -16,9 +16,8 @@ class PriceList(DocListController):
if not self.get("valid_for_territories"): if not self.get("valid_for_territories"):
# if no territory, set default territory # if no territory, set default territory
if frappe.defaults.get_user_default("territory"): if frappe.defaults.get_user_default("territory"):
self.doclist.append({ self.append("valid_for_territories", {
"doctype": "Applicable Territory", "doctype": "Applicable Territory",
"parentfield": "valid_for_territories",
"territory": frappe.defaults.get_user_default("territory") "territory": frappe.defaults.get_user_default("territory")
}) })
else: else:

View File

@ -254,7 +254,7 @@ def validate_serial_no(sle, item_det):
def update_serial_nos(sle, item_det): 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: 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 = [] serial_nos = []
for i in xrange(cint(sle.actual_qty)): for i in xrange(cint(sle.actual_qty)):
serial_nos.append(make_autoname(item_det.serial_no_series)) serial_nos.append(make_autoname(item_det.serial_no_series))

View File

@ -5,7 +5,6 @@ from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import add_days, cstr, flt, nowdate, cint, now 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.bean import getlist
from frappe.model.code import get_obj from frappe.model.code import get_obj
from frappe import session, msgprint from frappe import session, msgprint

View File

@ -158,7 +158,7 @@ def get_basic_details(args, item_bean):
return out return out
def get_price_list_rate(args, item_bean, 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"): if meta.get_field("currency"):
validate_price_list(args) validate_price_list(args)

View File

@ -116,7 +116,7 @@ def update_entries_after(args, verbose=1):
# rounding as per precision # rounding as per precision
from frappe.model.meta import get_field_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"), stock_value = flt(stock_value, get_field_precision(meta.get_field("stock_value"),
frappe._dict({"fields": sle}))) frappe._dict({"fields": sle})))

View File

@ -16,11 +16,10 @@ class SupportEmailSettings(Document):
""" """
if self.doc.sync_support_mails and self.doc.mail_server: if self.doc.sync_support_mails and self.doc.mail_server:
from frappe.utils.email_lib.receive import POP3Mailbox 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 = frappe.get_doc('Incoming Email Settings')
inc_email.encode() # inc_email.encode()
inc_email.host = self.doc.mail_server inc_email.host = self.doc.mail_server
inc_email.use_ssl = self.doc.use_ssl inc_email.use_ssl = self.doc.use_ssl
try: try:

View File

@ -56,7 +56,7 @@ def get_address_display(address_dict):
if not isinstance(address_dict, dict): if not isinstance(address_dict, dict):
address_dict = frappe.db.get_value("Address", address_dict, "*", as_dict=True) or {} 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"), sequence = (("", "address_line1"),
("\n", "address_line2"), ("\n", "address_line2"),
("\n", "city"), ("\n", "city"),

View File

@ -6,7 +6,6 @@ import frappe, json
from frappe.utils import nowdate, cstr from frappe.utils import nowdate, cstr
from frappe.model.code import get_obj from frappe.model.code import get_obj
from frappe.model.doc import Document
from frappe import msgprint, throw, _ from frappe import msgprint, throw, _
from frappe.model.bean import getlist from frappe.model.bean import getlist
@ -109,11 +108,11 @@ class SmsControl(Document):
# Create SMS Log # Create SMS Log
# ========================================================= # =========================================================
def create_sms_log(self, arg, sent_sms): 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.sender_name = arg['sender_name']
sl.sent_on = nowdate() sl.sent_on = nowdate()
sl.receiver_list = cstr(arg['receiver_list']) sl.receiver_list = cstr(arg['receiver_list'])
sl.message = arg['message'] sl.message = arg['message']
sl.no_of_requested_sms = len(arg['receiver_list']) sl.no_of_requested_sms = len(arg['receiver_list'])
sl.no_of_sent_sms = sent_sms sl.no_of_sent_sms = sent_sms
sl.save(new=1) sl.save()

View File

@ -36,7 +36,7 @@ class TransactionBase(StatusUpdater):
opts = frappe._dict(opts) opts = frappe._dict(opts)
if self.doc.contact_date: if self.doc.contact_date:
event_doclist = [{ event_doclist = frappe.get_doc({
"doctype": "Event", "doctype": "Event",
"owner": opts.owner or self.doc.owner, "owner": opts.owner or self.doc.owner,
"subject": opts.subject, "subject": opts.subject,
@ -45,16 +45,15 @@ class TransactionBase(StatusUpdater):
"event_type": "Private", "event_type": "Private",
"ref_type": self.doc.doctype, "ref_type": self.doc.doctype,
"ref_name": self.doc.name "ref_name": self.doc.name
}] })
if frappe.db.exists("User", self.doc.contact_by): if frappe.db.exists("User", self.doc.contact_by):
event_doclist.append({ event_doclist.append("event_individuals", {
"doctype": "Event User", "doctype": "Event User",
"parentfield": "event_individuals",
"person": self.doc.contact_by "person": self.doc.contact_by
}) })
frappe.bean(event_doclist).insert() event_doclist.insert()
def validate_uom_is_integer(self, uom_field, qty_fields): def validate_uom_is_integer(self, uom_field, qty_fields):
validate_uom_is_integer(self.doclist, uom_field, qty_fields) validate_uom_is_integer(self.doclist, uom_field, qty_fields)