diff --git a/erpnext/accounts/Print Format/Cheque Printing Format/Cheque Printing Format.txt b/erpnext/accounts/Print Format/Cheque Printing Format/Cheque Printing Format.json similarity index 100% rename from erpnext/accounts/Print Format/Cheque Printing Format/Cheque Printing Format.txt rename to erpnext/accounts/Print Format/Cheque Printing Format/Cheque Printing Format.json diff --git a/erpnext/accounts/Print Format/POS Invoice/POS Invoice.txt b/erpnext/accounts/Print Format/POS Invoice/POS Invoice.json similarity index 100% rename from erpnext/accounts/Print Format/POS Invoice/POS Invoice.txt rename to erpnext/accounts/Print Format/POS Invoice/POS Invoice.json diff --git a/erpnext/accounts/Print Format/Payment Receipt Voucher/Payment Receipt Voucher.txt b/erpnext/accounts/Print Format/Payment Receipt Voucher/Payment Receipt Voucher.json similarity index 100% rename from erpnext/accounts/Print Format/Payment Receipt Voucher/Payment Receipt Voucher.txt rename to erpnext/accounts/Print Format/Payment Receipt Voucher/Payment Receipt Voucher.json diff --git a/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt b/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.json similarity index 100% rename from erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt rename to erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.json diff --git a/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt b/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.json similarity index 100% rename from erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt rename to erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.json diff --git a/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt b/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.json similarity index 100% rename from erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt rename to erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.json diff --git a/erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.txt b/erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.json similarity index 100% rename from erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.txt rename to erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.json diff --git a/erpnext/accounts/doctype/account/account.txt b/erpnext/accounts/doctype/account/account.json similarity index 100% rename from erpnext/accounts/doctype/account/account.txt rename to erpnext/accounts/doctype/account/account.json diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.txt b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json similarity index 100% rename from erpnext/accounts/doctype/accounts_settings/accounts_settings.txt rename to erpnext/accounts/doctype/accounts_settings/accounts_settings.json diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.txt b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json similarity index 100% rename from erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.txt rename to erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json diff --git a/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.txt b/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.json similarity index 100% rename from erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.txt rename to erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.json diff --git a/erpnext/accounts/doctype/budget_detail/budget_detail.txt b/erpnext/accounts/doctype/budget_detail/budget_detail.json similarity index 100% rename from erpnext/accounts/doctype/budget_detail/budget_detail.txt rename to erpnext/accounts/doctype/budget_detail/budget_detail.json diff --git a/erpnext/accounts/doctype/budget_distribution/budget_distribution.txt b/erpnext/accounts/doctype/budget_distribution/budget_distribution.json similarity index 100% rename from erpnext/accounts/doctype/budget_distribution/budget_distribution.txt rename to erpnext/accounts/doctype/budget_distribution/budget_distribution.json diff --git a/erpnext/accounts/doctype/budget_distribution/test_budget_distribution.py b/erpnext/accounts/doctype/budget_distribution/test_budget_distribution.py index 57fc162fe53..4626bae4db8 100644 --- a/erpnext/accounts/doctype/budget_distribution/test_budget_distribution.py +++ b/erpnext/accounts/doctype/budget_distribution/test_budget_distribution.py @@ -1,49 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - { - "doctype": "Budget Distribution", - "distribution_id": "_Test Distribution", - "fiscal_year": "_Test Fiscal Year 2013", - "budget_distribution_details": [ - { - "month": "January", - "percentage_allocation": "8" - }, { - "month": "February", - "percentage_allocation": "8" - }, { - "month": "March", - "percentage_allocation": "8" - }, { - "month": "April", - "percentage_allocation": "8" - }, { - "month": "May", - "percentage_allocation": "8" - }, { - "month": "June", - "percentage_allocation": "8" - }, { - "month": "July", - "percentage_allocation": "8" - }, { - "month": "August", - "percentage_allocation": "8" - }, { - "month": "September", - "percentage_allocation": "8" - }, { - "month": "October", - "percentage_allocation": "8" - }, { - "month": "November", - "percentage_allocation": "10" - }, { - "month": "December", - "percentage_allocation": "10" - } - ] - } -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Budget Distribution') \ No newline at end of file diff --git a/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.txt b/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.json similarity index 100% rename from erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.txt rename to erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.json diff --git a/erpnext/accounts/doctype/c_form/c_form.txt b/erpnext/accounts/doctype/c_form/c_form.json similarity index 100% rename from erpnext/accounts/doctype/c_form/c_form.txt rename to erpnext/accounts/doctype/c_form/c_form.json diff --git a/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.txt b/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.json similarity index 100% rename from erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.txt rename to erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.json diff --git a/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.txt b/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.json similarity index 100% rename from erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.txt rename to erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.json diff --git a/erpnext/accounts/doctype/cost_center/cost_center.txt b/erpnext/accounts/doctype/cost_center/cost_center.json similarity index 100% rename from erpnext/accounts/doctype/cost_center/cost_center.txt rename to erpnext/accounts/doctype/cost_center/cost_center.json diff --git a/erpnext/accounts/doctype/cost_center/test_cost_center.py b/erpnext/accounts/doctype/cost_center/test_cost_center.py index 2fd7ecf9666..d23d38af614 100644 --- a/erpnext/accounts/doctype/cost_center/test_cost_center.py +++ b/erpnext/accounts/doctype/cost_center/test_cost_center.py @@ -1,19 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Cost Center", - "cost_center_name": "_Test Cost Center", - "parent_cost_center": "_Test Company - _TC", - "company": "_Test Company", - "group_or_ledger": "Ledger", - "distribution_id": "_Test Distribution", - }, { - "doctype": "Budget Detail", - "parentfield": "budget_details", - "account": "_Test Account Cost for Goods Sold - _TC", - "budget_allocated": 100000, - "fiscal_year": "_Test Fiscal Year 2013" - }], -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Cost Center') \ No newline at end of file diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.txt b/erpnext/accounts/doctype/fiscal_year/fiscal_year.json similarity index 100% rename from erpnext/accounts/doctype/fiscal_year/fiscal_year.txt rename to erpnext/accounts/doctype/fiscal_year/fiscal_year.json diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py index aa393e0a1a3..6e72c9ad79a 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py @@ -12,7 +12,7 @@ class FiscalYear(Document): def set_as_default(self): frappe.db.set_value("Global Defaults", None, "current_fiscal_year", self.name) - frappe.get_obj("Global Defaults").on_update() + frappe.get_doc("Global Defaults").on_update() # clear cache frappe.clear_cache() diff --git a/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py index cd9b1f4eadb..d0e6c6cd0fd 100644 --- a/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py +++ b/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py @@ -3,35 +3,4 @@ from __future__ import unicode_literals -test_records = [ - [{ - "doctype": "Fiscal Year", - "year": "_Test Fiscal Year 2012", - "year_start_date": "2012-01-01", - "year_end_date": "2012-12-31" - }], - [{ - "doctype": "Fiscal Year", - "year": "_Test Fiscal Year 2013", - "year_start_date": "2013-01-01", - "year_end_date": "2013-12-31" - }], - [{ - "doctype": "Fiscal Year", - "year": "_Test Fiscal Year 2014", - "year_start_date": "2014-01-01", - "year_end_date": "2014-12-31" - }], - [{ - "doctype": "Fiscal Year", - "year": "_Test Fiscal Year 2015", - "year_start_date": "2015-01-01", - "year_end_date": "2015-12-31" - }], - [{ - "doctype": "Fiscal Year", - "year": "_Test Fiscal Year 2016", - "year_start_date": "2016-01-01", - "year_end_date": "2016-12-31" - }], -] \ No newline at end of file +test_records = frappe.get_test_records('Fiscal Year') \ No newline at end of file diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.txt b/erpnext/accounts/doctype/gl_entry/gl_entry.json similarity index 100% rename from erpnext/accounts/doctype/gl_entry/gl_entry.txt rename to erpnext/accounts/doctype/gl_entry/gl_entry.json diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.txt b/erpnext/accounts/doctype/journal_voucher/journal_voucher.json similarity index 100% rename from erpnext/accounts/doctype/journal_voucher/journal_voucher.txt rename to erpnext/accounts/doctype/journal_voucher/journal_voucher.json diff --git a/erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py index 20a342d0909..c3a3d85ae95 100644 --- a/erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py +++ b/erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py @@ -9,14 +9,14 @@ import frappe class TestJournalVoucher(unittest.TestCase): def test_journal_voucher_with_against_jv(self): self.clear_account_balance() - jv_invoice = frappe.get_doc(copy=test_records[2]) + jv_invoice = frappe.copy_doc(test_records[2]) jv_invoice.insert() jv_invoice.submit() self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail` where against_jv=%s""", jv_invoice.name)) - jv_payment = frappe.get_doc(copy=test_records[0]) + jv_payment = frappe.copy_doc(test_records[0]) jv_payment.doclist[1].against_jv = jv_invoice.name jv_payment.insert() jv_payment.submit() @@ -37,7 +37,7 @@ class TestJournalVoucher(unittest.TestCase): from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory set_perpetual_inventory() - jv = frappe.get_doc(copy=test_records[0]) + jv = frappe.copy_doc(test_records[0]) jv.doclist[1].account = "_Test Warehouse - _TC" jv.insert() @@ -50,7 +50,7 @@ class TestJournalVoucher(unittest.TestCase): frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore") self.clear_account_balance() - jv = frappe.get_doc(copy=test_records[0]) + jv = frappe.copy_doc(test_records[0]) jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC" jv.doclist[2].cost_center = "_Test Cost Center - _TC" jv.doclist[2].debit = 20000.0 @@ -65,7 +65,7 @@ class TestJournalVoucher(unittest.TestCase): frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop") self.clear_account_balance() - jv = frappe.get_doc(copy=test_records[0]) + jv = frappe.copy_doc(test_records[0]) jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC" jv.doclist[2].cost_center = "_Test Cost Center - _TC" jv.doclist[2].debit = 20000.0 @@ -83,7 +83,7 @@ class TestJournalVoucher(unittest.TestCase): frappe.db.set_value("Company", "_Test Company", "yearly_bgt_flag", "Stop") - jv = frappe.get_doc(copy=test_records[0]) + jv = frappe.copy_doc(test_records[0]) jv.posting_date = "2013-08-12" jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC" jv.doclist[2].cost_center = "_Test Cost Center - _TC" @@ -100,7 +100,7 @@ class TestJournalVoucher(unittest.TestCase): frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop") self.clear_account_balance() - jv = frappe.get_doc(copy=test_records[0]) + jv = frappe.copy_doc(test_records[0]) jv.doclist[1].account = "_Test Account Cost for Goods Sold - _TC" jv.doclist[1].cost_center = "_Test Cost Center - _TC" jv.doclist[1].credit = 30000.0 @@ -110,7 +110,7 @@ class TestJournalVoucher(unittest.TestCase): self.assertTrue(frappe.db.get_value("GL Entry", {"voucher_type": "Journal Voucher", "voucher_no": jv.name})) - jv1 = frappe.get_doc(copy=test_records[0]) + jv1 = frappe.copy_doc(test_records[0]) jv1.doclist[2].account = "_Test Account Cost for Goods Sold - _TC" jv1.doclist[2].cost_center = "_Test Cost Center - _TC" jv1.doclist[2].debit = 40000.0 @@ -128,81 +128,4 @@ class TestJournalVoucher(unittest.TestCase): frappe.db.sql("""delete from `tabGL Entry`""") -test_records = [ - [{ - "company": "_Test Company", - "doctype": "Journal Voucher", - "fiscal_year": "_Test Fiscal Year 2013", - "naming_series": "_T-Journal Voucher-", - "posting_date": "2013-02-14", - "user_remark": "test", - "voucher_type": "Bank Voucher", - "cheque_no": "33", - "cheque_date": "2013-02-14" - }, - { - "account": "_Test Customer - _TC", - "doctype": "Journal Voucher Detail", - "credit": 400.0, - "debit": 0.0, - "parentfield": "entries" - }, - { - "account": "_Test Account Bank Account - _TC", - "doctype": "Journal Voucher Detail", - "debit": 400.0, - "credit": 0.0, - "parentfield": "entries" - }], - [{ - "company": "_Test Company", - "doctype": "Journal Voucher", - "fiscal_year": "_Test Fiscal Year 2013", - "naming_series": "_T-Journal Voucher-", - "posting_date": "2013-02-14", - "user_remark": "test", - "voucher_type": "Bank Voucher", - "cheque_no": "33", - "cheque_date": "2013-02-14" - }, - { - "account": "_Test Supplier - _TC", - "doctype": "Journal Voucher Detail", - "credit": 0.0, - "debit": 400.0, - "parentfield": "entries" - }, - { - "account": "_Test Account Bank Account - _TC", - "doctype": "Journal Voucher Detail", - "debit": 0.0, - "credit": 400.0, - "parentfield": "entries" - }], - [{ - "company": "_Test Company", - "doctype": "Journal Voucher", - "fiscal_year": "_Test Fiscal Year 2013", - "naming_series": "_T-Journal Voucher-", - "posting_date": "2013-02-14", - "user_remark": "test", - "voucher_type": "Bank Voucher", - "cheque_no": "33", - "cheque_date": "2013-02-14" - }, - { - "account": "_Test Customer - _TC", - "doctype": "Journal Voucher Detail", - "credit": 0.0, - "debit": 400.0, - "parentfield": "entries" - }, - { - "account": "Sales - _TC", - "doctype": "Journal Voucher Detail", - "credit": 400.0, - "debit": 0.0, - "parentfield": "entries", - "cost_center": "_Test Cost Center - _TC" - }], -] \ No newline at end of file +test_records = frappe.get_test_records('Journal Voucher') \ No newline at end of file diff --git a/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.txt b/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.json similarity index 100% rename from erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.txt rename to erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.json diff --git a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.txt b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.json similarity index 100% rename from erpnext/accounts/doctype/mode_of_payment/mode_of_payment.txt rename to erpnext/accounts/doctype/mode_of_payment/mode_of_payment.json diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.txt b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.json similarity index 100% rename from erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.txt rename to erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.json diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py index fed02523765..2198909d452 100644 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py +++ b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py @@ -5,4 +5,4 @@ from __future__ import unicode_literals import unittest import frappe -test_records = [] \ No newline at end of file +test_records = frappe.get_test_records('Payment To Invoice Matching Tool') \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.txt b/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.json similarity index 100% rename from erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.txt rename to erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.json diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.txt b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.json similarity index 100% rename from erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.txt rename to erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.json diff --git a/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py index 9ffe451e915..12facd8aa38 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py +++ b/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py @@ -12,18 +12,18 @@ class TestPeriodClosingVoucher(unittest.TestCase): frappe.db.sql("""delete from `tabGL Entry`""") from erpnext.accounts.doctype.journal_voucher.test_journal_voucher import test_records as jv_records - jv = frappe.get_doc(copy=jv_records[2]) + jv = frappe.copy_doc(jv_records[2]) jv.insert() jv.submit() - jv1 = frappe.get_doc(copy=jv_records[0]) + jv1 = frappe.copy_doc(jv_records[0]) jv1.doclist[2].account = "_Test Account Cost for Goods Sold - _TC" jv1.doclist[2].debit = 600.0 jv1.doclist[1].credit = 600.0 jv1.insert() jv1.submit() - pcv = frappe.get_doc(copy=test_record) + pcv = frappe.copy_doc(test_record) pcv.insert() pcv.submit() diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.txt b/erpnext/accounts/doctype/pos_setting/pos_setting.json similarity index 100% rename from erpnext/accounts/doctype/pos_setting/pos_setting.txt rename to erpnext/accounts/doctype/pos_setting/pos_setting.json diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.py b/erpnext/accounts/doctype/pos_setting/pos_setting.py index ed3f5f4a424..65761c93a54 100755 --- a/erpnext/accounts/doctype/pos_setting/pos_setting.py +++ b/erpnext/accounts/doctype/pos_setting/pos_setting.py @@ -10,11 +10,7 @@ from frappe.model.document import Document class PosSetting(Document): def get_series(self): - import frappe.model.doctype - docfield = frappe.model.doctype.get('Sales Invoice') - series = [d.options for d in docfield - if d.doctype == 'DocField' and d.fieldname == 'naming_series'] - return series and series[0] or '' + frappe.get_meta("Sales Invoice").get_field("naming_series").options or "" def validate(self): self.check_for_duplicate() diff --git a/erpnext/accounts/doctype/pos_setting/test_pos_setting.py b/erpnext/accounts/doctype/pos_setting/test_pos_setting.py index 42125cd0f90..d563be96d7f 100644 --- a/erpnext/accounts/doctype/pos_setting/test_pos_setting.py +++ b/erpnext/accounts/doctype/pos_setting/test_pos_setting.py @@ -1,19 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "POS Setting", - "name": "_Test POS Setting", - "currency": "INR", - "selling_price_list": "_Test Price List", - "company": "_Test Company", - "warehouse": "_Test Warehouse - _TC", - "territory": "_Test Territory", - "cash_bank_account": "_Test Account Bank Account - _TC", - "income_account": "Sales - _TC", - "cost_center": "_Test Cost Center - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "naming_series": "_T-Sales Invoice-" - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Pos Setting') \ No newline at end of file diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.txt b/erpnext/accounts/doctype/pricing_rule/pricing_rule.json similarity index 100% rename from erpnext/accounts/doctype/pricing_rule/pricing_rule.txt rename to erpnext/accounts/doctype/pricing_rule/pricing_rule.json diff --git a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py index c1bd3195d31..5e427971e55 100644 --- a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py @@ -19,7 +19,7 @@ class TestPricingRule(unittest.TestCase): "price": 0, "discount_percentage": 10, }] - frappe.get_doc(copy=test_record).insert() + frappe.copy_doc(test_record).insert() args = frappe._dict({ "item_code": "_Test Item", @@ -38,7 +38,7 @@ class TestPricingRule(unittest.TestCase): details = get_item_details(args) self.assertEquals(details.get("discount_percentage"), 10) - prule = frappe.get_doc(copy=test_record) + prule = frappe.copy_doc(test_record) prule.applicable_for = "Customer" self.assertRaises(MandatoryError, prule.insert) prule.customer = "_Test Customer" @@ -47,7 +47,7 @@ class TestPricingRule(unittest.TestCase): details = get_item_details(args) self.assertEquals(details.get("discount_percentage"), 20) - prule = frappe.get_doc(copy=test_record) + prule = frappe.copy_doc(test_record) prule.apply_on = "Item Group" prule.item_group = "All Item Groups" prule.discount_percentage = 15 @@ -57,7 +57,7 @@ class TestPricingRule(unittest.TestCase): details = get_item_details(args) self.assertEquals(details.get("discount_percentage"), 10) - prule = frappe.get_doc(copy=test_record) + prule = frappe.copy_doc(test_record) prule.applicable_for = "Campaign" prule.campaign = "_Test Campaign" prule.discount_percentage = 5 diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.txt b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json similarity index 100% rename from erpnext/accounts/doctype/purchase_invoice/purchase_invoice.txt rename to erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index eb8b93a5d67..b37479614ff 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -6,7 +6,6 @@ import frappe from frappe.utils import cint, cstr, flt, formatdate -from frappe.model.code import get_obj from frappe import msgprint, _ from erpnext.setup.utils import get_company_currency @@ -267,7 +266,7 @@ class PurchaseInvoice(BuyingController): def on_submit(self): self.check_prev_docstatus() - get_obj('Authorization Control').validate_approving_authority(self.doctype, + frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.grand_total) # this sequence because outstanding may get -negative diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index fa79c37d20f..cb5cd31c5df 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -19,7 +19,7 @@ class TestPurchaseInvoice(unittest.TestCase): set_perpetual_inventory(0) self.assertTrue(not cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))) - wrapper = frappe.get_doc(copy=test_records[0]) + wrapper = frappe.copy_doc(test_records[0]) wrapper.insert() wrapper.submit() wrapper.load_from_db() @@ -45,7 +45,7 @@ class TestPurchaseInvoice(unittest.TestCase): set_perpetual_inventory(1) self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1) - pi = frappe.get_doc(copy=test_records[1]) + pi = frappe.copy_doc(test_records[1]) pi.insert() pi.submit() @@ -73,7 +73,7 @@ class TestPurchaseInvoice(unittest.TestCase): set_perpetual_inventory() self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1) - pi = frappe.get_doc(copy=test_records[1]) + pi = frappe.copy_doc(test_records[1]) pi.doclist[1].item_code = "_Test Non Stock Item" pi.doclist[1].expense_account = "_Test Account Cost for Goods Sold - _TC" pi.doclist.pop(2) @@ -99,7 +99,7 @@ class TestPurchaseInvoice(unittest.TestCase): set_perpetual_inventory(0) def test_purchase_invoice_calculation(self): - wrapper = frappe.get_doc(copy=test_records[0]) + wrapper = frappe.copy_doc(test_records[0]) wrapper.insert() wrapper.load_from_db() @@ -132,7 +132,7 @@ class TestPurchaseInvoice(unittest.TestCase): self.assertEqual(tax.total, expected_values[i][2]) def test_purchase_invoice_with_subcontracted_item(self): - wrapper = frappe.get_doc(copy=test_records[0]) + wrapper = frappe.copy_doc(test_records[0]) wrapper.doclist[1].item_code = "_Test FG Item" wrapper.insert() wrapper.load_from_db() @@ -169,11 +169,11 @@ class TestPurchaseInvoice(unittest.TestCase): from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \ import test_records as jv_test_records - jv = frappe.get_doc(copy=jv_test_records[1]) + jv = frappe.copy_doc(jv_test_records[1]) jv.insert() jv.submit() - pi = frappe.get_doc(copy=test_records[0]) + pi = frappe.copy_doc(test_records[0]) pi.append("advance_allocation_details", { "journal_voucher": jv.name, "jv_detail_no": jv.doclist[1].name, @@ -198,212 +198,4 @@ class TestPurchaseInvoice(unittest.TestCase): self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail` where against_voucher=%s""", pi.name)) -test_records = [ - [ - # parent - { - "doctype": "Purchase Invoice", - "naming_series": "BILL", - "supplier_name": "_Test Supplier", - "credit_to": "_Test Supplier - _TC", - "bill_no": "NA", - "posting_date": "2013-02-03", - "fiscal_year": "_Test Fiscal Year 2013", - "company": "_Test Company", - "currency": "INR", - "conversion_rate": 1, - "grand_total_import": 0, # for feed - "buying_price_list": "_Test Price List" - }, - # items - { - "doctype": "Purchase Invoice Item", - "parentfield": "entries", - "item_code": "_Test Item Home Desktop 100", - "item_name": "_Test Item Home Desktop 100", - "qty": 10, - "rate": 50, - "amount": 500, - "base_rate": 50, - "base_amount": 500, - "uom": "_Test UOM", - "item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}), - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "cost_center": "_Test Cost Center - _TC", - "conversion_factor": 1.0, - - }, - { - "doctype": "Purchase Invoice Item", - "parentfield": "entries", - "item_code": "_Test Item Home Desktop 200", - "item_name": "_Test Item Home Desktop 200", - "qty": 5, - "rate": 150, - "amount": 750, - "base_rate": 150, - "base_amount": 750, - "uom": "_Test UOM", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "cost_center": "_Test Cost Center - _TC", - "conversion_factor": 1.0, - }, - # taxes - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "Actual", - "account_head": "_Test Account Shipping Charges - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Shipping Charges", - "category": "Valuation and Total", - "add_deduct_tax": "Add", - "rate": 100 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account Customs Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Customs Duty", - "category": "Valuation", - "add_deduct_tax": "Add", - "rate": 10 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account Excise Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Excise Duty", - "category": "Total", - "add_deduct_tax": "Add", - "rate": 12 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Amount", - "account_head": "_Test Account Education Cess - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Education Cess", - "category": "Total", - "add_deduct_tax": "Add", - "rate": 2, - "row_id": 3 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Amount", - "account_head": "_Test Account S&H Education Cess - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "S&H Education Cess", - "category": "Total", - "add_deduct_tax": "Add", - "rate": 1, - "row_id": 3 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Total", - "account_head": "_Test Account CST - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "CST", - "category": "Total", - "add_deduct_tax": "Add", - "rate": 2, - "row_id": 5 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account VAT - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "VAT", - "category": "Total", - "add_deduct_tax": "Add", - "rate": 12.5 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Total", - "account_head": "_Test Account Discount - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Discount", - "category": "Total", - "add_deduct_tax": "Deduct", - "rate": 10, - "row_id": 7 - }, - ], - [ - # parent - { - "doctype": "Purchase Invoice", - "naming_series": "_T-Purchase Invoice-", - "supplier_name": "_Test Supplier", - "credit_to": "_Test Supplier - _TC", - "bill_no": "NA", - "posting_date": "2013-02-03", - "fiscal_year": "_Test Fiscal Year 2013", - "company": "_Test Company", - "currency": "INR", - "conversion_rate": 1.0, - "grand_total_import": 0, # for feed - "buying_price_list": "_Test Price List" - }, - # items - { - "doctype": "Purchase Invoice Item", - "parentfield": "entries", - "item_code": "_Test Item", - "item_name": "_Test Item", - "qty": 10.0, - "rate": 50.0, - "uom": "_Test UOM", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "cost_center": "_Test Cost Center - _TC", - "conversion_factor": 1.0, - }, - # taxes - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "Actual", - "account_head": "_Test Account Shipping Charges - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Shipping Charges", - "category": "Valuation and Total", - "add_deduct_tax": "Add", - "rate": 100.0 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "Actual", - "account_head": "_Test Account VAT - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "VAT", - "category": "Total", - "add_deduct_tax": "Add", - "rate": 120.0 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "Actual", - "account_head": "_Test Account Customs Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Customs Duty", - "category": "Valuation", - "add_deduct_tax": "Add", - "rate": 150.0 - }, - ] -] \ No newline at end of file +test_records = frappe.get_test_records('Purchase Invoice') \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.txt b/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.json similarity index 100% rename from erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.txt rename to erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.json diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.txt b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json similarity index 100% rename from erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.txt rename to erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json similarity index 100% rename from erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt rename to erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.txt b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.json similarity index 100% rename from erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.txt rename to erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.json diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json similarity index 100% rename from erpnext/accounts/doctype/sales_invoice/sales_invoice.txt rename to erpnext/accounts/doctype/sales_invoice/sales_invoice.json diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 5bb8df81b55..d55d3a56760 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -11,7 +11,6 @@ from frappe.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdate, from frappe.utils import comma_and from frappe.model.naming import make_autoname -from frappe.model.code import get_obj from frappe import _, msgprint from erpnext.accounts.party import get_party_account, get_due_date @@ -78,7 +77,7 @@ class SalesInvoice(SellingController): else: # Check for Approving Authority if not self.recurring_id: - get_obj('Authorization Control').validate_approving_authority(self.doctype, + frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.grand_total, self) self.check_prev_docstatus() diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 87c8923887d..4e366b3e5f4 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -10,14 +10,14 @@ from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_per class TestSalesInvoice(unittest.TestCase): def make(self): - w = frappe.get_doc(copy=test_records[0]) + w = frappe.copy_doc(test_records[0]) w.is_pos = 0 w.insert() w.submit() return w def test_double_submission(self): - w = frappe.get_doc(copy=test_records[0]) + w = frappe.copy_doc(test_records[0]) w.docstatus = '0' w.insert() @@ -28,7 +28,7 @@ class TestSalesInvoice(unittest.TestCase): self.assertRaises(DocstatusTransitionError, w.submit) def test_timestamp_change(self): - w = frappe.get_doc(copy=test_records[0]) + w = frappe.copy_doc(test_records[0]) w.docstatus = '0' w.insert() @@ -43,7 +43,7 @@ class TestSalesInvoice(unittest.TestCase): self.assertRaises(TimestampMismatchError, w2.save) def test_sales_invoice_calculation_base_currency(self): - si = frappe.get_doc(copy=test_records[2]) + si = frappe.copy_doc(test_records[2]) si.insert() expected_values = { @@ -87,7 +87,7 @@ class TestSalesInvoice(unittest.TestCase): self.assertEquals(si.grand_total_export, 1627.05) def test_sales_invoice_calculation_export_currency(self): - si = frappe.get_doc(copy=test_records[2]) + si = frappe.copy_doc(test_records[2]) si.currency = "USD" si.conversion_rate = 50 si.doclist[1].rate = 1 @@ -137,7 +137,7 @@ class TestSalesInvoice(unittest.TestCase): self.assertEquals(si.grand_total_export, 32.54) def test_sales_invoice_discount_amount(self): - si = frappe.get_doc(copy=test_records[3]) + si = frappe.copy_doc(test_records[3]) si.discount_amount = 104.95 si.append("other_charges", { "doctype": "Sales Taxes and Charges", @@ -192,7 +192,7 @@ class TestSalesInvoice(unittest.TestCase): self.assertEquals(si.grand_total_export, 1500) def test_discount_amount_gl_entry(self): - si = frappe.get_doc(copy=test_records[3]) + si = frappe.copy_doc(test_records[3]) si.discount_amount = 104.95 si.append("other_charges", { "doctype": "Sales Taxes and Charges", @@ -240,7 +240,7 @@ class TestSalesInvoice(unittest.TestCase): self.assertFalse(gle) def test_inclusive_rate_validations(self): - si = frappe.get_doc(copy=test_records[2]) + si = frappe.copy_doc(test_records[2]) for i, tax in enumerate(si.get("other_charges")): tax.idx = i+1 @@ -258,7 +258,7 @@ class TestSalesInvoice(unittest.TestCase): def test_sales_invoice_calculation_base_currency_with_tax_inclusive_price(self): # prepare - si = frappe.get_doc(copy=test_records[3]) + si = frappe.copy_doc(test_records[3]) si.insert() expected_values = { @@ -303,7 +303,7 @@ class TestSalesInvoice(unittest.TestCase): def test_sales_invoice_calculation_export_currency_with_tax_inclusive_price(self): # prepare - si = frappe.get_doc(copy=test_records[3]) + si = frappe.copy_doc(test_records[3]) si.currency = "USD" si.conversion_rate = 50 si.doclist[1].price_list_rate = 55.56 @@ -403,7 +403,7 @@ class TestSalesInvoice(unittest.TestCase): def test_sales_invoice_gl_entry_without_aii(self): self.clear_stock_account_balance() set_perpetual_inventory(0) - si = frappe.get_doc(copy=test_records[1]) + si = frappe.copy_doc(test_records[1]) si.insert() si.submit() @@ -447,7 +447,7 @@ class TestSalesInvoice(unittest.TestCase): pos[0]["cash_bank_account"] = "_Test Account Bank Account - _TC" pos[0]["paid_amount"] = 600.0 - si = frappe.get_doc(copy=pos) + si = frappe.copy_doc(pos) si.insert() si.submit() @@ -500,7 +500,7 @@ class TestSalesInvoice(unittest.TestCase): # insert purchase receipt from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import test_records \ as pr_test_records - pr = frappe.get_doc(copy=pr_test_records[0]) + pr = frappe.copy_doc(pr_test_records[0]) pr.naming_series = "_T-Purchase Receipt-" pr.doclist[1].warehouse = "_Test Warehouse No Account - _TC" pr.insert() @@ -511,7 +511,7 @@ class TestSalesInvoice(unittest.TestCase): si_doclist[0]["posting_time"] = "12:05" si_doclist[1]["warehouse"] = "_Test Warehouse No Account - _TC" - si = frappe.get_doc(copy=si_doclist) + si = frappe.copy_doc(si_doclist) si.insert() si.submit() @@ -605,7 +605,7 @@ class TestSalesInvoice(unittest.TestCase): def _insert_purchase_receipt(self): from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import test_records \ as pr_test_records - pr = frappe.get_doc(copy=pr_test_records[0]) + pr = frappe.copy_doc(pr_test_records[0]) pr.naming_series = "_T-Purchase Receipt-" pr.insert() pr.submit() @@ -613,7 +613,7 @@ class TestSalesInvoice(unittest.TestCase): def _insert_delivery_note(self): from erpnext.stock.doctype.delivery_note.test_delivery_note import test_records \ as dn_test_records - dn = frappe.get_doc(copy=dn_test_records[0]) + dn = frappe.copy_doc(dn_test_records[0]) dn.naming_series = "_T-Delivery Note-" dn.insert() dn.submit() @@ -624,18 +624,18 @@ class TestSalesInvoice(unittest.TestCase): import test_records as pos_setting_test_records frappe.db.sql("""delete from `tabPOS Setting`""") - ps = frappe.get_doc(copy=pos_setting_test_records[0]) + ps = frappe.copy_doc(pos_setting_test_records[0]) ps.insert() def test_sales_invoice_with_advance(self): from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \ import test_records as jv_test_records - jv = frappe.get_doc(copy=jv_test_records[0]) + jv = frappe.copy_doc(jv_test_records[0]) jv.insert() jv.submit() - si = frappe.get_doc(copy=test_records[0]) + si = frappe.copy_doc(test_records[0]) si.append("advance_adjustment_details", { "doctype": "Sales Invoice Advance", "journal_voucher": jv.name, @@ -665,7 +665,7 @@ class TestSalesInvoice(unittest.TestCase): from frappe.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate from erpnext.accounts.utils import get_fiscal_year today = nowdate() - base_si = frappe.get_doc(copy=test_records[0]) + base_si = frappe.copy_doc(test_records[0]) base_si.update({ "convert_into_recurring_invoice": 1, "recurring_type": "Monthly", @@ -678,13 +678,13 @@ class TestSalesInvoice(unittest.TestCase): }) # monthly - si1 = frappe.get_doc(copy=base_si.doclist) + si1 = frappe.copy_doc(base_si.doclist) si1.insert() si1.submit() self._test_recurring_invoice(si1, True) # monthly without a first and last day period - si2 = frappe.get_doc(copy=base_si.doclist) + si2 = frappe.copy_doc(base_si.doclist) si2.update({ "invoice_period_from_date": today, "invoice_period_to_date": add_to_date(today, days=30) @@ -694,7 +694,7 @@ class TestSalesInvoice(unittest.TestCase): self._test_recurring_invoice(si2, False) # quarterly - si3 = frappe.get_doc(copy=base_si.doclist) + si3 = frappe.copy_doc(base_si.doclist) si3.update({ "recurring_type": "Quarterly", "invoice_period_from_date": get_first_day(today), @@ -705,7 +705,7 @@ class TestSalesInvoice(unittest.TestCase): self._test_recurring_invoice(si3, True) # quarterly without a first and last day period - si4 = frappe.get_doc(copy=base_si.doclist) + si4 = frappe.copy_doc(base_si.doclist) si4.update({ "recurring_type": "Quarterly", "invoice_period_from_date": today, @@ -716,7 +716,7 @@ class TestSalesInvoice(unittest.TestCase): self._test_recurring_invoice(si4, False) # yearly - si5 = frappe.get_doc(copy=base_si.doclist) + si5 = frappe.copy_doc(base_si.doclist) si5.update({ "recurring_type": "Yearly", "invoice_period_from_date": get_first_day(today), @@ -727,7 +727,7 @@ class TestSalesInvoice(unittest.TestCase): self._test_recurring_invoice(si5, True) # yearly without a first and last day period - si6 = frappe.get_doc(copy=base_si.doclist) + si6 = frappe.copy_doc(base_si.doclist) si6.update({ "recurring_type": "Yearly", "invoice_period_from_date": today, @@ -738,7 +738,7 @@ class TestSalesInvoice(unittest.TestCase): self._test_recurring_invoice(si6, False) # change posting date but keep recuring day to be today - si7 = frappe.get_doc(copy=base_si.doclist) + si7 = frappe.copy_doc(base_si.doclist) si7.update({ "posting_date": add_to_date(today, days=-1) }) @@ -811,7 +811,7 @@ class TestSalesInvoice(unittest.TestCase): se = make_serialized_item() serial_nos = get_serial_nos(se.doclist[1].serial_no) - si = frappe.get_doc(copy=test_records[0]) + si = frappe.copy_doc(test_records[0]) si.update_stock = 1 si.doclist[1].item_code = "_Test Serialized Item With Series" si.doclist[1].qty = 1 @@ -849,7 +849,7 @@ class TestSalesInvoice(unittest.TestCase): sr.status = "Not Available" sr.save() - si = frappe.get_doc(copy=test_records[0]) + si = frappe.copy_doc(test_records[0]) si.update_stock = 1 si.doclist[1].item_code = "_Test Serialized Item With Series" si.doclist[1].qty = 1 @@ -860,386 +860,4 @@ class TestSalesInvoice(unittest.TestCase): test_dependencies = ["Journal Voucher", "POS Setting", "Contact", "Address"] -test_records = [ - [ - { - "naming_series": "_T-Sales Invoice-", - "company": "_Test Company", - "is_pos": 0, - "conversion_rate": 1.0, - "currency": "INR", - "debit_to": "_Test Customer - _TC", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "doctype": "Sales Invoice", - "due_date": "2013-01-23", - "fiscal_year": "_Test Fiscal Year 2013", - "grand_total": 561.8, - "grand_total_export": 561.8, - "net_total": 500.0, - "plc_conversion_rate": 1.0, - "posting_date": "2013-01-23", - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", - "territory": "_Test Territory" - }, - { - "base_amount": 500.0, - "base_rate": 500.0, - "description": "138-CMS Shoe", - "doctype": "Sales Invoice Item", - "amount": 500.0, - "rate": 500.0, - "income_account": "Sales - _TC", - "cost_center": "_Test Cost Center - _TC", - "item_name": "138-CMS Shoe", - "parentfield": "entries", - "qty": 1.0 - }, - { - "account_head": "_Test Account VAT - _TC", - "charge_type": "On Net Total", - "description": "VAT", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 6, - }, - { - "account_head": "_Test Account Service Tax - _TC", - "charge_type": "On Net Total", - "description": "Service Tax", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 6.36, - }, - { - "parentfield": "sales_team", - "doctype": "Sales Team", - "sales_person": "_Test Sales Person 1", - "allocated_percentage": 65.5, - }, - { - "parentfield": "sales_team", - "doctype": "Sales Team", - "sales_person": "_Test Sales Person 2", - "allocated_percentage": 34.5, - }, - ], - [ - { - "naming_series": "_T-Sales Invoice-", - "company": "_Test Company", - "is_pos": 0, - "conversion_rate": 1.0, - "currency": "INR", - "debit_to": "_Test Customer - _TC", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "doctype": "Sales Invoice", - "due_date": "2013-01-23", - "fiscal_year": "_Test Fiscal Year 2013", - "grand_total": 630.0, - "grand_total_export": 630.0, - "net_total": 500.0, - "plc_conversion_rate": 1.0, - "posting_date": "2013-03-07", - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", - "territory": "_Test Territory" - }, - { - "item_code": "_Test Item", - "item_name": "_Test Item", - "description": "_Test Item", - "doctype": "Sales Invoice Item", - "parentfield": "entries", - "qty": 1.0, - "base_rate": 500.0, - "base_amount": 500.0, - "price_list_rate": 500.0, - "amount": 500.0, - "income_account": "Sales - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "cost_center": "_Test Cost Center - _TC", - }, - { - "account_head": "_Test Account VAT - _TC", - "charge_type": "On Net Total", - "description": "VAT", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 16, - }, - { - "account_head": "_Test Account Service Tax - _TC", - "charge_type": "On Net Total", - "description": "Service Tax", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 10 - } - ], - [ - { - "naming_series": "_T-Sales Invoice-", - "company": "_Test Company", - "is_pos": 0, - "conversion_rate": 1.0, - "currency": "INR", - "debit_to": "_Test Customer - _TC", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "doctype": "Sales Invoice", - "due_date": "2013-01-23", - "fiscal_year": "_Test Fiscal Year 2013", - "grand_total_export": 0, - "plc_conversion_rate": 1.0, - "posting_date": "2013-01-23", - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", - "territory": "_Test Territory", - }, - # items - { - "doctype": "Sales Invoice Item", - "parentfield": "entries", - "item_code": "_Test Item Home Desktop 100", - "item_name": "_Test Item Home Desktop 100", - "qty": 10, - "price_list_rate": 50, - "rate": 50, - "stock_uom": "_Test UOM", - "item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}), - "income_account": "Sales - _TC", - "cost_center": "_Test Cost Center - _TC", - - }, - { - "doctype": "Sales Invoice Item", - "parentfield": "entries", - "item_code": "_Test Item Home Desktop 200", - "item_name": "_Test Item Home Desktop 200", - "qty": 5, - "price_list_rate": 150, - "rate": 150, - "stock_uom": "_Test UOM", - "income_account": "Sales - _TC", - "cost_center": "_Test Cost Center - _TC", - - }, - # taxes - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "Actual", - "account_head": "_Test Account Shipping Charges - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Shipping Charges", - "rate": 100 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account Customs Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Customs Duty", - "rate": 10 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account Excise Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Excise Duty", - "rate": 12 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Amount", - "account_head": "_Test Account Education Cess - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Education Cess", - "rate": 2, - "row_id": 3 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Amount", - "account_head": "_Test Account S&H Education Cess - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "S&H Education Cess", - "rate": 1, - "row_id": 3 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Total", - "account_head": "_Test Account CST - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "CST", - "rate": 2, - "row_id": 5 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account VAT - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "VAT", - "rate": 12.5 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Total", - "account_head": "_Test Account Discount - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Discount", - "rate": -10, - "row_id": 7 - }, - ], - [ - { - "naming_series": "_T-Sales Invoice-", - "company": "_Test Company", - "is_pos": 0, - "conversion_rate": 1.0, - "currency": "INR", - "debit_to": "_Test Customer - _TC", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "doctype": "Sales Invoice", - "due_date": "2013-01-23", - "fiscal_year": "_Test Fiscal Year 2013", - "grand_total_export": 0, - "plc_conversion_rate": 1.0, - "posting_date": "2013-01-23", - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", - "territory": "_Test Territory", - }, - # items - { - "doctype": "Sales Invoice Item", - "parentfield": "entries", - "item_code": "_Test Item Home Desktop 100", - "item_name": "_Test Item Home Desktop 100", - "qty": 10, - "price_list_rate": 62.5, - "stock_uom": "_Test UOM", - "item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}), - "income_account": "Sales - _TC", - "cost_center": "_Test Cost Center - _TC", - - }, - { - "doctype": "Sales Invoice Item", - "parentfield": "entries", - "item_code": "_Test Item Home Desktop 200", - "item_name": "_Test Item Home Desktop 200", - "qty": 5, - "price_list_rate": 190.66, - "stock_uom": "_Test UOM", - "income_account": "Sales - _TC", - "cost_center": "_Test Cost Center - _TC", - - }, - # taxes - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account Excise Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Excise Duty", - "rate": 12, - "included_in_print_rate": 1, - "idx": 1 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Amount", - "account_head": "_Test Account Education Cess - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Education Cess", - "rate": 2, - "row_id": 1, - "included_in_print_rate": 1, - "idx": 2 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Amount", - "account_head": "_Test Account S&H Education Cess - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "S&H Education Cess", - "rate": 1, - "row_id": 1, - "included_in_print_rate": 1, - "idx": 3 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Total", - "account_head": "_Test Account CST - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "CST", - "rate": 2, - "row_id": 3, - "included_in_print_rate": 1, - "idx": 4 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account VAT - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "VAT", - "rate": 12.5, - "included_in_print_rate": 1, - "idx": 5 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account Customs Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Customs Duty", - "rate": 10, - "idx": 6 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "Actual", - "account_head": "_Test Account Shipping Charges - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Shipping Charges", - "rate": 100, - "idx": 7 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Total", - "account_head": "_Test Account Discount - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Discount", - "rate": -10, - "row_id": 7, - "idx": 8 - }, - ], -] \ No newline at end of file +test_records = frappe.get_test_records('Sales Invoice') \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.txt b/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.json similarity index 100% rename from erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.txt rename to erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.json diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.txt b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json similarity index 100% rename from erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.txt rename to erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json similarity index 100% rename from erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt rename to erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.json similarity index 100% rename from erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt rename to erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.json diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_master/test_sales_taxes_and_charges_master.py b/erpnext/accounts/doctype/sales_taxes_and_charges_master/test_sales_taxes_and_charges_master.py index 670edc44e00..e31474d37f1 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_master/test_sales_taxes_and_charges_master.py +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_master/test_sales_taxes_and_charges_master.py @@ -1,154 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [ - { - "doctype": "Sales Taxes and Charges Master", - "title": "_Test Sales Taxes and Charges Master", - "company": "_Test Company" - }, - { - "account_head": "_Test Account VAT - _TC", - "charge_type": "On Net Total", - "description": "VAT", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 6, - }, - { - "account_head": "_Test Account Service Tax - _TC", - "charge_type": "On Net Total", - "description": "Service Tax", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 6.36, - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "All Territories" - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory Rest Of The World" - } - ], - [ - { - "doctype": "Sales Taxes and Charges Master", - "title": "_Test India Tax Master", - "company": "_Test Company" - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "Actual", - "account_head": "_Test Account Shipping Charges - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Shipping Charges", - "rate": 100 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account Customs Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Customs Duty", - "rate": 10 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account Excise Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Excise Duty", - "rate": 12 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Amount", - "account_head": "_Test Account Education Cess - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Education Cess", - "rate": 2, - "row_id": 3 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Amount", - "account_head": "_Test Account S&H Education Cess - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "S&H Education Cess", - "rate": 1, - "row_id": 3 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Total", - "account_head": "_Test Account CST - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "CST", - "rate": 2, - "row_id": 5 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account VAT - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "VAT", - "rate": 12.5 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Total", - "account_head": "_Test Account Discount - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Discount", - "rate": -10, - "row_id": 7 - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory India" - } - ], - [ - { - "doctype": "Sales Taxes and Charges Master", - "title": "_Test Sales Taxes and Charges Master - Rest of the World", - "company": "_Test Company" - }, - { - "account_head": "_Test Account VAT - _TC", - "charge_type": "On Net Total", - "description": "VAT", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 12, - }, - { - "account_head": "_Test Account Service Tax - _TC", - "charge_type": "On Net Total", - "description": "Service Tax", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 4, - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory Rest Of The World" - } - ], -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Sales Taxes And Charges Master') \ No newline at end of file diff --git a/erpnext/accounts/doctype/shipping_rule/shipping_rule.txt b/erpnext/accounts/doctype/shipping_rule/shipping_rule.json similarity index 100% rename from erpnext/accounts/doctype/shipping_rule/shipping_rule.txt rename to erpnext/accounts/doctype/shipping_rule/shipping_rule.json diff --git a/erpnext/accounts/doctype/shipping_rule/test_shipping_rule.py b/erpnext/accounts/doctype/shipping_rule/test_shipping_rule.py index fe763e74385..0f41a567cd5 100644 --- a/erpnext/accounts/doctype/shipping_rule/test_shipping_rule.py +++ b/erpnext/accounts/doctype/shipping_rule/test_shipping_rule.py @@ -7,12 +7,12 @@ from erpnext.accounts.doctype.shipping_rule.shipping_rule import FromGreaterThan class TestShippingRule(unittest.TestCase): def test_from_greater_than_to(self): - shipping_rule = frappe.get_doc(copy=test_records[0]) + shipping_rule = frappe.copy_doc(test_records[0]) shipping_rule.doclist[1].from_value = 101 self.assertRaises(FromGreaterThanToError, shipping_rule.insert) def test_many_zero_to_values(self): - shipping_rule = frappe.get_doc(copy=test_records[0]) + shipping_rule = frappe.copy_doc(test_records[0]) shipping_rule.doclist[1].to_value = 0 self.assertRaises(ManyBlankToValuesError, shipping_rule.insert) @@ -24,120 +24,11 @@ class TestShippingRule(unittest.TestCase): ((50, 150), (25, 175)), ((50, 150), (50, 150)), ]: - shipping_rule = frappe.get_doc(copy=test_records[0]) + shipping_rule = frappe.copy_doc(test_records[0]) shipping_rule.doclist[1].from_value = range_a[0] shipping_rule.doclist[1].to_value = range_a[1] shipping_rule.doclist[2].from_value = range_b[0] shipping_rule.doclist[2].to_value = range_b[1] self.assertRaises(OverlappingConditionError, shipping_rule.insert) -test_records = [ - [ - { - "doctype": "Shipping Rule", - "label": "_Test Shipping Rule", - "name": "_Test Shipping Rule", - "calculate_based_on": "Net Total", - "company": "_Test Company", - "account": "_Test Account Shipping Charges - _TC", - "cost_center": "_Test Cost Center - _TC" - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 0, - "to_value": 100, - "shipping_amount": 50.0 - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 101, - "to_value": 200, - "shipping_amount": 100.0 - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 201, - "shipping_amount": 0.0 - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory" - } - ], - [ - { - "doctype": "Shipping Rule", - "name": "_Test Shipping Rule - India", - "label": "_Test Shipping Rule - India", - "calculate_based_on": "Net Total", - "company": "_Test Company", - "account": "_Test Account Shipping Charges - _TC", - "cost_center": "_Test Cost Center - _TC" - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 0, - "to_value": 100, - "shipping_amount": 50.0 - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 101, - "to_value": 200, - "shipping_amount": 100.0 - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 201, - "shipping_amount": 0.0 - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory India" - } - ], - [ - { - "doctype": "Shipping Rule", - "name": "_Test Shipping Rule - Rest of the World", - "label": "_Test Shipping Rule - Rest of the World", - "calculate_based_on": "Net Total", - "company": "_Test Company", - "account": "_Test Account Shipping Charges - _TC", - "cost_center": "_Test Cost Center - _TC" - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 0, - "to_value": 1000, - "shipping_amount": 500.0 - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 1001, - "to_value": 2000, - "shipping_amount": 1000.0 - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 2001, - "shipping_amount": 1500.0 - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory Rest Of The World" - } - ], -] \ No newline at end of file +test_records = frappe.get_test_records('Shipping Rule') \ No newline at end of file diff --git a/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.txt b/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.json similarity index 100% rename from erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.txt rename to erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.json diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.txt b/erpnext/accounts/page/accounts_browser/accounts_browser.json similarity index 100% rename from erpnext/accounts/page/accounts_browser/accounts_browser.txt rename to erpnext/accounts/page/accounts_browser/accounts_browser.json diff --git a/erpnext/accounts/page/financial_analytics/financial_analytics.txt b/erpnext/accounts/page/financial_analytics/financial_analytics.json similarity index 100% rename from erpnext/accounts/page/financial_analytics/financial_analytics.txt rename to erpnext/accounts/page/financial_analytics/financial_analytics.json diff --git a/erpnext/accounts/page/trial_balance/trial_balance.txt b/erpnext/accounts/page/trial_balance/trial_balance.json similarity index 100% rename from erpnext/accounts/page/trial_balance/trial_balance.txt rename to erpnext/accounts/page/trial_balance/trial_balance.json diff --git a/erpnext/accounts/report/accounts_payable/accounts_payable.txt b/erpnext/accounts/report/accounts_payable/accounts_payable.json similarity index 100% rename from erpnext/accounts/report/accounts_payable/accounts_payable.txt rename to erpnext/accounts/report/accounts_payable/accounts_payable.json diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.txt b/erpnext/accounts/report/accounts_receivable/accounts_receivable.json similarity index 100% rename from erpnext/accounts/report/accounts_receivable/accounts_receivable.txt rename to erpnext/accounts/report/accounts_receivable/accounts_receivable.json diff --git a/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.txt b/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.json similarity index 100% rename from erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.txt rename to erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.json diff --git a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.txt b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.json similarity index 100% rename from erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.txt rename to erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.json diff --git a/erpnext/accounts/report/budget_variance_report/budget_variance_report.txt b/erpnext/accounts/report/budget_variance_report/budget_variance_report.json similarity index 100% rename from erpnext/accounts/report/budget_variance_report/budget_variance_report.txt rename to erpnext/accounts/report/budget_variance_report/budget_variance_report.json diff --git a/erpnext/accounts/report/customer_account_head/customer_account_head.txt b/erpnext/accounts/report/customer_account_head/customer_account_head.json similarity index 100% rename from erpnext/accounts/report/customer_account_head/customer_account_head.txt rename to erpnext/accounts/report/customer_account_head/customer_account_head.json diff --git a/erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.txt b/erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.json similarity index 100% rename from erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.txt rename to erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.json diff --git a/erpnext/accounts/report/general_ledger/general_ledger.txt b/erpnext/accounts/report/general_ledger/general_ledger.json similarity index 100% rename from erpnext/accounts/report/general_ledger/general_ledger.txt rename to erpnext/accounts/report/general_ledger/general_ledger.json diff --git a/erpnext/accounts/report/gross_profit/gross_profit.txt b/erpnext/accounts/report/gross_profit/gross_profit.json similarity index 100% rename from erpnext/accounts/report/gross_profit/gross_profit.txt rename to erpnext/accounts/report/gross_profit/gross_profit.json diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.txt b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.json similarity index 100% rename from erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.txt rename to erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.json diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.txt b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.json similarity index 100% rename from erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.txt rename to erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.json diff --git a/erpnext/accounts/report/ordered_items_to_be_billed/ordered_items_to_be_billed.txt b/erpnext/accounts/report/ordered_items_to_be_billed/ordered_items_to_be_billed.json similarity index 100% rename from erpnext/accounts/report/ordered_items_to_be_billed/ordered_items_to_be_billed.txt rename to erpnext/accounts/report/ordered_items_to_be_billed/ordered_items_to_be_billed.json diff --git a/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.txt b/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.json similarity index 100% rename from erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.txt rename to erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.json diff --git a/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.txt b/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.json similarity index 100% rename from erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.txt rename to erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.json diff --git a/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.txt b/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.json similarity index 100% rename from erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.txt rename to erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.json diff --git a/erpnext/accounts/report/purchase_register/purchase_register.txt b/erpnext/accounts/report/purchase_register/purchase_register.json similarity index 100% rename from erpnext/accounts/report/purchase_register/purchase_register.txt rename to erpnext/accounts/report/purchase_register/purchase_register.json diff --git a/erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.txt b/erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.json similarity index 100% rename from erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.txt rename to erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.json diff --git a/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.txt b/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.json similarity index 100% rename from erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.txt rename to erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.json diff --git a/erpnext/accounts/report/sales_partners_commission/sales_partners_commission.txt b/erpnext/accounts/report/sales_partners_commission/sales_partners_commission.json similarity index 100% rename from erpnext/accounts/report/sales_partners_commission/sales_partners_commission.txt rename to erpnext/accounts/report/sales_partners_commission/sales_partners_commission.json diff --git a/erpnext/accounts/report/sales_register/sales_register.txt b/erpnext/accounts/report/sales_register/sales_register.json similarity index 100% rename from erpnext/accounts/report/sales_register/sales_register.txt rename to erpnext/accounts/report/sales_register/sales_register.json diff --git a/erpnext/accounts/report/supplier_account_head/supplier_account_head.txt b/erpnext/accounts/report/supplier_account_head/supplier_account_head.json similarity index 100% rename from erpnext/accounts/report/supplier_account_head/supplier_account_head.txt rename to erpnext/accounts/report/supplier_account_head/supplier_account_head.json diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index e0c1e3ac127..b096cbf0c2c 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -138,14 +138,14 @@ def reconcile_against_document(args): d['against_fld'] = against_fld[d['against_voucher_type']] # cancel JV - jv_obj = frappe.get_obj('Journal Voucher', d['voucher_no'], with_children=1) + jv_obj = frappe.get_doc('Journal Voucher', d['voucher_no']) jv_obj.make_gl_entries(cancel=1, adv_adj=1) # update ref in JV Detail update_against_doc(d, jv_obj) # re-submit JV - jv_obj = frappe.get_obj('Journal Voucher', d['voucher_no'], with_children =1) + jv_obj = frappe.get_doc('Journal Voucher', d['voucher_no']) jv_obj.make_gl_entries(cancel = 0, adv_adj =1) diff --git a/erpnext/buying/Print Format/Purchase Order Classic/Purchase Order Classic.txt b/erpnext/buying/Print Format/Purchase Order Classic/Purchase Order Classic.json similarity index 100% rename from erpnext/buying/Print Format/Purchase Order Classic/Purchase Order Classic.txt rename to erpnext/buying/Print Format/Purchase Order Classic/Purchase Order Classic.json diff --git a/erpnext/buying/Print Format/Purchase Order Modern/Purchase Order Modern.txt b/erpnext/buying/Print Format/Purchase Order Modern/Purchase Order Modern.json similarity index 100% rename from erpnext/buying/Print Format/Purchase Order Modern/Purchase Order Modern.txt rename to erpnext/buying/Print Format/Purchase Order Modern/Purchase Order Modern.json diff --git a/erpnext/buying/Print Format/Purchase Order Spartan/Purchase Order Spartan.txt b/erpnext/buying/Print Format/Purchase Order Spartan/Purchase Order Spartan.json similarity index 100% rename from erpnext/buying/Print Format/Purchase Order Spartan/Purchase Order Spartan.txt rename to erpnext/buying/Print Format/Purchase Order Spartan/Purchase Order Spartan.json diff --git a/erpnext/buying/doctype/buying_settings/buying_settings.txt b/erpnext/buying/doctype/buying_settings/buying_settings.json similarity index 100% rename from erpnext/buying/doctype/buying_settings/buying_settings.txt rename to erpnext/buying/doctype/buying_settings/buying_settings.json diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.txt b/erpnext/buying/doctype/purchase_common/purchase_common.json similarity index 100% rename from erpnext/buying/doctype/purchase_common/purchase_common.txt rename to erpnext/buying/doctype/purchase_common/purchase_common.json diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.txt b/erpnext/buying/doctype/purchase_order/purchase_order.json similarity index 100% rename from erpnext/buying/doctype/purchase_order/purchase_order.txt rename to erpnext/buying/doctype/purchase_order/purchase_order.json diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index f6ef8a2474e..b8504977f6a 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -6,7 +6,6 @@ import frappe from frappe.utils import cstr, flt -from frappe.model.code import get_obj from frappe import msgprint @@ -36,7 +35,7 @@ class PurchaseOrder(BuyingController): validate_status(self.status, ["Draft", "Submitted", "Stopped", "Cancelled"]) - pc_obj = get_obj(dt='Purchase Common') + pc_obj = frappe.get_doc(dt='Purchase Common') pc_obj.validate_for_items(self) self.check_for_stopped_status(pc_obj) @@ -68,7 +67,7 @@ class PurchaseOrder(BuyingController): d.prevdoc_detail_docname, "schedule_date") def get_last_purchase_rate(self): - get_obj('Purchase Common').get_last_purchase_rate(self) + frappe.get_doc('Purchase Common').get_last_purchase_rate(self) # Check for Stopped status def check_for_stopped_status(self, pc_obj): @@ -81,7 +80,7 @@ class PurchaseOrder(BuyingController): def update_bin(self, is_submit, is_stopped = 0): from erpnext.stock.utils import update_bin - pc_obj = get_obj('Purchase Common') + pc_obj = frappe.get_doc('Purchase Common') for d in self.get('po_details'): #1. Check if is_stock_item == 'Yes' if frappe.db.get_value("Item", d.item_code, "is_stock_item") == "Yes": @@ -144,12 +143,12 @@ class PurchaseOrder(BuyingController): msgprint(self.doctype + ": " + self.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status))) def on_submit(self): - purchase_controller = frappe.get_obj("Purchase Common") + purchase_controller = frappe.get_doc("Purchase Common") self.update_prevdoc_status() self.update_bin(is_submit = 1, is_stopped = 0) - get_obj('Authorization Control').validate_approving_authority(self.doctype, + frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.grand_total) purchase_controller.update_last_purchase_rate(self, is_submit = 1) @@ -157,7 +156,7 @@ class PurchaseOrder(BuyingController): frappe.db.set(self,'status','Submitted') def on_cancel(self): - pc_obj = get_obj(dt = 'Purchase Common') + pc_obj = frappe.get_doc(dt = 'Purchase Common') self.check_for_stopped_status(pc_obj) # Check if Purchase Receipt has been submitted against current Purchase Order diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py index 997d6dc88d7..0acb83688fd 100644 --- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py @@ -11,7 +11,7 @@ class TestPurchaseOrder(unittest.TestCase): def test_make_purchase_receipt(self): from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_receipt - po = frappe.get_doc(copy=test_records[0]).insert() + po = frappe.copy_doc(test_records[0]).insert() self.assertRaises(frappe.ValidationError, make_purchase_receipt, po.name) @@ -34,7 +34,7 @@ class TestPurchaseOrder(unittest.TestCase): from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_receipt - po = frappe.get_doc(copy=test_records[0]).insert() + po = frappe.copy_doc(test_records[0]).insert() self.assertRaises(frappe.ValidationError, make_purchase_receipt, po.name) @@ -77,7 +77,7 @@ class TestPurchaseOrder(unittest.TestCase): def test_make_purchase_invoice(self): from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_invoice - po = frappe.get_doc(copy=test_records[0]).insert() + po = frappe.copy_doc(test_records[0]).insert() self.assertRaises(frappe.ValidationError, make_purchase_invoice, po.name) @@ -93,58 +93,24 @@ class TestPurchaseOrder(unittest.TestCase): frappe.get_doc(pi).insert() def test_subcontracting(self): - po = frappe.get_doc(copy=test_records[0]) + po = frappe.copy_doc(test_records[0]) po.insert() self.assertEquals(len(po.get("po_raw_material_details")), 2) def test_warehouse_company_validation(self): from erpnext.stock.utils import InvalidWarehouseCompany - po = frappe.get_doc(copy=test_records[0]) + po = frappe.copy_doc(test_records[0]) po.company = "_Test Company 1" po.conversion_rate = 0.0167 self.assertRaises(InvalidWarehouseCompany, po.insert) def test_uom_integer_validation(self): from erpnext.utilities.transaction_base import UOMMustBeIntegerError - po = frappe.get_doc(copy=test_records[0]) + po = frappe.copy_doc(test_records[0]) po.doclist[1].qty = 3.4 self.assertRaises(UOMMustBeIntegerError, po.insert) test_dependencies = ["BOM"] -test_records = [ - [ - { - "company": "_Test Company", - "naming_series": "_T-Purchase Order-", - "conversion_rate": 1.0, - "currency": "INR", - "doctype": "Purchase Order", - "fiscal_year": "_Test Fiscal Year 2013", - "transaction_date": "2013-02-12", - "is_subcontracted": "Yes", - "supplier": "_Test Supplier", - "supplier_name": "_Test Supplier", - "net_total": 5000.0, - "grand_total": 5000.0, - "grand_total_import": 5000.0, - "buying_price_list": "_Test Price List" - }, - { - "conversion_factor": 1.0, - "description": "_Test FG Item", - "doctype": "Purchase Order Item", - "item_code": "_Test FG Item", - "item_name": "_Test FG Item", - "parentfield": "po_details", - "qty": 10.0, - "rate": 500.0, - "base_amount": 5000.0, - "warehouse": "_Test Warehouse - _TC", - "stock_uom": "_Test UOM", - "uom": "_Test UOM", - "schedule_date": "2013-03-01" - } - ], -] \ No newline at end of file +test_records = frappe.get_test_records('Purchase Order') \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.txt b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json similarity index 100% rename from erpnext/buying/doctype/purchase_order_item/purchase_order_item.txt rename to erpnext/buying/doctype/purchase_order_item/purchase_order_item.json diff --git a/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.txt b/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.json similarity index 100% rename from erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.txt rename to erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.json diff --git a/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.txt b/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.json similarity index 100% rename from erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.txt rename to erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.json diff --git a/erpnext/buying/doctype/quality_inspection/quality_inspection.txt b/erpnext/buying/doctype/quality_inspection/quality_inspection.json similarity index 100% rename from erpnext/buying/doctype/quality_inspection/quality_inspection.txt rename to erpnext/buying/doctype/quality_inspection/quality_inspection.json diff --git a/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.txt b/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.json similarity index 100% rename from erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.txt rename to erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.json diff --git a/erpnext/buying/doctype/supplier/supplier.txt b/erpnext/buying/doctype/supplier/supplier.json similarity index 100% rename from erpnext/buying/doctype/supplier/supplier.txt rename to erpnext/buying/doctype/supplier/supplier.json diff --git a/erpnext/buying/doctype/supplier/test_supplier.py b/erpnext/buying/doctype/supplier/test_supplier.py index d5bd4cb24b5..1f7c3e0b813 100644 --- a/erpnext/buying/doctype/supplier/test_supplier.py +++ b/erpnext/buying/doctype/supplier/test_supplier.py @@ -1,11 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Supplier", - "supplier_name": "_Test Supplier", - "supplier_type": "_Test Supplier Type", - "company": "_Test Company" - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Supplier') \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.txt b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json similarity index 100% rename from erpnext/buying/doctype/supplier_quotation/supplier_quotation.txt rename to erpnext/buying/doctype/supplier_quotation/supplier_quotation.json diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py index 6fced379a30..004954f2bc8 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals import frappe -from frappe.model.code import get_obj from erpnext.controllers.buying_controller import BuyingController class SupplierQuotation(BuyingController): @@ -48,7 +47,7 @@ class SupplierQuotation(BuyingController): def validate_common(self): - pc = get_obj('Purchase Common') + pc = frappe.get_doc('Purchase Common') pc.validate_for_items(self) @frappe.whitelist() diff --git a/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py index fc1d25d3987..d526fd15f67 100644 --- a/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py @@ -11,7 +11,7 @@ class TestPurchaseOrder(unittest.TestCase): def test_make_purchase_order(self): from erpnext.buying.doctype.supplier_quotation.supplier_quotation import make_purchase_order - sq = frappe.get_doc(copy=test_records[0]).insert() + sq = frappe.copy_doc(test_records[0]).insert() self.assertRaises(frappe.ValidationError, make_purchase_order, sq.name) @@ -31,35 +31,4 @@ class TestPurchaseOrder(unittest.TestCase): frappe.get_doc(po).insert() -test_records = [ - [ - { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "doctype": "Supplier Quotation", - "fiscal_year": "_Test Fiscal Year 2013", - "transaction_date": "2013-02-12", - "is_subcontracted": "No", - "supplier": "_Test Supplier", - "supplier_name": "_Test Supplier", - "net_total": 5000.0, - "grand_total": 5000.0, - "grand_total_import": 5000.0, - "naming_series": "_T-Supplier Quotation-", - "buying_price_list": "_Test Price List" - }, - { - "description": "_Test FG Item", - "doctype": "Supplier Quotation Item", - "item_code": "_Test FG Item", - "item_name": "_Test FG Item", - "parentfield": "quotation_items", - "qty": 10.0, - "rate": 500.0, - "base_amount": 5000.0, - "warehouse": "_Test Warehouse - _TC", - "uom": "_Test UOM", - } - ], -] \ No newline at end of file +test_records = frappe.get_test_records('Supplier Quotation') \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.txt b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json similarity index 100% rename from erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.txt rename to erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json diff --git a/erpnext/buying/page/purchase_analytics/purchase_analytics.txt b/erpnext/buying/page/purchase_analytics/purchase_analytics.json similarity index 100% rename from erpnext/buying/page/purchase_analytics/purchase_analytics.txt rename to erpnext/buying/page/purchase_analytics/purchase_analytics.json diff --git a/erpnext/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt b/erpnext/buying/report/item_wise_purchase_history/item_wise_purchase_history.json similarity index 100% rename from erpnext/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt rename to erpnext/buying/report/item_wise_purchase_history/item_wise_purchase_history.json diff --git a/erpnext/buying/report/purchase_order_trends/purchase_order_trends.txt b/erpnext/buying/report/purchase_order_trends/purchase_order_trends.json similarity index 100% rename from erpnext/buying/report/purchase_order_trends/purchase_order_trends.txt rename to erpnext/buying/report/purchase_order_trends/purchase_order_trends.json diff --git a/erpnext/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt b/erpnext/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.json similarity index 100% rename from erpnext/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt rename to erpnext/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.json diff --git a/erpnext/buying/report/supplier_addresses_and_contacts/supplier_addresses_and_contacts.txt b/erpnext/buying/report/supplier_addresses_and_contacts/supplier_addresses_and_contacts.json similarity index 100% rename from erpnext/buying/report/supplier_addresses_and_contacts/supplier_addresses_and_contacts.txt rename to erpnext/buying/report/supplier_addresses_and_contacts/supplier_addresses_and_contacts.json diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 4801c75ee84..2d54b74d078 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe from frappe import _, throw from frappe.utils import flt, cint, today, cstr -from frappe.model.code import get_obj from erpnext.setup.utils import get_company_currency from erpnext.accounts.utils import get_fiscal_year, validate_fiscal_year from erpnext.utilities.transaction_base import TransactionBase @@ -481,7 +480,7 @@ class AccountsController(TransactionBase): total_outstanding = total_outstanding[0][0] if total_outstanding else 0 if total_outstanding: - get_obj('Account', account).check_credit_limit(total_outstanding) + frappe.get_doc('Account', account).check_credit_limit(total_outstanding) @frappe.whitelist() diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index dee98334062..24c5db17d8d 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -262,8 +262,7 @@ class StatusUpdater(DocListController): / ref_doc_qty)*100 frappe.db.set_value(ref_dt, ref_dn, "per_billed", per_billed) - from frappe.model.meta import has_field - if has_field(ref_dt, "billing_status"): + if frappe.get_meta(ref_dt).get_field("billing_status"): if per_billed < 0.001: billing_status = "Not Billed" elif per_billed >= 99.99: billing_status = "Fully Billed" else: billing_status = "Partly Billed" diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index 3ff780d726e..a24834ea759 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -131,7 +131,7 @@ class StockController(AccountsController): warehouse_account = self.get_warehouse_account() for voucher_type, voucher_no in future_stock_vouchers: existing_gle = gle.get((voucher_type, voucher_no), []) - voucher_obj = frappe.get_obj(voucher_type, voucher_no) + voucher_obj = frappe.get_doc(voucher_type, voucher_no) expected_gle = voucher_obj.get_gl_entries(warehouse_account) if expected_gle: matched = True @@ -276,7 +276,7 @@ def update_gl_entries_after(posting_date, posting_time, warehouse_account=None, for voucher_type, voucher_no in future_stock_vouchers: existing_gle = gle.get((voucher_type, voucher_no), []) - voucher_obj = frappe.get_obj(voucher_type, voucher_no) + voucher_obj = frappe.get_doc(voucher_type, voucher_no) expected_gle = voucher_obj.get_gl_entries(warehouse_account) if expected_gle: if not existing_gle or not compare_existing_and_expected_gle(existing_gle, diff --git a/erpnext/home/doctype/feed/feed.txt b/erpnext/home/doctype/feed/feed.json similarity index 100% rename from erpnext/home/doctype/feed/feed.txt rename to erpnext/home/doctype/feed/feed.json diff --git a/erpnext/home/page/activity/activity.txt b/erpnext/home/page/activity/activity.json similarity index 100% rename from erpnext/home/page/activity/activity.txt rename to erpnext/home/page/activity/activity.json diff --git a/erpnext/hr/doctype/appraisal/appraisal.txt b/erpnext/hr/doctype/appraisal/appraisal.json similarity index 100% rename from erpnext/hr/doctype/appraisal/appraisal.txt rename to erpnext/hr/doctype/appraisal/appraisal.json diff --git a/erpnext/hr/doctype/appraisal_goal/appraisal_goal.txt b/erpnext/hr/doctype/appraisal_goal/appraisal_goal.json similarity index 100% rename from erpnext/hr/doctype/appraisal_goal/appraisal_goal.txt rename to erpnext/hr/doctype/appraisal_goal/appraisal_goal.json diff --git a/erpnext/hr/doctype/appraisal_template/appraisal_template.txt b/erpnext/hr/doctype/appraisal_template/appraisal_template.json similarity index 100% rename from erpnext/hr/doctype/appraisal_template/appraisal_template.txt rename to erpnext/hr/doctype/appraisal_template/appraisal_template.json diff --git a/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.txt b/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.json similarity index 100% rename from erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.txt rename to erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.json diff --git a/erpnext/hr/doctype/attendance/attendance.txt b/erpnext/hr/doctype/attendance/attendance.json similarity index 100% rename from erpnext/hr/doctype/attendance/attendance.txt rename to erpnext/hr/doctype/attendance/attendance.json diff --git a/erpnext/hr/doctype/branch/branch.txt b/erpnext/hr/doctype/branch/branch.json similarity index 100% rename from erpnext/hr/doctype/branch/branch.txt rename to erpnext/hr/doctype/branch/branch.json diff --git a/erpnext/hr/doctype/branch/test_branch.py b/erpnext/hr/doctype/branch/test_branch.py index f1db481eb73..52f2fe42e7f 100644 --- a/erpnext/hr/doctype/branch/test_branch.py +++ b/erpnext/hr/doctype/branch/test_branch.py @@ -1,4 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [{"doctype":"Branch", "branch":"_Test Branch"}] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Branch') \ No newline at end of file diff --git a/erpnext/hr/doctype/deduction_type/deduction_type.txt b/erpnext/hr/doctype/deduction_type/deduction_type.json similarity index 100% rename from erpnext/hr/doctype/deduction_type/deduction_type.txt rename to erpnext/hr/doctype/deduction_type/deduction_type.json diff --git a/erpnext/hr/doctype/deduction_type/test_deduction_type.py b/erpnext/hr/doctype/deduction_type/test_deduction_type.py index 6f46d24a5d4..577edc41a5c 100644 --- a/erpnext/hr/doctype/deduction_type/test_deduction_type.py +++ b/erpnext/hr/doctype/deduction_type/test_deduction_type.py @@ -1,13 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - { - "doctype": "Deduction Type", - "deduction_name": "_Test Professional Tax" - }, - { - "doctype": "Deduction Type", - "deduction_name": "_Test TDS" - } -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Deduction Type') \ No newline at end of file diff --git a/erpnext/hr/doctype/department/department.txt b/erpnext/hr/doctype/department/department.json similarity index 100% rename from erpnext/hr/doctype/department/department.txt rename to erpnext/hr/doctype/department/department.json diff --git a/erpnext/hr/doctype/department/test_department.py b/erpnext/hr/doctype/department/test_department.py index 654c250737d..6642bc2bf14 100644 --- a/erpnext/hr/doctype/department/test_department.py +++ b/erpnext/hr/doctype/department/test_department.py @@ -3,7 +3,6 @@ test_ignore = ["Leave Block List"] -test_records = [ - {"doctype":"Department", "department_name":"_Test Department"}, - {"doctype":"Department", "department_name":"_Test Department 1"} -] + +import frappe +test_records = frappe.get_test_records('Department') \ No newline at end of file diff --git a/erpnext/hr/doctype/designation/designation.txt b/erpnext/hr/doctype/designation/designation.json similarity index 100% rename from erpnext/hr/doctype/designation/designation.txt rename to erpnext/hr/doctype/designation/designation.json diff --git a/erpnext/hr/doctype/designation/test_designation.py b/erpnext/hr/doctype/designation/test_designation.py index 2ed331c7409..cb327e7d05a 100644 --- a/erpnext/hr/doctype/designation/test_designation.py +++ b/erpnext/hr/doctype/designation/test_designation.py @@ -1,4 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [{"doctype":"Designation", "designation_name":"_Test Designation"}] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Designation') \ No newline at end of file diff --git a/erpnext/hr/doctype/earning_type/earning_type.txt b/erpnext/hr/doctype/earning_type/earning_type.json similarity index 100% rename from erpnext/hr/doctype/earning_type/earning_type.txt rename to erpnext/hr/doctype/earning_type/earning_type.json diff --git a/erpnext/hr/doctype/earning_type/test_earning_type.py b/erpnext/hr/doctype/earning_type/test_earning_type.py index a7184a1663b..7b84af6e2ab 100644 --- a/erpnext/hr/doctype/earning_type/test_earning_type.py +++ b/erpnext/hr/doctype/earning_type/test_earning_type.py @@ -1,15 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - { - "doctype": "Earning Type", - "earning_name": "_Test Basic Salary", - "taxable": "Yes" - }, - { - "doctype": "Earning Type", - "earning_name": "_Test Allowance", - "taxable": "Yes" - } -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Earning Type') \ No newline at end of file diff --git a/erpnext/hr/doctype/employee/employee.txt b/erpnext/hr/doctype/employee/employee.json similarity index 100% rename from erpnext/hr/doctype/employee/employee.txt rename to erpnext/hr/doctype/employee/employee.json diff --git a/erpnext/hr/doctype/employee/test_employee.py b/erpnext/hr/doctype/employee/test_employee.py index cfafb63dce1..699e439c530 100644 --- a/erpnext/hr/doctype/employee/test_employee.py +++ b/erpnext/hr/doctype/employee/test_employee.py @@ -1,40 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [[{ - "doctype":"Employee", - "employee_name": "_Test Employee", - "naming_series": "_T-Employee-", - "date_of_joining": "2010-01-01", - "date_of_birth": "1980-01-01", - "gender": "Female", - "status": "Active", - "company": "_Test Company", - "user_id": "test@example.com", - "department": "_Test Department" -}], -[{ - "doctype":"Employee", - "employee_name": "_Test Employee 1", - "naming_series": "_T-Employee-", - "date_of_joining": "2010-01-01", - "date_of_birth": "1980-01-01", - "gender": "Male", - "status": "Active", - "company": "_Test Company", - "user_id": "test1@example.com", - "department": "_Test Department 1" -}], -[{ - "doctype":"Employee", - "employee_name": "_Test Employee 2", - "naming_series": "_T-Employee-", - "date_of_joining": "2010-01-01", - "date_of_birth": "1980-01-01", - "gender": "Male", - "status": "Active", - "company": "_Test Company", - "user_id": "test2@example.com", - "department": "_Test Department 1" -}] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Employee') \ No newline at end of file diff --git a/erpnext/hr/doctype/employee_education/employee_education.txt b/erpnext/hr/doctype/employee_education/employee_education.json similarity index 100% rename from erpnext/hr/doctype/employee_education/employee_education.txt rename to erpnext/hr/doctype/employee_education/employee_education.json diff --git a/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.txt b/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.json similarity index 100% rename from erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.txt rename to erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.json diff --git a/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.txt b/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.json similarity index 100% rename from erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.txt rename to erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.json diff --git a/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.txt b/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.json similarity index 100% rename from erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.txt rename to erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.json diff --git a/erpnext/hr/doctype/employment_type/employment_type.txt b/erpnext/hr/doctype/employment_type/employment_type.json similarity index 100% rename from erpnext/hr/doctype/employment_type/employment_type.txt rename to erpnext/hr/doctype/employment_type/employment_type.json diff --git a/erpnext/hr/doctype/employment_type/test_employment_type.py b/erpnext/hr/doctype/employment_type/test_employment_type.py index d2624dc7039..8a080f9b6d2 100644 --- a/erpnext/hr/doctype/employment_type/test_employment_type.py +++ b/erpnext/hr/doctype/employment_type/test_employment_type.py @@ -1,5 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [[{"doctype":"Employment Type", - "employee_type_name": "_Test Employment Type"}]] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Employment Type') \ No newline at end of file diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.txt b/erpnext/hr/doctype/expense_claim/expense_claim.json similarity index 100% rename from erpnext/hr/doctype/expense_claim/expense_claim.txt rename to erpnext/hr/doctype/expense_claim/expense_claim.json diff --git a/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.txt b/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.json similarity index 100% rename from erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.txt rename to erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.json diff --git a/erpnext/hr/doctype/expense_claim_type/expense_claim_type.txt b/erpnext/hr/doctype/expense_claim_type/expense_claim_type.json similarity index 100% rename from erpnext/hr/doctype/expense_claim_type/expense_claim_type.txt rename to erpnext/hr/doctype/expense_claim_type/expense_claim_type.json diff --git a/erpnext/hr/doctype/grade/grade.txt b/erpnext/hr/doctype/grade/grade.json similarity index 100% rename from erpnext/hr/doctype/grade/grade.txt rename to erpnext/hr/doctype/grade/grade.json diff --git a/erpnext/hr/doctype/grade/test_grade.py b/erpnext/hr/doctype/grade/test_grade.py index e0330e61693..fabab8d72bf 100644 --- a/erpnext/hr/doctype/grade/test_grade.py +++ b/erpnext/hr/doctype/grade/test_grade.py @@ -1,4 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [{"doctype":"Grade", "grade_name":"_Test Grade"}] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Grade') \ No newline at end of file diff --git a/erpnext/hr/doctype/holiday/holiday.txt b/erpnext/hr/doctype/holiday/holiday.json similarity index 100% rename from erpnext/hr/doctype/holiday/holiday.txt rename to erpnext/hr/doctype/holiday/holiday.json diff --git a/erpnext/hr/doctype/holiday_list/holiday_list.txt b/erpnext/hr/doctype/holiday_list/holiday_list.json similarity index 100% rename from erpnext/hr/doctype/holiday_list/holiday_list.txt rename to erpnext/hr/doctype/holiday_list/holiday_list.json diff --git a/erpnext/hr/doctype/holiday_list/test_holiday_list.py b/erpnext/hr/doctype/holiday_list/test_holiday_list.py index 4acd33915cf..959f82611c8 100644 --- a/erpnext/hr/doctype/holiday_list/test_holiday_list.py +++ b/erpnext/hr/doctype/holiday_list/test_holiday_list.py @@ -1,16 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [[{ - "doctype": "Holiday List", - "holiday_list_name": "_Test Holiday List", - "fiscal_year": "_Test Fiscal Year 2013", - "is_default": 1 - }, { - "doctype": "Holiday", - "parent": "_Test Holiday List", - "parenttype": "Holiday List", - "parentfield": "holiday_list_details", - "holiday_date": "2013-01-01", - "description": "New Year" - }]] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Holiday List') \ No newline at end of file diff --git a/erpnext/hr/doctype/hr_settings/hr_settings.txt b/erpnext/hr/doctype/hr_settings/hr_settings.json similarity index 100% rename from erpnext/hr/doctype/hr_settings/hr_settings.txt rename to erpnext/hr/doctype/hr_settings/hr_settings.json diff --git a/erpnext/hr/doctype/hr_settings/hr_settings.py b/erpnext/hr/doctype/hr_settings/hr_settings.py index 602558ba5cc..861408d0646 100644 --- a/erpnext/hr/doctype/hr_settings/hr_settings.py +++ b/erpnext/hr/doctype/hr_settings/hr_settings.py @@ -30,6 +30,6 @@ class HrSettings(Document): if not self.stop_birthday_reminders: for employee in frappe.db.sql_list("""select name from `tabEmployee` where status='Active' and ifnull(date_of_birth, '')!=''"""): - frappe.get_obj("Employee", employee).update_dob_event() + frappe.get_doc("Employee", employee).update_dob_event() frappe.msgprint(frappe._("Updated Birthday Reminders")) \ No newline at end of file diff --git a/erpnext/hr/doctype/job_applicant/job_applicant.txt b/erpnext/hr/doctype/job_applicant/job_applicant.json similarity index 100% rename from erpnext/hr/doctype/job_applicant/job_applicant.txt rename to erpnext/hr/doctype/job_applicant/job_applicant.json diff --git a/erpnext/hr/doctype/job_opening/job_opening.txt b/erpnext/hr/doctype/job_opening/job_opening.json similarity index 100% rename from erpnext/hr/doctype/job_opening/job_opening.txt rename to erpnext/hr/doctype/job_opening/job_opening.json diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.txt b/erpnext/hr/doctype/leave_allocation/leave_allocation.json similarity index 100% rename from erpnext/hr/doctype/leave_allocation/leave_allocation.txt rename to erpnext/hr/doctype/leave_allocation/leave_allocation.json diff --git a/erpnext/hr/doctype/leave_application/leave_application.txt b/erpnext/hr/doctype/leave_application/leave_application.json similarity index 100% rename from erpnext/hr/doctype/leave_application/leave_application.txt rename to erpnext/hr/doctype/leave_application/leave_application.json diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py index 3ed9d561610..89c98332fbe 100644 --- a/erpnext/hr/doctype/leave_application/test_leave_application.py +++ b/erpnext/hr/doctype/leave_application/test_leave_application.py @@ -194,51 +194,4 @@ class TestLeaveApplication(unittest.TestCase): test_dependencies = ["Leave Block List"] -test_records = [ - [{ - "doctype": "Leave Allocation", - "leave_type": "_Test Leave Type", - "fiscal_year": "_Test Fiscal Year 2013", - "employee":"_T-Employee-0001", - "new_leaves_allocated": 15, - "docstatus": 1 - }], - [{ - "doctype": "Leave Application", - "leave_type": "_Test Leave Type", - "from_date": "2013-05-01", - "to_date": "2013-05-05", - "posting_date": "2013-01-02", - "fiscal_year": "_Test Fiscal Year 2013", - "employee": "_T-Employee-0001", - "company": "_Test Company" - }], - [{ - "doctype": "Leave Allocation", - "leave_type": "_Test Leave Type", - "fiscal_year": "_Test Fiscal Year 2013", - "employee":"_T-Employee-0002", - "new_leaves_allocated": 15, - "docstatus": 1 - }], - [{ - "doctype": "Leave Application", - "leave_type": "_Test Leave Type", - "from_date": "2013-05-01", - "to_date": "2013-05-05", - "posting_date": "2013-01-02", - "fiscal_year": "_Test Fiscal Year 2013", - "employee": "_T-Employee-0002", - "company": "_Test Company" - }], - [{ - "doctype": "Leave Application", - "leave_type": "_Test Leave Type LWP", - "from_date": "2013-01-15", - "to_date": "2013-01-15", - "posting_date": "2013-01-02", - "fiscal_year": "_Test Fiscal Year 2013", - "employee": "_T-Employee-0001", - "company": "_Test Company", - }] -] +test_records = frappe.get_test_records('Leave Application') \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_block_list/leave_block_list.txt b/erpnext/hr/doctype/leave_block_list/leave_block_list.json similarity index 100% rename from erpnext/hr/doctype/leave_block_list/leave_block_list.txt rename to erpnext/hr/doctype/leave_block_list/leave_block_list.json diff --git a/erpnext/hr/doctype/leave_block_list/test_leave_block_list.py b/erpnext/hr/doctype/leave_block_list/test_leave_block_list.py index 811d8978276..88786587e4b 100644 --- a/erpnext/hr/doctype/leave_block_list/test_leave_block_list.py +++ b/erpnext/hr/doctype/leave_block_list/test_leave_block_list.py @@ -32,23 +32,4 @@ class TestLeaveBlockList(unittest.TestCase): test_dependencies = ["Employee"] -test_records = [[{ - "doctype":"Leave Block List", - "leave_block_list_name": "_Test Leave Block List", - "year": "_Test Fiscal Year 2013", - "company": "_Test Company" - }, { - "doctype": "Leave Block List Date", - "parent": "_Test Leave Block List", - "parenttype": "Leave Block List", - "parentfield": "leave_block_list_dates", - "block_date": "2013-01-02", - "reason": "First work day" - }, { - "doctype": "Leave Block List Allow", - "parent": "_Test Leave Block List", - "parenttype": "Leave Block List", - "parentfield": "leave_block_list_allowed", - "allow_user": "test1@example.com", - } - ]] \ No newline at end of file +test_records = frappe.get_test_records('Leave Block List') \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.txt b/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.json similarity index 100% rename from erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.txt rename to erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.json diff --git a/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.txt b/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.json similarity index 100% rename from erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.txt rename to erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.json diff --git a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.txt b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.json similarity index 100% rename from erpnext/hr/doctype/leave_control_panel/leave_control_panel.txt rename to erpnext/hr/doctype/leave_control_panel/leave_control_panel.json 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 81ab56bc13b..4a8795affdf 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 @@ from __future__ import unicode_literals import frappe from frappe.utils import cint, cstr, flt, nowdate -from frappe.model.code import get_obj from frappe import msgprint, _ diff --git a/erpnext/hr/doctype/leave_type/leave_type.txt b/erpnext/hr/doctype/leave_type/leave_type.json similarity index 100% rename from erpnext/hr/doctype/leave_type/leave_type.txt rename to erpnext/hr/doctype/leave_type/leave_type.json diff --git a/erpnext/hr/doctype/leave_type/test_leave_type.py b/erpnext/hr/doctype/leave_type/test_leave_type.py index 50c3e795ccc..59fff57cc68 100644 --- a/erpnext/hr/doctype/leave_type/test_leave_type.py +++ b/erpnext/hr/doctype/leave_type/test_leave_type.py @@ -1,14 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "leave_type_name": "_Test Leave Type", - "doctype": "Leave Type" - }], - [{ - "leave_type_name": "_Test Leave Type LWP", - "doctype": "Leave Type", - "is_lwp": 1 - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Leave Type') \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_manager/salary_manager.txt b/erpnext/hr/doctype/salary_manager/salary_manager.json similarity index 100% rename from erpnext/hr/doctype/salary_manager/salary_manager.txt rename to erpnext/hr/doctype/salary_manager/salary_manager.json diff --git a/erpnext/hr/doctype/salary_manager/salary_manager.py b/erpnext/hr/doctype/salary_manager/salary_manager.py index 0079b2ed7d3..ac64963bbc5 100644 --- a/erpnext/hr/doctype/salary_manager/salary_manager.py +++ b/erpnext/hr/doctype/salary_manager/salary_manager.py @@ -4,7 +4,6 @@ from __future__ import unicode_literals import frappe from frappe.utils import cint, flt -from frappe.model.code import get_obj from frappe import msgprint from frappe.model.document import Document @@ -128,7 +127,7 @@ class SalaryManager(Document): ss_list = self.get_sal_slip_list() not_submitted_ss = [] for ss in ss_list: - ss_obj = get_obj("Salary Slip",ss[0],with_children=1) + ss_obj = frappe.get_doc("Salary Slip",ss[0]) try: frappe.db.set(ss_obj.doc, 'email_check', cint(self.send_mail)) if cint(self.send_email) == 1: diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.txt b/erpnext/hr/doctype/salary_slip/salary_slip.json similarity index 100% rename from erpnext/hr/doctype/salary_slip/salary_slip.txt rename to erpnext/hr/doctype/salary_slip/salary_slip.json diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index cfd39fc5e13..981935f35c2 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -7,7 +7,6 @@ import frappe from frappe.utils import add_days, cint, cstr, flt, getdate, nowdate, _round from frappe.model.naming import make_autoname -from frappe.model.code import get_obj from frappe import msgprint, _ from erpnext.setup.utils import get_company_currency @@ -52,7 +51,7 @@ class SalarySlip(TransactionBase): if not self.month: self.month = "%02d" % getdate(nowdate()).month - m = get_obj('Salary Manager').get_month_details(self.fiscal_year, self.month) + m = frappe.get_doc('Salary Manager').get_month_details(self.fiscal_year, self.month) holidays = self.get_holidays_for_employee(m) if not cint(frappe.db.get_value("HR Settings", "HR Settings", diff --git a/erpnext/hr/doctype/salary_slip/test_salary_slip.py b/erpnext/hr/doctype/salary_slip/test_salary_slip.py index c14901a5c56..ab590444b48 100644 --- a/erpnext/hr/doctype/salary_slip/test_salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/test_salary_slip.py @@ -9,7 +9,7 @@ class TestSalarySlip(unittest.TestCase): frappe.db.sql("""delete from `tabLeave Application`""") frappe.db.sql("""delete from `tabSalary Slip`""") from erpnext.hr.doctype.leave_application.test_leave_application import test_records as leave_applications - la = frappe.get_doc(copy=leave_applications[4]) + la = frappe.copy_doc(leave_applications[4]) la.insert() la.status = "Approved" la.submit() @@ -19,7 +19,7 @@ class TestSalarySlip(unittest.TestCase): def test_salary_slip_with_holidays_included(self): frappe.db.set_value("HR Settings", "HR Settings", "include_holidays_in_total_working_days", 1) - ss = frappe.get_doc(copy=test_records[0]) + ss = frappe.copy_doc(test_records[0]) ss.insert() self.assertEquals(ss.total_days_in_month, 31) self.assertEquals(ss.payment_days, 30) @@ -31,7 +31,7 @@ class TestSalarySlip(unittest.TestCase): self.assertEquals(ss.net_pay, 14867.74) def test_salary_slip_with_holidays_excluded(self): - ss = frappe.get_doc(copy=test_records[0]) + ss = frappe.copy_doc(test_records[0]) ss.insert() self.assertEquals(ss.total_days_in_month, 30) self.assertEquals(ss.payment_days, 29) @@ -44,45 +44,4 @@ class TestSalarySlip(unittest.TestCase): test_dependencies = ["Leave Application"] -test_records = [ - [ - { - "doctype": "Salary Slip", - "employee": "_T-Employee-0001", - "employee_name": "_Test Employee", - "company": "_Test Company", - "fiscal_year": "_Test Fiscal Year 2013", - "month": "01", - "total_days_in_month": 31, - "payment_days": 31 - }, - { - "doctype": "Salary Slip Earning", - "parentfield": "earning_details", - "e_type": "_Test Basic Salary", - "e_amount": 15000, - "e_depends_on_lwp": 1 - }, - { - "doctype": "Salary Slip Earning", - "parentfield": "earning_details", - "e_type": "_Test Allowance", - "e_amount": 500, - "e_depends_on_lwp": 0 - }, - { - "doctype": "Salary Slip Deduction", - "parentfield": "deduction_details", - "d_type": "_Test Professional Tax", - "d_amount": 100, - "d_depends_on_lwp": 0 - }, - { - "doctype": "Salary Slip Deduction", - "parentfield": "deduction_details", - "d_type": "_Test TDS", - "d_amount": 50, - "d_depends_on_lwp": 1 - }, - ] -] \ No newline at end of file +test_records = frappe.get_test_records('Salary Slip') \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.txt b/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.json similarity index 100% rename from erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.txt rename to erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.json diff --git a/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.txt b/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.json similarity index 100% rename from erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.txt rename to erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.json diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.txt b/erpnext/hr/doctype/salary_structure/salary_structure.json similarity index 100% rename from erpnext/hr/doctype/salary_structure/salary_structure.txt rename to erpnext/hr/doctype/salary_structure/salary_structure.json diff --git a/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.txt b/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.json similarity index 100% rename from erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.txt rename to erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.json diff --git a/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.txt b/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.json similarity index 100% rename from erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.txt rename to erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.json diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.txt b/erpnext/hr/doctype/upload_attendance/upload_attendance.json similarity index 100% rename from erpnext/hr/doctype/upload_attendance/upload_attendance.txt rename to erpnext/hr/doctype/upload_attendance/upload_attendance.json diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.py b/erpnext/hr/doctype/upload_attendance/upload_attendance.py index 8a544158324..1ba31e9f20b 100644 --- a/erpnext/hr/doctype/upload_attendance/upload_attendance.py +++ b/erpnext/hr/doctype/upload_attendance/upload_attendance.py @@ -10,9 +10,6 @@ from frappe import msgprint, _ from frappe.utils.datautils import UnicodeWriter from frappe.model.document import Document -# doclist = None -doclist = frappe.local('uploadattendance_doclist') - class UploadAttendance(Document): pass @@ -22,7 +19,6 @@ def get_template(): raise frappe.PermissionError args = frappe.local.form_dict - frappe.local.uploadattendance_doclist = frappe.model.doctype.get("Attendance") w = UnicodeWriter() w = add_header(w) @@ -34,13 +30,8 @@ def get_template(): frappe.response['type'] = 'csv' frappe.response['doctype'] = "Attendance" -def getdocfield(fieldname): - """get docfield from doclist of doctype""" - l = [d for d in doclist if d.doctype=='DocField' and d.fieldname==fieldname] - return l and l[0] or None - def add_header(w): - status = ", ".join(getdocfield("status").options.strip().split("\n")) + status = ", ".join((frappe.get_meta("Attendance").get_field("status").options or "").strip().split("\n")) w.writerow(["Notes:"]) w.writerow(["Please do not change the template headings"]) w.writerow(["Status should be one of these values: " + status]) @@ -94,7 +85,7 @@ def get_existing_attendance_records(args): return existing_attendance def get_naming_series(): - series = getdocfield("naming_series").options.strip().split("\n") + series = frappe.get_meta("Attendance").get_field("naming_series").options.strip().split("\n") if not series: msgprint("""Please create naming series for Attendance \ through Setup -> Numbering Series.""", raise_exception=1) diff --git a/erpnext/hr/report/employee_birthday/employee_birthday.txt b/erpnext/hr/report/employee_birthday/employee_birthday.json similarity index 100% rename from erpnext/hr/report/employee_birthday/employee_birthday.txt rename to erpnext/hr/report/employee_birthday/employee_birthday.json diff --git a/erpnext/hr/report/employee_information/employee_information.txt b/erpnext/hr/report/employee_information/employee_information.json similarity index 100% rename from erpnext/hr/report/employee_information/employee_information.txt rename to erpnext/hr/report/employee_information/employee_information.json diff --git a/erpnext/hr/report/employee_leave_balance/employee_leave_balance.txt b/erpnext/hr/report/employee_leave_balance/employee_leave_balance.json similarity index 100% rename from erpnext/hr/report/employee_leave_balance/employee_leave_balance.txt rename to erpnext/hr/report/employee_leave_balance/employee_leave_balance.json diff --git a/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.txt b/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.json similarity index 100% rename from erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.txt rename to erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.json diff --git a/erpnext/hr/report/monthly_salary_register/monthly_salary_register.txt b/erpnext/hr/report/monthly_salary_register/monthly_salary_register.json similarity index 100% rename from erpnext/hr/report/monthly_salary_register/monthly_salary_register.txt rename to erpnext/hr/report/monthly_salary_register/monthly_salary_register.json diff --git a/erpnext/manufacturing/doctype/bom/bom.txt b/erpnext/manufacturing/doctype/bom/bom.json similarity index 100% rename from erpnext/manufacturing/doctype/bom/bom.txt rename to erpnext/manufacturing/doctype/bom/bom.json diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index 14e18f22999..6fdf6414e2d 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe from frappe.utils import cint, cstr, flt, now, nowdate -from frappe.model.code import get_obj from frappe import msgprint, _ @@ -282,7 +281,7 @@ class Bom(Document): def update_cost_and_exploded_items(self, bom_list=[]): bom_list = self.traverse_tree(bom_list) for bom in bom_list: - bom_obj = get_obj("BOM", bom, with_children=1) + bom_obj = frappe.get_doc("BOM", bom) bom_obj.on_update() return bom_list diff --git a/erpnext/manufacturing/doctype/bom/test_bom.py b/erpnext/manufacturing/doctype/bom/test_bom.py index 9bd9a074094..074daa4eb95 100644 --- a/erpnext/manufacturing/doctype/bom/test_bom.py +++ b/erpnext/manufacturing/doctype/bom/test_bom.py @@ -6,95 +6,7 @@ from __future__ import unicode_literals import unittest import frappe -test_records = [ - [ - { - "doctype": "BOM", - "item": "_Test Item Home Desktop Manufactured", - "quantity": 1.0, - "is_active": 1, - "is_default": 1, - "docstatus": 1 - }, - { - "doctype": "BOM Item", - "item_code": "_Test Serialized Item With Series", - "parentfield": "bom_materials", - "qty": 1.0, - "rate": 5000.0, - "amount": 5000.0, - "stock_uom": "_Test UOM" - }, - { - "doctype": "BOM Item", - "item_code": "_Test Item 2", - "parentfield": "bom_materials", - "qty": 2.0, - "rate": 1000.0, - "amount": 2000.0, - "stock_uom": "_Test UOM" - } - ], - - [ - { - "doctype": "BOM", - "item": "_Test FG Item", - "quantity": 1.0, - "is_active": 1, - "is_default": 1, - "docstatus": 1 - }, - { - "doctype": "BOM Item", - "item_code": "_Test Item", - "parentfield": "bom_materials", - "qty": 1.0, - "rate": 5000.0, - "amount": 5000.0, - "stock_uom": "_Test UOM" - }, - { - "doctype": "BOM Item", - "item_code": "_Test Item Home Desktop 100", - "parentfield": "bom_materials", - "qty": 2.0, - "rate": 1000.0, - "amount": 2000.0, - "stock_uom": "_Test UOM" - } - ], - - [ - { - "doctype": "BOM", - "item": "_Test FG Item 2", - "quantity": 1.0, - "is_active": 1, - "is_default": 1, - "docstatus": 1 - }, - { - "doctype": "BOM Item", - "item_code": "_Test Item", - "parentfield": "bom_materials", - "qty": 1.0, - "rate": 5000.0, - "amount": 5000.0, - "stock_uom": "_Test UOM" - }, - { - "doctype": "BOM Item", - "item_code": "_Test Item Home Desktop Manufactured", - "bom_no": "BOM/_Test Item Home Desktop Manufactured/001", - "parentfield": "bom_materials", - "qty": 2.0, - "rate": 1000.0, - "amount": 2000.0, - "stock_uom": "_Test UOM" - } - ], -] +test_records = frappe.get_test_records('Bom') class TestBOM(unittest.TestCase): def test_get_items(self): @@ -115,5 +27,4 @@ class TestBOM(unittest.TestCase): def test_get_items_list(self): from erpnext.manufacturing.doctype.bom.bom import get_bom_items - self.assertEquals(len(get_bom_items(bom="BOM/_Test FG Item 2/001", qty=1, fetch_exploded=1)), 3) - + self.assertEquals(len(get_bom_items(bom="BOM/_Test FG Item 2/001", qty=1, fetch_exploded=1)), 3) \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.txt b/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.json similarity index 100% rename from erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.txt rename to erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.json diff --git a/erpnext/manufacturing/doctype/bom_item/bom_item.txt b/erpnext/manufacturing/doctype/bom_item/bom_item.json similarity index 100% rename from erpnext/manufacturing/doctype/bom_item/bom_item.txt rename to erpnext/manufacturing/doctype/bom_item/bom_item.json diff --git a/erpnext/manufacturing/doctype/bom_operation/bom_operation.txt b/erpnext/manufacturing/doctype/bom_operation/bom_operation.json similarity index 100% rename from erpnext/manufacturing/doctype/bom_operation/bom_operation.txt rename to erpnext/manufacturing/doctype/bom_operation/bom_operation.json diff --git a/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.txt b/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.json similarity index 100% rename from erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.txt rename to erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.json diff --git a/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py b/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py index cf7750a269b..34f45bdbf93 100644 --- a/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py +++ b/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py @@ -4,7 +4,6 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt -from frappe.model.code import get_obj from frappe import msgprint, _ from frappe.model.document import Document @@ -16,7 +15,7 @@ class BomReplaceTool(Document): bom_list = self.get_parent_boms() updated_bom = [] for bom in bom_list: - bom_obj = get_obj("BOM", bom, with_children=1) + bom_obj = frappe.get_doc("BOM", bom) updated_bom = bom_obj.update_cost_and_exploded_items(updated_bom) frappe.msgprint(_("BOM replaced")) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.txt b/erpnext/manufacturing/doctype/production_order/production_order.json similarity index 100% rename from erpnext/manufacturing/doctype/production_order/production_order.txt rename to erpnext/manufacturing/doctype/production_order/production_order.json diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index f878cd8933f..fd979805a27 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt, nowdate -from frappe.model.code import get_obj from frappe import msgprint, _ class OverProductionError(frappe.ValidationError): pass diff --git a/erpnext/manufacturing/doctype/production_order/test_production_order.py b/erpnext/manufacturing/doctype/production_order/test_production_order.py index b3d655a2e42..1af4815aa1d 100644 --- a/erpnext/manufacturing/doctype/production_order/test_production_order.py +++ b/erpnext/manufacturing/doctype/production_order/test_production_order.py @@ -17,16 +17,16 @@ class TestProductionOrder(unittest.TestCase): frappe.db.sql("""delete from `tabBin`""") frappe.db.sql("""delete from `tabGL Entry`""") - pro_bean = frappe.get_doc(copy = test_records[0]) + pro_bean = frappe.copy_doc(test_records[0]) pro_bean.insert() pro_bean.submit() from erpnext.stock.doctype.stock_entry.test_stock_entry import test_records as se_test_records - mr1 = frappe.get_doc(copy = se_test_records[0]) + mr1 = frappe.copy_doc(se_test_records[0]) mr1.insert() mr1.submit() - mr2 = frappe.get_doc(copy = se_test_records[0]) + mr2 = frappe.copy_doc(se_test_records[0]) mr2.doclist[1].item_code = "_Test Item Home Desktop 100" mr2.insert() mr2.submit() @@ -63,17 +63,4 @@ class TestProductionOrder(unittest.TestCase): -test_records = [ - [ - { - "bom_no": "BOM/_Test FG Item/001", - "company": "_Test Company", - "doctype": "Production Order", - "production_item": "_Test FG Item", - "qty": 10.0, - "fg_warehouse": "_Test Warehouse 1 - _TC", - "wip_warehouse": "_Test Warehouse - _TC", - "stock_uom": "Nos" - } - ] -] \ No newline at end of file +test_records = frappe.get_test_records('Production Order') \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.txt b/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.json similarity index 100% rename from erpnext/manufacturing/doctype/production_plan_item/production_plan_item.txt rename to erpnext/manufacturing/doctype/production_plan_item/production_plan_item.json diff --git a/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.txt b/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.json similarity index 100% rename from erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.txt rename to erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.json diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.txt b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.json similarity index 100% rename from erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.txt rename to erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.json 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 c925c0c5e29..8c9c3cdb9f5 100644 --- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py +++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt, cint, nowdate, add_days -from frappe.model.code import get_obj from frappe import msgprint, _ from frappe.model.document import Document diff --git a/erpnext/manufacturing/doctype/workstation/workstation.txt b/erpnext/manufacturing/doctype/workstation/workstation.json similarity index 100% rename from erpnext/manufacturing/doctype/workstation/workstation.txt rename to erpnext/manufacturing/doctype/workstation/workstation.json diff --git a/erpnext/manufacturing/report/completed_production_orders/completed_production_orders.txt b/erpnext/manufacturing/report/completed_production_orders/completed_production_orders.json similarity index 100% rename from erpnext/manufacturing/report/completed_production_orders/completed_production_orders.txt rename to erpnext/manufacturing/report/completed_production_orders/completed_production_orders.json diff --git a/erpnext/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt b/erpnext/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.json similarity index 100% rename from erpnext/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt rename to erpnext/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.json diff --git a/erpnext/manufacturing/report/open_production_orders/open_production_orders.txt b/erpnext/manufacturing/report/open_production_orders/open_production_orders.json similarity index 100% rename from erpnext/manufacturing/report/open_production_orders/open_production_orders.txt rename to erpnext/manufacturing/report/open_production_orders/open_production_orders.json diff --git a/erpnext/manufacturing/report/production_orders_in_progress/production_orders_in_progress.txt b/erpnext/manufacturing/report/production_orders_in_progress/production_orders_in_progress.json similarity index 100% rename from erpnext/manufacturing/report/production_orders_in_progress/production_orders_in_progress.txt rename to erpnext/manufacturing/report/production_orders_in_progress/production_orders_in_progress.json diff --git a/erpnext/patches/4_0/update_user_properties.py b/erpnext/patches/4_0/update_user_properties.py index da8635ed290..0c3aa4ab2ee 100644 --- a/erpnext/patches/4_0/update_user_properties.py +++ b/erpnext/patches/4_0/update_user_properties.py @@ -4,7 +4,6 @@ from __future__ import unicode_literals import frappe import frappe.permissions -import frappe.model.doctype import frappe.defaults def execute(): @@ -79,7 +78,7 @@ def add_employee_restrictions_to_leave_approver(): # add restrict rights to HR User and HR Manager frappe.db.sql("""update `tabDocPerm` set `restrict`=1 where parent in ('Employee', 'Leave Application') and role in ('HR User', 'HR Manager') and permlevel=0 and `read`=1""") - frappe.model.doctype.clear_cache() + frappe.clear_cache() # add Employee restrictions (in on_update method) for employee in frappe.db.sql_list("""select name from `tabEmployee` diff --git a/erpnext/projects/doctype/activity_type/activity_type.txt b/erpnext/projects/doctype/activity_type/activity_type.json similarity index 100% rename from erpnext/projects/doctype/activity_type/activity_type.txt rename to erpnext/projects/doctype/activity_type/activity_type.json diff --git a/erpnext/projects/doctype/activity_type/test_activity_type.py b/erpnext/projects/doctype/activity_type/test_activity_type.py index b8933170f0d..ec319799b32 100644 --- a/erpnext/projects/doctype/activity_type/test_activity_type.py +++ b/erpnext/projects/doctype/activity_type/test_activity_type.py @@ -1,8 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{"activity_type":"_Test Activity Type"}], - [{"activity_type":"_Test Activity Type 1"}], - [{"activity_type":"_Test Activity Type 2"}] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Activity Type') \ No newline at end of file diff --git a/erpnext/projects/doctype/project/project.txt b/erpnext/projects/doctype/project/project.json similarity index 100% rename from erpnext/projects/doctype/project/project.txt rename to erpnext/projects/doctype/project/project.json diff --git a/erpnext/projects/doctype/project/test_project.py b/erpnext/projects/doctype/project/test_project.py index b4ea021698c..7769ff421f1 100644 --- a/erpnext/projects/doctype/project/test_project.py +++ b/erpnext/projects/doctype/project/test_project.py @@ -1,11 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [[{ - "project_name": "_Test Project", - "status": "Open" -}], -[{ - "project_name": "_Test Project 1", - "status": "Open" -}]] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Project') \ No newline at end of file diff --git a/erpnext/projects/doctype/project_milestone/project_milestone.txt b/erpnext/projects/doctype/project_milestone/project_milestone.json similarity index 100% rename from erpnext/projects/doctype/project_milestone/project_milestone.txt rename to erpnext/projects/doctype/project_milestone/project_milestone.json diff --git a/erpnext/projects/doctype/task/task.txt b/erpnext/projects/doctype/task/task.json similarity index 100% rename from erpnext/projects/doctype/task/task.txt rename to erpnext/projects/doctype/task/task.json diff --git a/erpnext/projects/doctype/task/test_task.py b/erpnext/projects/doctype/task/test_task.py index af7ad288f07..c345649c44c 100644 --- a/erpnext/projects/doctype/task/test_task.py +++ b/erpnext/projects/doctype/task/test_task.py @@ -1,10 +1,8 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{"subject": "_Test Task", "project":"_Test Project", "status":"Open"}], - [{"subject": "_Test Task 1", "status":"Open"}], - [{"subject": "_Test Task 2", "status":"Open"}] -] + +import frappe +test_records = frappe.get_test_records('Task') test_ignore = ["Customer"] \ No newline at end of file diff --git a/erpnext/projects/doctype/time_log/test_time_log.py b/erpnext/projects/doctype/time_log/test_time_log.py index c0bfa750a28..eedad0b387a 100644 --- a/erpnext/projects/doctype/time_log/test_time_log.py +++ b/erpnext/projects/doctype/time_log/test_time_log.py @@ -11,13 +11,4 @@ class TestTimeLog(unittest.TestCase): ts = frappe.get_doc(frappe.copy_doc(test_records[0])) self.assertRaises(OverlapError, ts.insert) -test_records = [[{ - "doctype": "Time Log", - "from_time": "2013-01-01 10:00:00.000000", - "to_time": "2013-01-01 11:00:00.000000", - "activity_type": "_Test Activity Type", - "note": "_Test Note", - "docstatus": 1 -}]] - -test_ignore = ["Sales Invoice", "Time Log Batch"] \ No newline at end of file +test_records = frappe.get_test_records('Time Log') \ No newline at end of file diff --git a/erpnext/projects/doctype/time_log/time_log.txt b/erpnext/projects/doctype/time_log/time_log.json similarity index 100% rename from erpnext/projects/doctype/time_log/time_log.txt rename to erpnext/projects/doctype/time_log/time_log.json diff --git a/erpnext/projects/doctype/time_log_batch/test_time_log_batch.py b/erpnext/projects/doctype/time_log_batch/test_time_log_batch.py index e059c04e99c..eaf498c2d6a 100644 --- a/erpnext/projects/doctype/time_log_batch/test_time_log_batch.py +++ b/erpnext/projects/doctype/time_log_batch/test_time_log_batch.py @@ -6,7 +6,7 @@ import frappe, unittest class TimeLogBatchTest(unittest.TestCase): def test_time_log_status(self): from erpnext.projects.doctype.time_log.test_time_log import test_records as time_log_records - time_log = frappe.get_doc(copy=time_log_records[0]) + time_log = frappe.copy_doc(time_log_records[0]) time_log.update({ "from_time": "2013-01-02 10:00:00.000000", "to_time": "2013-01-02 11:00:00.000000", @@ -16,7 +16,7 @@ class TimeLogBatchTest(unittest.TestCase): time_log.submit() self.assertEquals(frappe.db.get_value("Time Log", time_log.name, "status"), "Submitted") - tlb = frappe.get_doc(copy=test_records[0]) + tlb = frappe.copy_doc(test_records[0]) tlb.doclist[1].time_log = time_log.name tlb.insert() tlb.submit() @@ -25,15 +25,4 @@ class TimeLogBatchTest(unittest.TestCase): tlb.cancel() self.assertEquals(frappe.db.get_value("Time Log", time_log.name, "status"), "Submitted") -test_records = [[ - { - "doctype": "Time Log Batch", - "rate": "500" - }, - { - "doctype": "Time Log Batch Detail", - "parenttype": "Time Log Batch", - "parentfield": "time_log_batch_details", - "time_log": "_T-Time Log-00001", - } -]] \ No newline at end of file +test_records = frappe.get_test_records('Time Log Batch') \ No newline at end of file diff --git a/erpnext/projects/doctype/time_log_batch/time_log_batch.txt b/erpnext/projects/doctype/time_log_batch/time_log_batch.json similarity index 100% rename from erpnext/projects/doctype/time_log_batch/time_log_batch.txt rename to erpnext/projects/doctype/time_log_batch/time_log_batch.json diff --git a/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.txt b/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.json similarity index 100% rename from erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.txt rename to erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.json diff --git a/erpnext/projects/report/daily_time_log_summary/daily_time_log_summary.txt b/erpnext/projects/report/daily_time_log_summary/daily_time_log_summary.json similarity index 100% rename from erpnext/projects/report/daily_time_log_summary/daily_time_log_summary.txt rename to erpnext/projects/report/daily_time_log_summary/daily_time_log_summary.json diff --git a/erpnext/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.txt b/erpnext/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.json similarity index 100% rename from erpnext/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.txt rename to erpnext/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.json diff --git a/erpnext/selling/Print Format/Quotation Classic/Quotation Classic.txt b/erpnext/selling/Print Format/Quotation Classic/Quotation Classic.json similarity index 100% rename from erpnext/selling/Print Format/Quotation Classic/Quotation Classic.txt rename to erpnext/selling/Print Format/Quotation Classic/Quotation Classic.json diff --git a/erpnext/selling/Print Format/Quotation Modern/Quotation Modern.txt b/erpnext/selling/Print Format/Quotation Modern/Quotation Modern.json similarity index 100% rename from erpnext/selling/Print Format/Quotation Modern/Quotation Modern.txt rename to erpnext/selling/Print Format/Quotation Modern/Quotation Modern.json diff --git a/erpnext/selling/Print Format/Quotation Spartan/Quotation Spartan.txt b/erpnext/selling/Print Format/Quotation Spartan/Quotation Spartan.json similarity index 100% rename from erpnext/selling/Print Format/Quotation Spartan/Quotation Spartan.txt rename to erpnext/selling/Print Format/Quotation Spartan/Quotation Spartan.json diff --git a/erpnext/selling/Print Format/Sales Order Classic/Sales Order Classic.txt b/erpnext/selling/Print Format/Sales Order Classic/Sales Order Classic.json similarity index 100% rename from erpnext/selling/Print Format/Sales Order Classic/Sales Order Classic.txt rename to erpnext/selling/Print Format/Sales Order Classic/Sales Order Classic.json diff --git a/erpnext/selling/Print Format/Sales Order Modern/Sales Order Modern.txt b/erpnext/selling/Print Format/Sales Order Modern/Sales Order Modern.json similarity index 100% rename from erpnext/selling/Print Format/Sales Order Modern/Sales Order Modern.txt rename to erpnext/selling/Print Format/Sales Order Modern/Sales Order Modern.json diff --git a/erpnext/selling/Print Format/Sales Order Spartan/Sales Order Spartan.txt b/erpnext/selling/Print Format/Sales Order Spartan/Sales Order Spartan.json similarity index 100% rename from erpnext/selling/Print Format/Sales Order Spartan/Sales Order Spartan.txt rename to erpnext/selling/Print Format/Sales Order Spartan/Sales Order Spartan.json diff --git a/erpnext/selling/doctype/campaign/campaign.txt b/erpnext/selling/doctype/campaign/campaign.json similarity index 100% rename from erpnext/selling/doctype/campaign/campaign.txt rename to erpnext/selling/doctype/campaign/campaign.json diff --git a/erpnext/selling/doctype/campaign/test_campaign.py b/erpnext/selling/doctype/campaign/test_campaign.py index d3bf61e80a8..5d7c9a4649f 100644 --- a/erpnext/selling/doctype/campaign/test_campaign.py +++ b/erpnext/selling/doctype/campaign/test_campaign.py @@ -1,7 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{"doctype":"Campaign", "campaign_name":"_Test Campaign"}], - [{"doctype":"Campaign", "campaign_name":"_Test Campaign 1"}], -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Campaign') \ No newline at end of file diff --git a/erpnext/selling/doctype/customer/customer.txt b/erpnext/selling/doctype/customer/customer.json similarity index 100% rename from erpnext/selling/doctype/customer/customer.txt rename to erpnext/selling/doctype/customer/customer.json diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py index b6a7116843a..be60795ccca 100644 --- a/erpnext/selling/doctype/customer/test_customer.py +++ b/erpnext/selling/doctype/customer/test_customer.py @@ -49,29 +49,4 @@ class TestCustomer(unittest.TestCase): test_ignore = ["Price List"] -test_records = [ - [{ - "doctype": "Customer", - "customer_name": "_Test Customer", - "customer_type": "Individual", - "customer_group": "_Test Customer Group", - "territory": "_Test Territory", - "company": "_Test Company" - }], - [{ - "doctype": "Customer", - "customer_name": "_Test Customer 1", - "customer_type": "Individual", - "customer_group": "_Test Customer Group", - "territory": "_Test Territory", - "company": "_Test Company" - }], - [{ - "doctype": "Customer", - "customer_name": "_Test Customer 2", - "customer_type": "Individual", - "customer_group": "_Test Customer Group", - "territory": "_Test Territory", - "company": "_Test Company" - }] -] \ No newline at end of file +test_records = frappe.get_test_records('Customer') \ No newline at end of file diff --git a/erpnext/selling/doctype/industry_type/industry_type.txt b/erpnext/selling/doctype/industry_type/industry_type.json similarity index 100% rename from erpnext/selling/doctype/industry_type/industry_type.txt rename to erpnext/selling/doctype/industry_type/industry_type.json diff --git a/erpnext/selling/doctype/industry_type/test_industry_type.py b/erpnext/selling/doctype/industry_type/test_industry_type.py index 91679c77bbe..31c5bb26721 100644 --- a/erpnext/selling/doctype/industry_type/test_industry_type.py +++ b/erpnext/selling/doctype/industry_type/test_industry_type.py @@ -1,7 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{"doctype":"Industry Type", "industry":"_Test Industry"}], - [{"doctype":"Industry Type", "industry":"_Test Industry 1"}], -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Industry Type') \ No newline at end of file diff --git a/erpnext/selling/doctype/installation_note/installation_note.txt b/erpnext/selling/doctype/installation_note/installation_note.json similarity index 100% rename from erpnext/selling/doctype/installation_note/installation_note.txt rename to erpnext/selling/doctype/installation_note/installation_note.json diff --git a/erpnext/selling/doctype/installation_note_item/installation_note_item.txt b/erpnext/selling/doctype/installation_note_item/installation_note_item.json similarity index 100% rename from erpnext/selling/doctype/installation_note_item/installation_note_item.txt rename to erpnext/selling/doctype/installation_note_item/installation_note_item.json diff --git a/erpnext/selling/doctype/lead/lead.txt b/erpnext/selling/doctype/lead/lead.json similarity index 100% rename from erpnext/selling/doctype/lead/lead.txt rename to erpnext/selling/doctype/lead/lead.json diff --git a/erpnext/selling/doctype/lead/test_lead.py b/erpnext/selling/doctype/lead/test_lead.py index a403e933325..697f2e156fc 100644 --- a/erpnext/selling/doctype/lead/test_lead.py +++ b/erpnext/selling/doctype/lead/test_lead.py @@ -3,16 +3,7 @@ from __future__ import unicode_literals -test_records = [ - [{"doctype":"Lead", "lead_name": "_Test Lead", "status":"Open", - "email_id":"test_lead@example.com", "territory": "_Test Territory"}], - [{"doctype":"Lead", "lead_name": "_Test Lead 1", "status":"Open", - "email_id":"test_lead1@example.com"}], - [{"doctype":"Lead", "lead_name": "_Test Lead 2", "status":"Contacted", - "email_id":"test_lead2@example.com"}], - [{"doctype":"Lead", "lead_name": "_Test Lead 3", "status":"Converted", - "email_id":"test_lead3@example.com"}], -] +test_records = frappe.get_test_records('Lead') import frappe import unittest @@ -28,5 +19,4 @@ class TestLead(unittest.TestCase): customer[0]["company"] = "_Test Company" customer[0]["customer_group"] = "_Test Customer Group" - frappe.get_doc(customer).insert() - \ No newline at end of file + frappe.get_doc(customer).insert() \ No newline at end of file diff --git a/erpnext/selling/doctype/opportunity/opportunity.txt b/erpnext/selling/doctype/opportunity/opportunity.json similarity index 100% rename from erpnext/selling/doctype/opportunity/opportunity.txt rename to erpnext/selling/doctype/opportunity/opportunity.json diff --git a/erpnext/selling/doctype/opportunity_item/opportunity_item.txt b/erpnext/selling/doctype/opportunity_item/opportunity_item.json similarity index 100% rename from erpnext/selling/doctype/opportunity_item/opportunity_item.txt rename to erpnext/selling/doctype/opportunity_item/opportunity_item.json diff --git a/erpnext/selling/doctype/quotation/quotation.txt b/erpnext/selling/doctype/quotation/quotation.json similarity index 100% rename from erpnext/selling/doctype/quotation/quotation.txt rename to erpnext/selling/doctype/quotation/quotation.json diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 6b248580213..900d764afe6 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr -from frappe.model.code import get_obj from frappe import _, msgprint from erpnext.controllers.selling_controller import SellingController @@ -74,7 +73,7 @@ class Quotation(SellingController): self.check_item_table() # Check for Approving Authority - get_obj('Authorization Control').validate_approving_authority(self.doctype, self.company, self.grand_total, self) + frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.grand_total, self) #update enquiry status self.update_opportunity() diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py index b9f49211401..54aa1c4eb00 100644 --- a/erpnext/selling/doctype/quotation/test_quotation.py +++ b/erpnext/selling/doctype/quotation/test_quotation.py @@ -11,7 +11,7 @@ class TestQuotation(unittest.TestCase): def test_make_sales_order(self): from erpnext.selling.doctype.quotation.quotation import make_sales_order - quotation = frappe.get_doc(copy=test_records[0]) + quotation = frappe.copy_doc(test_records[0]) quotation.insert() self.assertRaises(frappe.ValidationError, make_sales_order, quotation.name) @@ -32,37 +32,4 @@ class TestQuotation(unittest.TestCase): frappe.get_doc(sales_order).insert() -test_records = [ - [ - { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "quotation_to": "Customer", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "customer_group": "_Test Customer Group", - "doctype": "Quotation", - "fiscal_year": "_Test Fiscal Year 2013", - "order_type": "Sales", - "plc_conversion_rate": 1.0, - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", - "territory": "_Test Territory", - "transaction_date": "2013-02-21", - "grand_total": 1000.0, - "grand_total_export": 1000.0, - }, - { - "description": "CPU", - "doctype": "Quotation Item", - "item_code": "_Test Item Home Desktop 100", - "item_name": "CPU", - "parentfield": "quotation_details", - "qty": 10.0, - "base_rate": 100.0, - "rate": 100.0, - "base_amount": 1000.0, - } - ], -] \ No newline at end of file +test_records = frappe.get_test_records('Quotation') \ No newline at end of file diff --git a/erpnext/selling/doctype/quotation_item/quotation_item.txt b/erpnext/selling/doctype/quotation_item/quotation_item.json similarity index 100% rename from erpnext/selling/doctype/quotation_item/quotation_item.txt rename to erpnext/selling/doctype/quotation_item/quotation_item.json diff --git a/erpnext/selling/doctype/sales_bom/sales_bom.txt b/erpnext/selling/doctype/sales_bom/sales_bom.json similarity index 100% rename from erpnext/selling/doctype/sales_bom/sales_bom.txt rename to erpnext/selling/doctype/sales_bom/sales_bom.json diff --git a/erpnext/selling/doctype/sales_bom/test_sales_bom.py b/erpnext/selling/doctype/sales_bom/test_sales_bom.py index 02ca68f0c52..6d39ee2e0f7 100644 --- a/erpnext/selling/doctype/sales_bom/test_sales_bom.py +++ b/erpnext/selling/doctype/sales_bom/test_sales_bom.py @@ -1,23 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [ - { - "doctype": "Sales BOM", - "new_item_code": "_Test Sales BOM Item" - }, - { - "doctype": "Sales BOM Item", - "item_code": "_Test Item", - "parentfield": "sales_bom_items", - "qty": 5.0 - }, - { - "doctype": "Sales BOM Item", - "item_code": "_Test Item Home Desktop 100", - "parentfield": "sales_bom_items", - "qty": 2.0 - } - ], -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Sales Bom') \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_bom_item/sales_bom_item.txt b/erpnext/selling/doctype/sales_bom_item/sales_bom_item.json similarity index 100% rename from erpnext/selling/doctype/sales_bom_item/sales_bom_item.txt rename to erpnext/selling/doctype/sales_bom_item/sales_bom_item.json diff --git a/erpnext/selling/doctype/sales_order/sales_order.txt b/erpnext/selling/doctype/sales_order/sales_order.json similarity index 100% rename from erpnext/selling/doctype/sales_order/sales_order.txt rename to erpnext/selling/doctype/sales_order/sales_order.json diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index e553b26f04a..0dbb78ac26b 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -7,7 +7,6 @@ import frappe.utils from frappe.utils import cstr, flt, getdate -from frappe.model.code import get_obj from frappe import msgprint from frappe.model.mapper import get_mapped_doc @@ -161,7 +160,7 @@ class SalesOrder(SellingController): self.check_credit(self.grand_total) - get_obj('Authorization Control').validate_approving_authority(self.doctype, self.grand_total, self) + frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.grand_total, self) self.update_prevdoc_status('submit') frappe.db.set(self, 'status', 'Submitted') diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py index 62411b05430..e56de33db5c 100644 --- a/erpnext/selling/doctype/sales_order/test_sales_order.py +++ b/erpnext/selling/doctype/sales_order/test_sales_order.py @@ -12,7 +12,7 @@ class TestSalesOrder(unittest.TestCase): def test_make_material_request(self): from erpnext.selling.doctype.sales_order.sales_order import make_material_request - so = frappe.get_doc(copy=test_records[0]).insert() + so = frappe.copy_doc(test_records[0]).insert() self.assertRaises(frappe.ValidationError, make_material_request, so.name) @@ -27,7 +27,7 @@ class TestSalesOrder(unittest.TestCase): def test_make_delivery_note(self): from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note - so = frappe.get_doc(copy=test_records[0]).insert() + so = frappe.copy_doc(test_records[0]).insert() self.assertRaises(frappe.ValidationError, make_delivery_note, so.name) @@ -42,7 +42,7 @@ class TestSalesOrder(unittest.TestCase): def test_make_sales_invoice(self): from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice - so = frappe.get_doc(copy=test_records[0]).insert() + so = frappe.copy_doc(test_records[0]).insert() self.assertRaises(frappe.ValidationError, make_sales_invoice, so.name) @@ -68,7 +68,7 @@ class TestSalesOrder(unittest.TestCase): if not so_doclist: so_doclist = test_records[0] - w = frappe.get_doc(copy=so_doclist) + w = frappe.copy_doc(so_doclist) w.insert() w.submit() @@ -290,7 +290,7 @@ class TestSalesOrder(unittest.TestCase): frappe.set_user("test@example.com") from frappe.model.bean import BeanPermissionError - so = frappe.get_doc(copy = test_records[0]) + so = frappe.copy_doc(test_records[0]) so.company = "_Test Company 1" so.conversion_rate = 0.02 so.plc_conversion_rate = 0.02 @@ -304,39 +304,4 @@ class TestSalesOrder(unittest.TestCase): test_dependencies = ["Sales BOM", "Currency Exchange"] -test_records = [ - [ - { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "customer_group": "_Test Customer Group", - "doctype": "Sales Order", - "fiscal_year": "_Test Fiscal Year 2013", - "order_type": "Sales", - "delivery_date": "2013-02-23", - "plc_conversion_rate": 1.0, - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", - "territory": "_Test Territory", - "transaction_date": "2013-02-21", - "grand_total": 1000.0, - "grand_total_export": 1000.0, - "naming_series": "_T-Sales Order-" - }, - { - "description": "CPU", - "doctype": "Sales Order Item", - "item_code": "_Test Item Home Desktop 100", - "item_name": "CPU", - "parentfield": "sales_order_details", - "qty": 10.0, - "base_rate": 100.0, - "rate": 100.0, - "base_amount": 1000.0, - "warehouse": "_Test Warehouse - _TC", - } - ], -] \ No newline at end of file +test_records = frappe.get_test_records('Sales Order') \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_order_item/sales_order_item.txt b/erpnext/selling/doctype/sales_order_item/sales_order_item.json similarity index 100% rename from erpnext/selling/doctype/sales_order_item/sales_order_item.txt rename to erpnext/selling/doctype/sales_order_item/sales_order_item.json diff --git a/erpnext/selling/doctype/sales_team/sales_team.txt b/erpnext/selling/doctype/sales_team/sales_team.json similarity index 100% rename from erpnext/selling/doctype/sales_team/sales_team.txt rename to erpnext/selling/doctype/sales_team/sales_team.json diff --git a/erpnext/selling/doctype/selling_settings/selling_settings.txt b/erpnext/selling/doctype/selling_settings/selling_settings.json similarity index 100% rename from erpnext/selling/doctype/selling_settings/selling_settings.txt rename to erpnext/selling/doctype/selling_settings/selling_settings.json diff --git a/erpnext/selling/doctype/sms_center/sms_center.txt b/erpnext/selling/doctype/sms_center/sms_center.json similarity index 100% rename from erpnext/selling/doctype/sms_center/sms_center.txt rename to erpnext/selling/doctype/sms_center/sms_center.json diff --git a/erpnext/selling/doctype/sms_center/sms_center.py b/erpnext/selling/doctype/sms_center/sms_center.py index 51f9d770611..487df386449 100644 --- a/erpnext/selling/doctype/sms_center/sms_center.py +++ b/erpnext/selling/doctype/sms_center/sms_center.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr -from frappe.model.code import get_obj from frappe import msgprint, _ from frappe.model.document import Document @@ -74,4 +73,4 @@ class SmsCenter(Document): else: receiver_list = self.get_receiver_nos() if receiver_list: - msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, cstr(self.message))) \ No newline at end of file + msgprint(frappe.get_doc('SMS Control', 'SMS Control').send_sms(receiver_list, cstr(self.message))) \ No newline at end of file diff --git a/erpnext/selling/page/sales_analytics/sales_analytics.txt b/erpnext/selling/page/sales_analytics/sales_analytics.json similarity index 100% rename from erpnext/selling/page/sales_analytics/sales_analytics.txt rename to erpnext/selling/page/sales_analytics/sales_analytics.json diff --git a/erpnext/selling/page/sales_browser/sales_browser.txt b/erpnext/selling/page/sales_browser/sales_browser.json similarity index 100% rename from erpnext/selling/page/sales_browser/sales_browser.txt rename to erpnext/selling/page/sales_browser/sales_browser.json diff --git a/erpnext/selling/page/sales_funnel/sales_funnel.txt b/erpnext/selling/page/sales_funnel/sales_funnel.json similarity index 100% rename from erpnext/selling/page/sales_funnel/sales_funnel.txt rename to erpnext/selling/page/sales_funnel/sales_funnel.json diff --git a/erpnext/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.txt b/erpnext/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.json similarity index 100% rename from erpnext/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.txt rename to erpnext/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.json diff --git a/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.txt b/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.json similarity index 100% rename from erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.txt rename to erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.json diff --git a/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.txt b/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.json similarity index 100% rename from erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.txt rename to erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.json diff --git a/erpnext/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.txt b/erpnext/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.json similarity index 100% rename from erpnext/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.txt rename to erpnext/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.json diff --git a/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.txt b/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.json similarity index 100% rename from erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.txt rename to erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.json diff --git a/erpnext/selling/report/lead_details/lead_details.txt b/erpnext/selling/report/lead_details/lead_details.json similarity index 100% rename from erpnext/selling/report/lead_details/lead_details.txt rename to erpnext/selling/report/lead_details/lead_details.json diff --git a/erpnext/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.txt b/erpnext/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.json similarity index 100% rename from erpnext/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.txt rename to erpnext/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.json diff --git a/erpnext/selling/report/quotation_trends/quotation_trends.txt b/erpnext/selling/report/quotation_trends/quotation_trends.json similarity index 100% rename from erpnext/selling/report/quotation_trends/quotation_trends.txt rename to erpnext/selling/report/quotation_trends/quotation_trends.json diff --git a/erpnext/selling/report/sales_order_trends/sales_order_trends.txt b/erpnext/selling/report/sales_order_trends/sales_order_trends.json similarity index 100% rename from erpnext/selling/report/sales_order_trends/sales_order_trends.txt rename to erpnext/selling/report/sales_order_trends/sales_order_trends.json diff --git a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.txt b/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.json similarity index 100% rename from erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.txt rename to erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.json diff --git a/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.txt b/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.json similarity index 100% rename from erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.txt rename to erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.json diff --git a/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.txt b/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.json similarity index 100% rename from erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.txt rename to erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.json diff --git a/erpnext/setup/doctype/applicable_territory/applicable_territory.txt b/erpnext/setup/doctype/applicable_territory/applicable_territory.json similarity index 100% rename from erpnext/setup/doctype/applicable_territory/applicable_territory.txt rename to erpnext/setup/doctype/applicable_territory/applicable_territory.json diff --git a/erpnext/setup/doctype/authorization_control/authorization_control.txt b/erpnext/setup/doctype/authorization_control/authorization_control.json similarity index 100% rename from erpnext/setup/doctype/authorization_control/authorization_control.txt rename to erpnext/setup/doctype/authorization_control/authorization_control.json diff --git a/erpnext/setup/doctype/authorization_rule/authorization_rule.txt b/erpnext/setup/doctype/authorization_rule/authorization_rule.json similarity index 100% rename from erpnext/setup/doctype/authorization_rule/authorization_rule.txt rename to erpnext/setup/doctype/authorization_rule/authorization_rule.json diff --git a/erpnext/setup/doctype/backup_manager/backup_manager.txt b/erpnext/setup/doctype/backup_manager/backup_manager.json similarity index 100% rename from erpnext/setup/doctype/backup_manager/backup_manager.txt rename to erpnext/setup/doctype/backup_manager/backup_manager.json diff --git a/erpnext/setup/doctype/brand/brand.txt b/erpnext/setup/doctype/brand/brand.json similarity index 100% rename from erpnext/setup/doctype/brand/brand.txt rename to erpnext/setup/doctype/brand/brand.json diff --git a/erpnext/setup/doctype/brand/test_brand.py b/erpnext/setup/doctype/brand/test_brand.py index c66413ffa0f..34dc6de0485 100644 --- a/erpnext/setup/doctype/brand/test_brand.py +++ b/erpnext/setup/doctype/brand/test_brand.py @@ -1,9 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Brand", - "brand": "_Test Brand" - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Brand') \ No newline at end of file diff --git a/erpnext/setup/doctype/company/company.txt b/erpnext/setup/doctype/company/company.json similarity index 100% rename from erpnext/setup/doctype/company/company.txt rename to erpnext/setup/doctype/company/company.json diff --git a/erpnext/setup/doctype/company/test_company.py b/erpnext/setup/doctype/company/test_company.py index 691bc72f9d0..570cd23aa9d 100644 --- a/erpnext/setup/doctype/company/test_company.py +++ b/erpnext/setup/doctype/company/test_company.py @@ -29,19 +29,4 @@ class TestCompany(unittest.TestCase): frappe.delete_doc("Company", "_Test Company 2") -test_records = [ - [{ - "doctype": "Company", - "company_name": "_Test Company", - "abbr": "_TC", - "default_currency": "INR", - "domain": "Manufacturing" - }], - [{ - "doctype": "Company", - "company_name": "_Test Company 1", - "abbr": "_TC1", - "default_currency": "USD", - "domain": "Retail" - }], -] \ No newline at end of file +test_records = frappe.get_test_records('Company') \ No newline at end of file diff --git a/erpnext/setup/doctype/contact_control/contact_control.txt b/erpnext/setup/doctype/contact_control/contact_control.json similarity index 100% rename from erpnext/setup/doctype/contact_control/contact_control.txt rename to erpnext/setup/doctype/contact_control/contact_control.json diff --git a/erpnext/setup/doctype/country/country.txt b/erpnext/setup/doctype/country/country.json similarity index 100% rename from erpnext/setup/doctype/country/country.txt rename to erpnext/setup/doctype/country/country.json diff --git a/erpnext/setup/doctype/country/test_country.py b/erpnext/setup/doctype/country/test_country.py index 27174a10242..b2610667af4 100644 --- a/erpnext/setup/doctype/country/test_country.py +++ b/erpnext/setup/doctype/country/test_country.py @@ -1,9 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Country", - "country_name": "_Test Country" - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Country') \ No newline at end of file diff --git a/erpnext/setup/doctype/currency/currency.txt b/erpnext/setup/doctype/currency/currency.json similarity index 100% rename from erpnext/setup/doctype/currency/currency.txt rename to erpnext/setup/doctype/currency/currency.json diff --git a/erpnext/setup/doctype/currency/test_currency.py b/erpnext/setup/doctype/currency/test_currency.py index 41a2fab2548..f0c6cee2609 100644 --- a/erpnext/setup/doctype/currency/test_currency.py +++ b/erpnext/setup/doctype/currency/test_currency.py @@ -2,4 +2,6 @@ # License: GNU General Public License v3. See license.txt # pre loaded -test_records = [] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Currency') \ No newline at end of file diff --git a/erpnext/setup/doctype/currency_exchange/currency_exchange.txt b/erpnext/setup/doctype/currency_exchange/currency_exchange.json similarity index 100% rename from erpnext/setup/doctype/currency_exchange/currency_exchange.txt rename to erpnext/setup/doctype/currency_exchange/currency_exchange.json diff --git a/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py b/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py index f8260be607b..6726dc83188 100644 --- a/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py +++ b/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py @@ -1,23 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Currency Exchange", - "from_currency": "USD", - "to_currency": "INR", - "exchange_rate": 60.0 - }], - [{ - "doctype": "Currency Exchange", - "from_currency": "USD", - "to_currency": "EUR", - "exchange_rate": 0.773 - }], - [{ - "doctype": "Currency Exchange", - "from_currency": "INR", - "to_currency": "USD", - "exchange_rate": 0.0167 - }], -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Currency Exchange') \ No newline at end of file diff --git a/erpnext/setup/doctype/customer_group/customer_group.txt b/erpnext/setup/doctype/customer_group/customer_group.json similarity index 100% rename from erpnext/setup/doctype/customer_group/customer_group.txt rename to erpnext/setup/doctype/customer_group/customer_group.json diff --git a/erpnext/setup/doctype/customer_group/test_customer_group.py b/erpnext/setup/doctype/customer_group/test_customer_group.py index e08ec23e3f9..68f7aacc3b3 100644 --- a/erpnext/setup/doctype/customer_group/test_customer_group.py +++ b/erpnext/setup/doctype/customer_group/test_customer_group.py @@ -4,11 +4,6 @@ test_ignore = ["Price List"] -test_records = [ - [{ - "doctype": "Customer Group", - "customer_group_name": "_Test Customer Group", - "parent_customer_group": "All Customer Groups", - "is_group": "No" - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Customer Group') \ No newline at end of file diff --git a/erpnext/setup/doctype/email_digest/email_digest.txt b/erpnext/setup/doctype/email_digest/email_digest.json similarity index 100% rename from erpnext/setup/doctype/email_digest/email_digest.txt rename to erpnext/setup/doctype/email_digest/email_digest.json diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py index 5d3efcd7a55..e077c957155 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.py +++ b/erpnext/setup/doctype/email_digest/email_digest.py @@ -471,12 +471,11 @@ class EmailDigest(DocListController): self.get_next_sending() def send(): - from frappe.model.code import get_obj - from frappe.utils import getdate + from frappe.utils import getdate now_date = now_datetime().date() for ed in frappe.db.sql("""select name from `tabEmail Digest` where enabled=1 and docstatus<2""", as_list=1): - ed_obj = get_obj('Email Digest', ed[0]) + ed_obj = frappe.get_doc('Email Digest', ed[0]) if (now_date == ed_obj.get_next_sending()): ed_obj.send() diff --git a/erpnext/setup/doctype/features_setup/features_setup.txt b/erpnext/setup/doctype/features_setup/features_setup.json similarity index 100% rename from erpnext/setup/doctype/features_setup/features_setup.txt rename to erpnext/setup/doctype/features_setup/features_setup.json diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.txt b/erpnext/setup/doctype/global_defaults/global_defaults.json similarity index 100% rename from erpnext/setup/doctype/global_defaults/global_defaults.txt rename to erpnext/setup/doctype/global_defaults/global_defaults.json diff --git a/erpnext/setup/doctype/item_group/item_group.txt b/erpnext/setup/doctype/item_group/item_group.json similarity index 100% rename from erpnext/setup/doctype/item_group/item_group.txt rename to erpnext/setup/doctype/item_group/item_group.json diff --git a/erpnext/setup/doctype/item_group/test_item_group.py b/erpnext/setup/doctype/item_group/test_item_group.py index 4bdace8ef5a..ae234996206 100644 --- a/erpnext/setup/doctype/item_group/test_item_group.py +++ b/erpnext/setup/doctype/item_group/test_item_group.py @@ -7,74 +7,7 @@ import frappe from frappe.utils.nestedset import NestedSetRecursionError, NestedSetMultipleRootsError, \ NestedSetChildExistsError, NestedSetInvalidMergeError, rebuild_tree, get_ancestors_of -test_records = [ - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group", - "parent_item_group": "All Item Groups", - "is_group": "No" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group Desktops", - "parent_item_group": "All Item Groups", - "is_group": "No" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group A", - "parent_item_group": "All Item Groups", - "is_group": "Yes" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group B", - "parent_item_group": "All Item Groups", - "is_group": "Yes" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group B - 1", - "parent_item_group": "_Test Item Group B", - "is_group": "Yes" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group B - 2", - "parent_item_group": "_Test Item Group B", - "is_group": "Yes" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group B - 3", - "parent_item_group": "_Test Item Group B", - "is_group": "No" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group C", - "parent_item_group": "All Item Groups", - "is_group": "Yes" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group C - 1", - "parent_item_group": "_Test Item Group C", - "is_group": "Yes" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group C - 2", - "parent_item_group": "_Test Item Group C", - "is_group": "Yes" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group D", - "parent_item_group": "All Item Groups", - "is_group": "Yes" - }], -] +test_records = frappe.get_test_records('Item Group') class TestItem(unittest.TestCase): def test_basic_tree(self, records=None): @@ -228,7 +161,7 @@ class TestItem(unittest.TestCase): self.assertEquals(new_rgt, item_group.rgt - 2) # insert it back - frappe.get_doc(copy=test_records[6]).insert() + frappe.copy_doc(test_records[6]).insert() self.test_basic_tree() @@ -243,7 +176,7 @@ class TestItem(unittest.TestCase): self.test_basic_tree(records=records_to_test) # insert Group B back - frappe.get_doc(copy=test_records[3]).insert() + frappe.copy_doc(test_records[3]).insert() self.test_basic_tree() # move its children back @@ -263,7 +196,7 @@ class TestItem(unittest.TestCase): self.test_basic_tree(records=records_to_test) # insert Group B - 2back - frappe.get_doc(copy=test_records[5]).insert() + frappe.copy_doc(test_records[5]).insert() self.test_basic_tree() def test_merge_leaf_into_group(self): diff --git a/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.txt b/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.json similarity index 100% rename from erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.txt rename to erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.json diff --git a/erpnext/setup/doctype/naming_series/naming_series.txt b/erpnext/setup/doctype/naming_series/naming_series.json similarity index 100% rename from erpnext/setup/doctype/naming_series/naming_series.txt rename to erpnext/setup/doctype/naming_series/naming_series.json diff --git a/erpnext/setup/doctype/naming_series/naming_series.py b/erpnext/setup/doctype/naming_series/naming_series.py index 7338de01890..8fc596e05f8 100644 --- a/erpnext/setup/doctype/naming_series/naming_series.py +++ b/erpnext/setup/doctype/naming_series/naming_series.py @@ -6,7 +6,6 @@ import frappe from frappe.utils import cstr from frappe import msgprint, throw, _ -import frappe.model.doctype from frappe.model.document import Document @@ -96,7 +95,7 @@ class NamingSeries(Document): where dt.name = df.dt and df.fieldname='naming_series' and dt.name != %s""", self.select_doc_for_series) )) - sr = [[frappe.model.doctype.get_property(p, 'options', 'naming_series'), p] + sr = [[frappe.get_meta(p).get_field("naming_series").options, p] for p in parent] options = self.scrub_options_list(self.set_options.split("\n")) for series in options: @@ -120,9 +119,7 @@ class NamingSeries(Document): throw('Special Characters except "-" and "/" not allowed in naming series') def get_options(self, arg=''): - sr = frappe.model.doctype.get_property(self.select_doc_for_series, - 'options', 'naming_series') - return sr + return frappe.get_meta(self.select_doc_for_series).get_field("naming_series").options def get_current(self, arg=None): """get series current""" @@ -172,7 +169,6 @@ def set_by_naming_series(doctype, fieldname, naming_series, hide_name_field=True ifnull({fieldname}, '')=''""".format(doctype=doctype, fieldname=fieldname)) def get_default_naming_series(doctype): - from frappe.model.doctype import get_property - naming_series = get_property(doctype, "options", "naming_series") + naming_series = frappe.model.get_meta(doctype).get_field("naming_series").options or "" naming_series = naming_series.split("\n") return naming_series[0] or naming_series[1] \ No newline at end of file diff --git a/erpnext/setup/doctype/notification_control/notification_control.txt b/erpnext/setup/doctype/notification_control/notification_control.json similarity index 100% rename from erpnext/setup/doctype/notification_control/notification_control.txt rename to erpnext/setup/doctype/notification_control/notification_control.json diff --git a/erpnext/setup/doctype/print_heading/print_heading.txt b/erpnext/setup/doctype/print_heading/print_heading.json similarity index 100% rename from erpnext/setup/doctype/print_heading/print_heading.txt rename to erpnext/setup/doctype/print_heading/print_heading.json diff --git a/erpnext/setup/doctype/print_heading/test_print_heading.py b/erpnext/setup/doctype/print_heading/test_print_heading.py index e9f61c4b485..6ccb4d677ad 100644 --- a/erpnext/setup/doctype/print_heading/test_print_heading.py +++ b/erpnext/setup/doctype/print_heading/test_print_heading.py @@ -1,4 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [[{"print_heading": "_Test Print Heading"}]] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Print Heading') \ No newline at end of file diff --git a/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.txt b/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.json similarity index 100% rename from erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.txt rename to erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.json diff --git a/erpnext/setup/doctype/quotation_lost_reason/test_quotation_lost_reason.py b/erpnext/setup/doctype/quotation_lost_reason/test_quotation_lost_reason.py index 486dd86e366..0c96d451426 100644 --- a/erpnext/setup/doctype/quotation_lost_reason/test_quotation_lost_reason.py +++ b/erpnext/setup/doctype/quotation_lost_reason/test_quotation_lost_reason.py @@ -1,4 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [[{"doctype":"Quotation Lost Reason", "order_lost_reason": "_Test Quotation Lost Reason"}]] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Quotation Lost Reason') \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_email_settings/sales_email_settings.txt b/erpnext/setup/doctype/sales_email_settings/sales_email_settings.json similarity index 100% rename from erpnext/setup/doctype/sales_email_settings/sales_email_settings.txt rename to erpnext/setup/doctype/sales_email_settings/sales_email_settings.json diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.txt b/erpnext/setup/doctype/sales_partner/sales_partner.json similarity index 100% rename from erpnext/setup/doctype/sales_partner/sales_partner.txt rename to erpnext/setup/doctype/sales_partner/sales_partner.json diff --git a/erpnext/setup/doctype/sales_partner/test_sales_partner.py b/erpnext/setup/doctype/sales_partner/test_sales_partner.py index 2dc000680ae..e14f5ec6e7b 100644 --- a/erpnext/setup/doctype/sales_partner/test_sales_partner.py +++ b/erpnext/setup/doctype/sales_partner/test_sales_partner.py @@ -1,4 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Sales Partner') \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_person/sales_person.txt b/erpnext/setup/doctype/sales_person/sales_person.json similarity index 100% rename from erpnext/setup/doctype/sales_person/sales_person.txt rename to erpnext/setup/doctype/sales_person/sales_person.json diff --git a/erpnext/setup/doctype/sales_person/test_sales_person.py b/erpnext/setup/doctype/sales_person/test_sales_person.py index ebbc25ed9bb..8db97d387f9 100644 --- a/erpnext/setup/doctype/sales_person/test_sales_person.py +++ b/erpnext/setup/doctype/sales_person/test_sales_person.py @@ -2,28 +2,6 @@ # License: GNU General Public License v3. See license.txt test_dependencies = ["Employee"] -test_records = [ - [{ - "doctype": "Sales Person", - "sales_person_name": "_Test Sales Person", - "parent_sales_person": "Sales Team", - "is_group": "No", - "employee": "_T-Employee-0001", - }], - [{ - "doctype": "Sales Person", - "sales_person_name": "_Test Sales Person 1", - "parent_sales_person": "Sales Team", - "is_group": "No", - "employee": "_T-Employee-0002", - }], - [{ - "doctype": "Sales Person", - "sales_person_name": "_Test Sales Person 2", - "parent_sales_person": "Sales Team", - "is_group": "No", - "employee": "_T-Employee-0003", - }] - - -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Sales Person') \ No newline at end of file diff --git a/erpnext/setup/doctype/sms_parameter/sms_parameter.txt b/erpnext/setup/doctype/sms_parameter/sms_parameter.json similarity index 100% rename from erpnext/setup/doctype/sms_parameter/sms_parameter.txt rename to erpnext/setup/doctype/sms_parameter/sms_parameter.json diff --git a/erpnext/setup/doctype/sms_settings/sms_settings.txt b/erpnext/setup/doctype/sms_settings/sms_settings.json similarity index 100% rename from erpnext/setup/doctype/sms_settings/sms_settings.txt rename to erpnext/setup/doctype/sms_settings/sms_settings.json diff --git a/erpnext/setup/doctype/supplier_type/supplier_type.txt b/erpnext/setup/doctype/supplier_type/supplier_type.json similarity index 100% rename from erpnext/setup/doctype/supplier_type/supplier_type.txt rename to erpnext/setup/doctype/supplier_type/supplier_type.json diff --git a/erpnext/setup/doctype/supplier_type/test_supplier_type.py b/erpnext/setup/doctype/supplier_type/test_supplier_type.py index eb49ef4ceb4..b365a05a854 100644 --- a/erpnext/setup/doctype/supplier_type/test_supplier_type.py +++ b/erpnext/setup/doctype/supplier_type/test_supplier_type.py @@ -1,9 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Supplier Type", - "supplier_type": "_Test Supplier Type", - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Supplier Type') \ No newline at end of file diff --git a/erpnext/setup/doctype/target_detail/target_detail.txt b/erpnext/setup/doctype/target_detail/target_detail.json similarity index 100% rename from erpnext/setup/doctype/target_detail/target_detail.txt rename to erpnext/setup/doctype/target_detail/target_detail.json diff --git a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.txt b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.json similarity index 100% rename from erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.txt rename to erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.json diff --git a/erpnext/setup/doctype/terms_and_conditions/test_terms_and_conditions.py b/erpnext/setup/doctype/terms_and_conditions/test_terms_and_conditions.py index acebf7982cd..146930f373b 100644 --- a/erpnext/setup/doctype/terms_and_conditions/test_terms_and_conditions.py +++ b/erpnext/setup/doctype/terms_and_conditions/test_terms_and_conditions.py @@ -1,4 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [[{"title": "_Test Terms and Conditions", "terms": "_Test Terms"}]] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Terms And Conditions') \ No newline at end of file diff --git a/erpnext/setup/doctype/territory/territory.txt b/erpnext/setup/doctype/territory/territory.json similarity index 100% rename from erpnext/setup/doctype/territory/territory.txt rename to erpnext/setup/doctype/territory/territory.json diff --git a/erpnext/setup/doctype/territory/test_territory.py b/erpnext/setup/doctype/territory/test_territory.py index 3068b5f969c..22fad29f6a7 100644 --- a/erpnext/setup/doctype/territory/test_territory.py +++ b/erpnext/setup/doctype/territory/test_territory.py @@ -1,35 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Territory", - "territory_name": "_Test Territory", - "parent_territory": "All Territories", - "is_group": "No", - }], - [{ - "doctype": "Territory", - "territory_name": "_Test Territory India", - "parent_territory": "All Territories", - "is_group": "Yes", - }], - [{ - "doctype": "Territory", - "territory_name": "_Test Territory Maharashtra", - "parent_territory": "_Test Territory India", - "is_group": "No", - }], - [{ - "doctype": "Territory", - "territory_name": "_Test Territory Rest Of The World", - "parent_territory": "All Territories", - "is_group": "No", - }], - [{ - "doctype": "Territory", - "territory_name": "_Test Territory United States", - "parent_territory": "All Territories", - "is_group": "No", - }], -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Territory') \ No newline at end of file diff --git a/erpnext/setup/doctype/uom/test_uom.py b/erpnext/setup/doctype/uom/test_uom.py index 2a7f2eea311..3511874e6fa 100644 --- a/erpnext/setup/doctype/uom/test_uom.py +++ b/erpnext/setup/doctype/uom/test_uom.py @@ -1,14 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "UOM", - "uom_name": "_Test UOM", - "must_be_whole_number": 1 - }], - [{ - "doctype": "UOM", - "uom_name": "_Test UOM 1" - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Uom') \ No newline at end of file diff --git a/erpnext/setup/doctype/uom/uom.txt b/erpnext/setup/doctype/uom/uom.json similarity index 100% rename from erpnext/setup/doctype/uom/uom.txt rename to erpnext/setup/doctype/uom/uom.json diff --git a/erpnext/setup/doctype/website_item_group/website_item_group.txt b/erpnext/setup/doctype/website_item_group/website_item_group.json similarity index 100% rename from erpnext/setup/doctype/website_item_group/website_item_group.txt rename to erpnext/setup/doctype/website_item_group/website_item_group.json diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.txt b/erpnext/setup/page/setup_wizard/setup_wizard.json similarity index 100% rename from erpnext/setup/page/setup_wizard/setup_wizard.txt rename to erpnext/setup/page/setup_wizard/setup_wizard.json diff --git a/erpnext/startup/boot.py b/erpnext/startup/boot.py index 0311cdcd638..6624b1d91eb 100644 --- a/erpnext/startup/boot.py +++ b/erpnext/startup/boot.py @@ -8,7 +8,6 @@ import frappe def boot_session(bootinfo): """boot session - send website info if guest""" import frappe - import frappe.model.doc bootinfo['custom_css'] = frappe.db.get_value('Style Settings', None, 'custom_css') or '' bootinfo['website_settings'] = frappe.model.getsingle('Website Settings') @@ -18,7 +17,6 @@ def boot_session(bootinfo): load_country_and_currency(bootinfo) - import frappe.model.doctype bootinfo['notification_settings'] = frappe.get_doc("Notification Control", "Notification Control").get_values() diff --git a/erpnext/stock/Print Format/Delivery Note Classic/Delivery Note Classic.txt b/erpnext/stock/Print Format/Delivery Note Classic/Delivery Note Classic.json similarity index 100% rename from erpnext/stock/Print Format/Delivery Note Classic/Delivery Note Classic.txt rename to erpnext/stock/Print Format/Delivery Note Classic/Delivery Note Classic.json diff --git a/erpnext/stock/Print Format/Delivery Note Modern/Delivery Note Modern.txt b/erpnext/stock/Print Format/Delivery Note Modern/Delivery Note Modern.json similarity index 100% rename from erpnext/stock/Print Format/Delivery Note Modern/Delivery Note Modern.txt rename to erpnext/stock/Print Format/Delivery Note Modern/Delivery Note Modern.json diff --git a/erpnext/stock/Print Format/Delivery Note Packing List Wise/Delivery Note Packing List Wise.txt b/erpnext/stock/Print Format/Delivery Note Packing List Wise/Delivery Note Packing List Wise.json similarity index 100% rename from erpnext/stock/Print Format/Delivery Note Packing List Wise/Delivery Note Packing List Wise.txt rename to erpnext/stock/Print Format/Delivery Note Packing List Wise/Delivery Note Packing List Wise.json diff --git a/erpnext/stock/Print Format/Delivery Note Spartan/Delivery Note Spartan.txt b/erpnext/stock/Print Format/Delivery Note Spartan/Delivery Note Spartan.json similarity index 100% rename from erpnext/stock/Print Format/Delivery Note Spartan/Delivery Note Spartan.txt rename to erpnext/stock/Print Format/Delivery Note Spartan/Delivery Note Spartan.json diff --git a/erpnext/stock/doctype/batch/batch.txt b/erpnext/stock/doctype/batch/batch.json similarity index 100% rename from erpnext/stock/doctype/batch/batch.txt rename to erpnext/stock/doctype/batch/batch.json diff --git a/erpnext/stock/doctype/bin/bin.txt b/erpnext/stock/doctype/bin/bin.json similarity index 100% rename from erpnext/stock/doctype/bin/bin.txt rename to erpnext/stock/doctype/bin/bin.json diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.txt b/erpnext/stock/doctype/delivery_note/delivery_note.json similarity index 100% rename from erpnext/stock/doctype/delivery_note/delivery_note.txt rename to erpnext/stock/doctype/delivery_note/delivery_note.json diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index 6207d6cd2ed..c0302446e60 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -6,7 +6,6 @@ import frappe from frappe.utils import cstr, flt, cint -from frappe.model.code import get_obj from frappe import msgprint, _ import frappe.defaults from frappe.model.mapper import get_mapped_doc @@ -150,7 +149,7 @@ class DeliveryNote(SellingController): self.validate_packed_qty() # Check for Approving Authority - get_obj('Authorization Control').validate_approving_authority(self.doctype, self.company, self.grand_total, self) + frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.grand_total, self) # update delivered qty in sales order self.update_prevdoc_status() diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py index 1c2bececddf..1ee4993cece 100644 --- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py @@ -13,7 +13,7 @@ def _insert_purchase_receipt(item_code=None): if not item_code: item_code = pr_test_records[0][1]["item_code"] - pr = frappe.get_doc(copy=pr_test_records[0]) + pr = frappe.copy_doc(pr_test_records[0]) pr.doclist[1].item_code = item_code pr.insert() pr.submit() @@ -25,7 +25,7 @@ class TestDeliveryNote(unittest.TestCase): from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_invoice _insert_purchase_receipt() - dn = frappe.get_doc(copy=test_records[0]).insert() + dn = frappe.copy_doc(test_records[0]).insert() self.assertRaises(frappe.ValidationError, make_sales_invoice, dn.name) @@ -48,7 +48,7 @@ class TestDeliveryNote(unittest.TestCase): _insert_purchase_receipt() - dn = frappe.get_doc(copy=test_records[0]) + dn = frappe.copy_doc(test_records[0]) dn.insert() dn.submit() @@ -68,7 +68,7 @@ class TestDeliveryNote(unittest.TestCase): _insert_purchase_receipt() - dn = frappe.get_doc(copy=test_records[0]) + dn = frappe.copy_doc(test_records[0]) dn.doclist[1].expense_account = "Cost of Goods Sold - _TC" dn.doclist[1].cost_center = "Main - _TC" @@ -95,7 +95,7 @@ class TestDeliveryNote(unittest.TestCase): self.assertEquals(bal, prev_bal - 375.0) # back dated purchase receipt - pr = frappe.get_doc(copy=pr_test_records[0]) + pr = frappe.copy_doc(pr_test_records[0]) pr.posting_date = "2013-01-01" pr.doclist[1].rate = 100 pr.doclist[1].base_amount = 100 @@ -123,7 +123,7 @@ class TestDeliveryNote(unittest.TestCase): _insert_purchase_receipt() _insert_purchase_receipt("_Test Item Home Desktop 100") - dn = frappe.get_doc(copy=test_records[0]) + dn = frappe.copy_doc(test_records[0]) dn.doclist[1].item_code = "_Test Sales BOM Item" dn.doclist[1].qty = 1 @@ -162,7 +162,7 @@ class TestDeliveryNote(unittest.TestCase): se = make_serialized_item() serial_nos = get_serial_nos(se.doclist[1].serial_no) - dn = frappe.get_doc(copy=test_records[0]) + dn = frappe.copy_doc(test_records[0]) dn.doclist[1].item_code = "_Test Serialized Item With Series" dn.doclist[1].qty = 1 dn.doclist[1].serial_no = serial_nos[0] @@ -199,7 +199,7 @@ class TestDeliveryNote(unittest.TestCase): sr.status = "Not Available" sr.save() - dn = frappe.get_doc(copy=test_records[0]) + dn = frappe.copy_doc(test_records[0]) dn.doclist[1].item_code = "_Test Serialized Item With Series" dn.doclist[1].qty = 1 dn.doclist[1].serial_no = serial_nos[0] @@ -214,43 +214,4 @@ class TestDeliveryNote(unittest.TestCase): test_dependencies = ["Sales BOM"] -test_records = [ - [ - { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "doctype": "Delivery Note", - "fiscal_year": "_Test Fiscal Year 2013", - "plc_conversion_rate": 1.0, - "posting_date": "2013-02-21", - "posting_time": "9:00:00", - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", - "status": "Draft", - "territory": "_Test Territory", - "net_total": 500.0, - "grand_total": 500.0, - "grand_total_export": 500.0, - "naming_series": "_T-Delivery Note-" - }, - { - "description": "CPU", - "doctype": "Delivery Note Item", - "item_code": "_Test Item", - "item_name": "_Test Item", - "parentfield": "delivery_note_details", - "qty": 5.0, - "base_rate": 100.0, - "rate": 100.0, - "base_amount": 500.0, - "warehouse": "_Test Warehouse - _TC", - "stock_uom": "_Test UOM", - "expense_account": "Cost of Goods Sold - _TC", - "cost_center": "Main - _TC" - } - ] - -] +test_records = frappe.get_test_records('Delivery Note') \ No newline at end of file diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.txt b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json similarity index 100% rename from erpnext/stock/doctype/delivery_note_item/delivery_note_item.txt rename to erpnext/stock/doctype/delivery_note_item/delivery_note_item.json diff --git a/erpnext/stock/doctype/item/item.txt b/erpnext/stock/doctype/item/item.json similarity index 100% rename from erpnext/stock/doctype/item/item.txt rename to erpnext/stock/doctype/item/item.json diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py index 0ad6be22682..506e5d016c3 100644 --- a/erpnext/stock/doctype/item/test_item.py +++ b/erpnext/stock/doctype/item/test_item.py @@ -13,7 +13,7 @@ test_dependencies = ["Warehouse"] class TestItem(unittest.TestCase): def test_default_warehouse(self): from erpnext.stock.doctype.item.item import WarehouseNotSet - item = frappe.get_doc(copy=test_records[0]) + item = frappe.copy_doc(test_records[0]) item.is_stock_item = "Yes" item.default_warehouse = None self.assertRaises(WarehouseNotSet, item.insert) @@ -60,246 +60,4 @@ class TestItem(unittest.TestCase): for key, value in to_check.iteritems(): self.assertEquals(value, details.get(key)) -test_records = [ - [{ - "doctype": "Item", - "item_code": "_Test Item", - "item_name": "_Test Item", - "description": "_Test Item", - "item_group": "_Test Item Group", - "is_stock_item": "Yes", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "Yes", - "is_sub_contracted_item": "No", - "stock_uom": "_Test UOM", - "income_account": "Sales - _TC", - "default_warehouse": "_Test Warehouse - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "selling_cost_center": "_Test Cost Center - _TC", - }, { - "doctype": "Item Reorder", - "parentfield": "item_reorder", - "warehouse": "_Test Warehouse - _TC", - "warehouse_reorder_level": 20, - "warehouse_reorder_qty": 20, - "material_request_type": "Purchase" - }, - ], - [{ - "doctype": "Item", - "item_code": "_Test Item 2", - "item_name": "_Test Item 2", - "description": "_Test Item 2", - "item_group": "_Test Item Group", - "is_stock_item": "Yes", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "Yes", - "is_sub_contracted_item": "No", - "stock_uom": "_Test UOM", - "income_account": "Sales - _TC", - "default_warehouse": "_Test Warehouse - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC" - }], - [{ - "doctype": "Item", - "item_code": "_Test Item Home Desktop 100", - "item_name": "_Test Item Home Desktop 100", - "description": "_Test Item Home Desktop 100", - "item_group": "_Test Item Group Desktops", - "default_warehouse": "_Test Warehouse - _TC", - "income_account": "Sales - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "is_stock_item": "Yes", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "No", - "is_sub_contracted_item": "No", - "is_manufactured_item": "No", - "stock_uom": "_Test UOM" - }, - { - "doctype": "Item Tax", - "tax_type": "_Test Account Excise Duty - _TC", - "tax_rate": 10 - }], - [{ - "doctype": "Item", - "item_code": "_Test Item Home Desktop 200", - "item_name": "_Test Item Home Desktop 200", - "description": "_Test Item Home Desktop 200", - "item_group": "_Test Item Group Desktops", - "default_warehouse": "_Test Warehouse - _TC", - "income_account": "Sales - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "is_stock_item": "Yes", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "No", - "is_sub_contracted_item": "No", - "is_manufactured_item": "No", - "stock_uom": "_Test UOM" - }], - [{ - "doctype": "Item", - "item_code": "_Test Sales BOM Item", - "item_name": "_Test Sales BOM Item", - "description": "_Test Sales BOM Item", - "item_group": "_Test Item Group Desktops", - "income_account": "Sales - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "is_stock_item": "No", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "No", - "is_sub_contracted_item": "No", - "stock_uom": "_Test UOM" - }], - [{ - "doctype": "Item", - "item_code": "_Test FG Item", - "item_name": "_Test FG Item", - "description": "_Test FG Item", - "item_group": "_Test Item Group Desktops", - "is_stock_item": "Yes", - "default_warehouse": "_Test Warehouse - _TC", - "income_account": "Sales - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "Yes", - "is_sub_contracted_item": "Yes", - "stock_uom": "_Test UOM" - }], - [{ - "doctype": "Item", - "item_code": "_Test Non Stock Item", - "item_name": "_Test Non Stock Item", - "description": "_Test Non Stock Item", - "item_group": "_Test Item Group Desktops", - "is_stock_item": "No", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "No", - "is_sub_contracted_item": "No", - "stock_uom": "_Test UOM" - }], - [{ - "doctype": "Item", - "item_code": "_Test Serialized Item", - "item_name": "_Test Serialized Item", - "description": "_Test Serialized Item", - "item_group": "_Test Item Group Desktops", - "is_stock_item": "Yes", - "default_warehouse": "_Test Warehouse - _TC", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "Yes", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "No", - "is_sub_contracted_item": "No", - "stock_uom": "_Test UOM" - }], - [{ - "doctype": "Item", - "item_code": "_Test Serialized Item With Series", - "item_name": "_Test Serialized Item With Series", - "description": "_Test Serialized Item", - "item_group": "_Test Item Group Desktops", - "is_stock_item": "Yes", - "default_warehouse": "_Test Warehouse - _TC", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "Yes", - "serial_no_series": "ABCD.#####", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "Yes", - "is_sub_contracted_item": "No", - "stock_uom": "_Test UOM" - }], - [{ - "doctype": "Item", - "item_code": "_Test Item Home Desktop Manufactured", - "item_name": "_Test Item Home Desktop Manufactured", - "description": "_Test Item Home Desktop Manufactured", - "item_group": "_Test Item Group Desktops", - "default_warehouse": "_Test Warehouse - _TC", - "income_account": "Sales - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "is_stock_item": "Yes", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "Yes", - "is_sub_contracted_item": "No", - "is_manufactured_item": "Yes", - "stock_uom": "_Test UOM" - }], - [{ - "doctype": "Item", - "item_code": "_Test FG Item 2", - "item_name": "_Test FG Item 2", - "description": "_Test FG Item 2", - "item_group": "_Test Item Group Desktops", - "is_stock_item": "Yes", - "default_warehouse": "_Test Warehouse - _TC", - "income_account": "Sales - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "Yes", - "is_sub_contracted_item": "Yes", - "stock_uom": "_Test UOM" - }], -] \ No newline at end of file +test_records = frappe.get_test_records('Item') \ No newline at end of file diff --git a/erpnext/stock/doctype/item_customer_detail/item_customer_detail.txt b/erpnext/stock/doctype/item_customer_detail/item_customer_detail.json similarity index 100% rename from erpnext/stock/doctype/item_customer_detail/item_customer_detail.txt rename to erpnext/stock/doctype/item_customer_detail/item_customer_detail.json diff --git a/erpnext/stock/doctype/item_price/item_price.txt b/erpnext/stock/doctype/item_price/item_price.json similarity index 100% rename from erpnext/stock/doctype/item_price/item_price.txt rename to erpnext/stock/doctype/item_price/item_price.json diff --git a/erpnext/stock/doctype/item_price/test_item_price.py b/erpnext/stock/doctype/item_price/test_item_price.py index 310c7d9b46f..a1a10bae553 100644 --- a/erpnext/stock/doctype/item_price/test_item_price.py +++ b/erpnext/stock/doctype/item_price/test_item_price.py @@ -8,16 +8,7 @@ import frappe class TestItem(unittest.TestCase): def test_duplicate_item(self): from erpnext.stock.doctype.item_price.item_price import ItemPriceDuplicateItem - bean = frappe.get_doc(copy=test_records[0]) + bean = frappe.copy_doc(test_records[0]) self.assertRaises(ItemPriceDuplicateItem, bean.insert) -test_records = [ - [ - { - "doctype": "Item Price", - "price_list": "_Test Price List", - "item_code": "_Test Item", - "price_list_rate": 100 - } - ] -] \ No newline at end of file +test_records = frappe.get_test_records('Item Price') \ No newline at end of file diff --git a/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.txt b/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.json similarity index 100% rename from erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.txt rename to erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.json diff --git a/erpnext/stock/doctype/item_reorder/item_reorder.txt b/erpnext/stock/doctype/item_reorder/item_reorder.json similarity index 100% rename from erpnext/stock/doctype/item_reorder/item_reorder.txt rename to erpnext/stock/doctype/item_reorder/item_reorder.json diff --git a/erpnext/stock/doctype/item_supplier/item_supplier.txt b/erpnext/stock/doctype/item_supplier/item_supplier.json similarity index 100% rename from erpnext/stock/doctype/item_supplier/item_supplier.txt rename to erpnext/stock/doctype/item_supplier/item_supplier.json diff --git a/erpnext/stock/doctype/item_tax/item_tax.txt b/erpnext/stock/doctype/item_tax/item_tax.json similarity index 100% rename from erpnext/stock/doctype/item_tax/item_tax.txt rename to erpnext/stock/doctype/item_tax/item_tax.json diff --git a/erpnext/stock/doctype/item_website_specification/item_website_specification.txt b/erpnext/stock/doctype/item_website_specification/item_website_specification.json similarity index 100% rename from erpnext/stock/doctype/item_website_specification/item_website_specification.txt rename to erpnext/stock/doctype/item_website_specification/item_website_specification.json diff --git a/erpnext/stock/doctype/landed_cost_item/landed_cost_item.txt b/erpnext/stock/doctype/landed_cost_item/landed_cost_item.json similarity index 100% rename from erpnext/stock/doctype/landed_cost_item/landed_cost_item.txt rename to erpnext/stock/doctype/landed_cost_item/landed_cost_item.json diff --git a/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.txt b/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.json similarity index 100% rename from erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.txt rename to erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.json diff --git a/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.txt b/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.json similarity index 100% rename from erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.txt rename to erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.json diff --git a/erpnext/stock/doctype/material_request/material_request.txt b/erpnext/stock/doctype/material_request/material_request.json similarity index 100% rename from erpnext/stock/doctype/material_request/material_request.txt rename to erpnext/stock/doctype/material_request/material_request.json diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py index c8f38ed5d22..42c6f23ae2c 100644 --- a/erpnext/stock/doctype/material_request/material_request.py +++ b/erpnext/stock/doctype/material_request/material_request.py @@ -9,7 +9,6 @@ import frappe from frappe.utils import cstr, flt from frappe.model.utils import getlist -from frappe.model.code import get_obj from frappe import msgprint, _ from erpnext.controllers.buying_controller import BuyingController @@ -70,7 +69,7 @@ class MaterialRequest(BuyingController): self.validate_value("material_request_type", "in", ["Purchase", "Transfer"]) - pc_obj = get_obj(dt='Purchase Common') + pc_obj = frappe.get_doc(dt='Purchase Common') pc_obj.validate_for_items(self) # self.validate_qty_against_so() @@ -126,7 +125,7 @@ class MaterialRequest(BuyingController): def on_cancel(self): # Step 1:=> Get Purchase Common Obj - pc_obj = get_obj(dt='Purchase Common') + pc_obj = frappe.get_doc(dt='Purchase Common') # Step 2:=> Check for stopped status pc_obj.check_for_stopped_status(self.doctype, self.name) @@ -176,7 +175,7 @@ def update_completed_qty(bean, method): material_request_map.setdefault(d.material_request, []).append(d.material_request_item) 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_doc("Material Request", mr_name) mr_doctype = frappe.get_meta("Material Request") if mr_obj.status in ["Stopped", "Cancelled"]: diff --git a/erpnext/stock/doctype/material_request/test_material_request.py b/erpnext/stock/doctype/material_request/test_material_request.py index 66c4dd2c0aa..ecdc9c0efd0 100644 --- a/erpnext/stock/doctype/material_request/test_material_request.py +++ b/erpnext/stock/doctype/material_request/test_material_request.py @@ -15,7 +15,7 @@ class TestMaterialRequest(unittest.TestCase): def test_make_purchase_order(self): from erpnext.stock.doctype.material_request.material_request import make_purchase_order - mr = frappe.get_doc(copy=test_records[0]).insert() + mr = frappe.copy_doc(test_records[0]).insert() self.assertRaises(frappe.ValidationError, make_purchase_order, mr.name) @@ -30,7 +30,7 @@ class TestMaterialRequest(unittest.TestCase): def test_make_supplier_quotation(self): from erpnext.stock.doctype.material_request.material_request import make_supplier_quotation - mr = frappe.get_doc(copy=test_records[0]).insert() + mr = frappe.copy_doc(test_records[0]).insert() self.assertRaises(frappe.ValidationError, make_supplier_quotation, mr.name) @@ -46,7 +46,7 @@ class TestMaterialRequest(unittest.TestCase): def test_make_stock_entry(self): from erpnext.stock.doctype.material_request.material_request import make_stock_entry - mr = frappe.get_doc(copy=test_records[0]).insert() + mr = frappe.copy_doc(test_records[0]).insert() self.assertRaises(frappe.ValidationError, make_stock_entry, mr.name) @@ -112,7 +112,7 @@ class TestMaterialRequest(unittest.TestCase): frappe.db.sql("""delete from `tabBin`""") # submit material request of type Purchase - mr = frappe.get_doc(copy=test_records[0]) + mr = frappe.copy_doc(test_records[0]) mr.insert() mr.submit() @@ -133,14 +133,14 @@ class TestMaterialRequest(unittest.TestCase): # check for stopped status of Material Request - po = frappe.get_doc(copy=po_doclist) + po = frappe.copy_doc(po_doclist) po.insert() mr.obj.update_status('Stopped') self.assertRaises(frappe.ValidationError, po.submit) self.assertRaises(frappe.ValidationError, po.cancel) mr.obj.update_status('Submitted') - po = frappe.get_doc(copy=po_doclist) + po = frappe.copy_doc(po_doclist) po.insert() po.submit() @@ -160,7 +160,7 @@ class TestMaterialRequest(unittest.TestCase): frappe.db.sql("""delete from `tabStock Ledger Entry`""") # submit material request of type Purchase - mr = frappe.get_doc(copy=test_records[0]) + mr = frappe.copy_doc(test_records[0]) mr.material_request_type = "Transfer" mr.insert() mr.submit() @@ -196,14 +196,14 @@ class TestMaterialRequest(unittest.TestCase): self._insert_stock_entry(27.0, 1.5) # check for stopped status of Material Request - se = frappe.get_doc(copy=se_doclist) + se = frappe.copy_doc(se_doclist) se.insert() mr.obj.update_status('Stopped') self.assertRaises(frappe.ValidationError, se.submit) self.assertRaises(frappe.ValidationError, se.cancel) mr.obj.update_status('Submitted') - se = frappe.get_doc(copy=se_doclist) + se = frappe.copy_doc(se_doclist) se.insert() se.submit() @@ -223,7 +223,7 @@ class TestMaterialRequest(unittest.TestCase): frappe.db.sql("""delete from `tabStock Ledger Entry`""") # submit material request of type Purchase - mr = frappe.get_doc(copy=test_records[0]) + mr = frappe.copy_doc(test_records[0]) mr.material_request_type = "Transfer" mr.insert() mr.submit() @@ -259,14 +259,14 @@ class TestMaterialRequest(unittest.TestCase): self._insert_stock_entry(60.0, 3.0) # check for stopped status of Material Request - se = frappe.get_doc(copy=se_doclist) + se = frappe.copy_doc(se_doclist) se.insert() mr.obj.update_status('Stopped') self.assertRaises(frappe.ValidationError, se.submit) self.assertRaises(frappe.ValidationError, se.cancel) mr.obj.update_status('Submitted') - se = frappe.get_doc(copy=se_doclist) + se = frappe.copy_doc(se_doclist) se.insert() se.submit() @@ -283,7 +283,7 @@ class TestMaterialRequest(unittest.TestCase): def test_incorrect_mapping_of_stock_entry(self): # submit material request of type Purchase - mr = frappe.get_doc(copy=test_records[0]) + mr = frappe.copy_doc(test_records[0]) mr.material_request_type = "Transfer" mr.insert() mr.submit() @@ -312,47 +312,14 @@ class TestMaterialRequest(unittest.TestCase): }) # check for stopped status of Material Request - se = frappe.get_doc(copy=se_doclist) + se = frappe.copy_doc(se_doclist) self.assertRaises(frappe.MappingMismatchError, se.insert) def test_warehouse_company_validation(self): from erpnext.stock.utils import InvalidWarehouseCompany - mr = frappe.get_doc(copy=test_records[0]) + mr = frappe.copy_doc(test_records[0]) mr.company = "_Test Company 1" self.assertRaises(InvalidWarehouseCompany, mr.insert) test_dependencies = ["Currency Exchange"] -test_records = [ - [ - { - "company": "_Test Company", - "doctype": "Material Request", - "fiscal_year": "_Test Fiscal Year 2013", - "transaction_date": "2013-02-18", - "material_request_type": "Purchase", - "naming_series": "_T-Material Request-" - }, - { - "description": "_Test Item Home Desktop 100", - "doctype": "Material Request Item", - "item_code": "_Test Item Home Desktop 100", - "item_name": "_Test Item Home Desktop 100", - "parentfield": "indent_details", - "qty": 54.0, - "schedule_date": "2013-02-18", - "uom": "_Test UOM 1", - "warehouse": "_Test Warehouse - _TC" - }, - { - "description": "_Test Item Home Desktop 200", - "doctype": "Material Request Item", - "item_code": "_Test Item Home Desktop 200", - "item_name": "_Test Item Home Desktop 200", - "parentfield": "indent_details", - "qty": 3.0, - "schedule_date": "2013-02-19", - "uom": "_Test UOM 1", - "warehouse": "_Test Warehouse - _TC" - } - ], -] \ No newline at end of file +test_records = frappe.get_test_records('Material Request') \ No newline at end of file diff --git a/erpnext/stock/doctype/material_request_item/material_request_item.txt b/erpnext/stock/doctype/material_request_item/material_request_item.json similarity index 100% rename from erpnext/stock/doctype/material_request_item/material_request_item.txt rename to erpnext/stock/doctype/material_request_item/material_request_item.json diff --git a/erpnext/stock/doctype/packed_item/packed_item.txt b/erpnext/stock/doctype/packed_item/packed_item.json similarity index 100% rename from erpnext/stock/doctype/packed_item/packed_item.txt rename to erpnext/stock/doctype/packed_item/packed_item.json diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.txt b/erpnext/stock/doctype/packing_slip/packing_slip.json similarity index 100% rename from erpnext/stock/doctype/packing_slip/packing_slip.txt rename to erpnext/stock/doctype/packing_slip/packing_slip.json diff --git a/erpnext/stock/doctype/packing_slip_item/packing_slip_item.txt b/erpnext/stock/doctype/packing_slip_item/packing_slip_item.json similarity index 100% rename from erpnext/stock/doctype/packing_slip_item/packing_slip_item.txt rename to erpnext/stock/doctype/packing_slip_item/packing_slip_item.json diff --git a/erpnext/stock/doctype/price_list/price_list.txt b/erpnext/stock/doctype/price_list/price_list.json similarity index 100% rename from erpnext/stock/doctype/price_list/price_list.txt rename to erpnext/stock/doctype/price_list/price_list.json diff --git a/erpnext/stock/doctype/price_list/test_price_list.py b/erpnext/stock/doctype/price_list/test_price_list.py index 8ec53cbfc76..ca7f47d5799 100644 --- a/erpnext/stock/doctype/price_list/test_price_list.py +++ b/erpnext/stock/doctype/price_list/test_price_list.py @@ -6,70 +6,4 @@ import frappe # test_ignore = ["Item"] -test_records = [ - [ - { - "doctype": "Price List", - "price_list_name": "_Test Price List", - "enabled": 1, - "currency": "INR", - "selling": 1, - "buying": 1 - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "All Territories" - }, - ], - [ - { - "doctype": "Price List", - "price_list_name": "_Test Price List 2", - "enabled": 1, - "currency": "INR", - "selling": 1, - "buying": 1 - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory Rest Of The World" - } - ], - [ - { - "doctype": "Price List", - "price_list_name": "_Test Price List India", - "enabled": 1, - "currency": "INR", - "selling": 1, - "buying": 1 - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory India" - } - ], - [ - { - "doctype": "Price List", - "price_list_name": "_Test Price List Rest of the World", - "enabled": 1, - "currency": "USD", - "selling": 1, - "buying": 1 - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory Rest Of The World" - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory United States" - } - ], -] \ No newline at end of file +test_records = frappe.get_test_records('Price List') \ No newline at end of file diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.txt b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json similarity index 100% rename from erpnext/stock/doctype/purchase_receipt/purchase_receipt.txt rename to erpnext/stock/doctype/purchase_receipt/purchase_receipt.json diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index a00a07a1419..950db93a56a 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -6,7 +6,6 @@ import frappe from frappe.utils import cstr, flt, cint -from frappe.model.code import get_obj from frappe import msgprint, _ import frappe.defaults from erpnext.stock.utils import update_bin @@ -54,7 +53,7 @@ class PurchaseReceipt(BuyingController): self.validate_uom_is_integer("stock_uom", "stock_qty") self.validate_challan_no() - pc_obj = get_obj(dt='Purchase Common') + pc_obj = frappe.get_doc(dt='Purchase Common') pc_obj.validate_for_items(self) self.check_for_stopped_status(pc_obj) @@ -223,10 +222,10 @@ class PurchaseReceipt(BuyingController): # on submit def on_submit(self): - purchase_controller = frappe.get_obj("Purchase Common") + purchase_controller = frappe.get_doc("Purchase Common") # Check for Approving Authority - get_obj('Authorization Control').validate_approving_authority(self.doctype, self.company, self.grand_total) + frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.grand_total) # Set status as Submitted frappe.db.set(self, 'status', 'Submitted') @@ -255,7 +254,7 @@ class PurchaseReceipt(BuyingController): def on_cancel(self): - pc_obj = get_obj('Purchase Common') + pc_obj = frappe.get_doc('Purchase Common') self.check_for_stopped_status(pc_obj) # Check if Purchase Invoice has been submitted against current Purchase Order @@ -285,7 +284,7 @@ class PurchaseReceipt(BuyingController): d.current_stock = bin and flt(bin[0]['actual_qty']) or 0 def get_rate(self,arg): - return get_obj('Purchase Common').get_rate(arg,self) + return frappe.get_doc('Purchase Common').get_rate(arg,self) def get_gl_entries(self, warehouse_account=None): against_stock_account = self.get_company_default("stock_received_but_not_billed") diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index 0b22425951e..4c2b3a001cd 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -14,7 +14,7 @@ class TestPurchaseReceipt(unittest.TestCase): set_perpetual_inventory(0) from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice - pr = frappe.get_doc(copy=test_records[0]).insert() + pr = frappe.copy_doc(test_records[0]).insert() self.assertRaises(frappe.ValidationError, make_purchase_invoice, pr.name) @@ -33,7 +33,7 @@ class TestPurchaseReceipt(unittest.TestCase): def test_purchase_receipt_no_gl_entry(self): self._clear_stock_account_balance() set_perpetual_inventory(0) - pr = frappe.get_doc(copy=test_records[0]) + pr = frappe.copy_doc(test_records[0]) pr.insert() pr.submit() @@ -56,7 +56,7 @@ class TestPurchaseReceipt(unittest.TestCase): set_perpetual_inventory() self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1) - pr = frappe.get_doc(copy=test_records[0]) + pr = frappe.copy_doc(test_records[0]) pr.insert() pr.submit() @@ -90,7 +90,7 @@ class TestPurchaseReceipt(unittest.TestCase): frappe.db.sql("""delete from `tabGL Entry`""") def test_subcontracting(self): - pr = frappe.get_doc(copy=test_records[1]) + pr = frappe.copy_doc(test_records[1]) pr.run_method("calculate_taxes_and_totals") pr.insert() @@ -98,7 +98,7 @@ class TestPurchaseReceipt(unittest.TestCase): self.assertEquals(len(pr.get("pr_raw_material_details")), 2) def test_serial_no_supplier(self): - pr = frappe.get_doc(copy=test_records[0]) + pr = frappe.copy_doc(test_records[0]) pr.doclist[1].item_code = "_Test Serialized Item With Series" pr.doclist[1].qty = 1 pr.doclist[1].received_qty = 1 @@ -130,119 +130,4 @@ def set_perpetual_inventory(enable=1): test_dependencies = ["BOM"] -test_records = [ - [ - { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "doctype": "Purchase Receipt", - "fiscal_year": "_Test Fiscal Year 2013", - "posting_date": "2013-02-12", - "posting_time": "15:33:30", - "supplier": "_Test Supplier", - "net_total": 500.0, - "grand_total": 720.0, - "naming_series": "_T-Purchase Receipt-", - "buying_price_list": "_Test Price List" - }, - { - "conversion_factor": 1.0, - "description": "_Test Item", - "doctype": "Purchase Receipt Item", - "item_code": "_Test Item", - "item_name": "_Test Item", - "parentfield": "purchase_receipt_details", - "received_qty": 5.0, - "qty": 5.0, - "rejected_qty": 0.0, - "rate": 50.0, - "base_amount": 250.0, - "warehouse": "_Test Warehouse - _TC", - "stock_uom": "Nos", - "uom": "_Test UOM", - }, - { - "conversion_factor": 1.0, - "description": "_Test Item", - "doctype": "Purchase Receipt Item", - "item_code": "_Test Item", - "item_name": "_Test Item", - "parentfield": "purchase_receipt_details", - "received_qty": 5.0, - "qty": 5.0, - "rejected_qty": 0.0, - "rate": 50.0, - "base_amount": 250.0, - "warehouse": "_Test Warehouse 1 - _TC", - "stock_uom": "Nos", - "uom": "_Test UOM", - }, - { - "account_head": "_Test Account Shipping Charges - _TC", - "add_deduct_tax": "Add", - "category": "Valuation and Total", - "charge_type": "Actual", - "description": "Shipping Charges", - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "rate": 100.0, - "tax_amount": 100.0, - }, - { - "account_head": "_Test Account VAT - _TC", - "add_deduct_tax": "Add", - "category": "Total", - "charge_type": "Actual", - "description": "VAT", - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "rate": 120.0, - "tax_amount": 120.0, - }, - { - "account_head": "_Test Account Customs Duty - _TC", - "add_deduct_tax": "Add", - "category": "Valuation", - "charge_type": "Actual", - "description": "Customs Duty", - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "rate": 150.0, - "tax_amount": 150.0, - }, - ], - [ - { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "doctype": "Purchase Receipt", - "fiscal_year": "_Test Fiscal Year 2013", - "posting_date": "2013-02-12", - "posting_time": "15:33:30", - "is_subcontracted": "Yes", - "supplier_warehouse": "_Test Warehouse - _TC", - "supplier": "_Test Supplier", - "net_total": 5000.0, - "grand_total": 5000.0, - "buying_price_list": "_Test Price List" - }, - { - "conversion_factor": 1.0, - "description": "_Test FG Item", - "doctype": "Purchase Receipt Item", - "item_code": "_Test FG Item", - "item_name": "_Test FG Item", - "parentfield": "purchase_receipt_details", - "received_qty": 10.0, - "qty": 10.0, - "rejected_qty": 0.0, - "rate": 500.0, - "base_amount": 5000.0, - "warehouse": "_Test Warehouse - _TC", - "stock_uom": "Nos", - "uom": "_Test UOM", - } - ], -] \ No newline at end of file +test_records = frappe.get_test_records('Purchase Receipt') \ No newline at end of file diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json similarity index 100% rename from erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt rename to erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json diff --git a/erpnext/stock/doctype/serial_no/serial_no.txt b/erpnext/stock/doctype/serial_no/serial_no.json similarity index 100% rename from erpnext/stock/doctype/serial_no/serial_no.txt rename to erpnext/stock/doctype/serial_no/serial_no.json diff --git a/erpnext/stock/doctype/serial_no/test_serial_no.py b/erpnext/stock/doctype/serial_no/test_serial_no.py index dc9c155bd9f..30368b63935 100644 --- a/erpnext/stock/doctype/serial_no/test_serial_no.py +++ b/erpnext/stock/doctype/serial_no/test_serial_no.py @@ -8,7 +8,7 @@ from __future__ import unicode_literals import frappe, unittest test_dependencies = ["Item"] -test_records = [] +test_records = frappe.get_test_records('Serial No') from erpnext.stock.doctype.serial_no.serial_no import * diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.txt b/erpnext/stock/doctype/stock_entry/stock_entry.json similarity index 100% rename from erpnext/stock/doctype/stock_entry/stock_entry.txt rename to erpnext/stock/doctype/stock_entry/stock_entry.json diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index a21c9fc81e2..6191811a9c1 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -7,7 +7,6 @@ import frappe.defaults from frappe.utils import cstr, cint, flt, comma_or, nowdate -from frappe.model.code import get_obj from frappe import msgprint, _ from erpnext.stock.utils import get_incoming_rate from erpnext.stock.stock_ledger import get_previous_sle @@ -30,7 +29,7 @@ class StockEntry(StockController): self.validate_posting_time() self.validate_purpose() pro_obj = self.production_order and \ - get_obj('Production Order', self.production_order) or None + frappe.get_doc('Production Order', self.production_order) or None self.validate_item() self.validate_uom_is_integer("uom", "qty") @@ -139,7 +138,7 @@ class StockEntry(StockController): def validate_production_order(self, pro_obj=None): if not pro_obj: if self.production_order: - pro_obj = get_obj('Production Order', self.production_order) + pro_obj = frappe.get_doc('Production Order', self.production_order) else: return @@ -432,7 +431,7 @@ class StockEntry(StockController): pro_obj = None if self.production_order: # common validations - pro_obj = get_obj('Production Order', self.production_order) + pro_obj = frappe.get_doc('Production Order', self.production_order) if pro_obj: self.validate_production_order(pro_obj) self.bom_no = pro_obj.bom_no diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index db816fd320b..98e1b00811e 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -22,11 +22,11 @@ class TestStockEntry(unittest.TestCase): frappe.db.set_value("Stock Settings", None, "auto_indent", True) - st1 = frappe.get_doc(copy=test_records[0]) + st1 = frappe.copy_doc(test_records[0]) st1.insert() st1.submit() - st2 = frappe.get_doc(copy=test_records[1]) + st2 = frappe.copy_doc(test_records[1]) st2.insert() st2.submit() @@ -45,7 +45,7 @@ class TestStockEntry(unittest.TestCase): self._clear_stock_account_balance() set_perpetual_inventory() - mr = frappe.get_doc(copy=test_records[0]) + mr = frappe.copy_doc(test_records[0]) mr.insert() mr.submit() @@ -77,7 +77,7 @@ class TestStockEntry(unittest.TestCase): self._insert_material_receipt() - mi = frappe.get_doc(copy=test_records[1]) + mi = frappe.copy_doc(test_records[1]) mi.insert() mi.submit() @@ -113,7 +113,7 @@ class TestStockEntry(unittest.TestCase): self._insert_material_receipt() - mtn = frappe.get_doc(copy=test_records[2]) + mtn = frappe.copy_doc(test_records[2]) mtn.insert() mtn.submit() @@ -149,7 +149,7 @@ class TestStockEntry(unittest.TestCase): self._insert_material_receipt() - repack = frappe.get_doc(copy=test_records[3]) + repack = frappe.copy_doc(test_records[3]) repack.insert() repack.submit() @@ -170,7 +170,7 @@ class TestStockEntry(unittest.TestCase): self._insert_material_receipt() - repack = frappe.get_doc(copy=test_records[3]) + repack = frappe.copy_doc(test_records[3]) repack.doclist[2].incoming_rate = 6000 repack.insert() repack.submit() @@ -218,11 +218,11 @@ class TestStockEntry(unittest.TestCase): def _insert_material_receipt(self): self._clear_stock_account_balance() - se1 = frappe.get_doc(copy=test_records[0]) + se1 = frappe.copy_doc(test_records[0]) se1.insert() se1.submit() - se2 = frappe.get_doc(copy=test_records[0]) + se2 = frappe.copy_doc(test_records[0]) se2.doclist[1].item_code = "_Test Item Home Desktop 100" se2.insert() se2.submit() @@ -240,11 +240,11 @@ class TestStockEntry(unittest.TestCase): import test_records as sales_invoice_test_records # invalid sales invoice as update stock not checked - si = frappe.get_doc(copy=sales_invoice_test_records[1]) + si = frappe.copy_doc(sales_invoice_test_records[1]) si.insert() si.submit() - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.purpose = "Sales Return" se.sales_invoice_no = si.name se.doclist[1].qty = returned_qty @@ -257,7 +257,7 @@ class TestStockEntry(unittest.TestCase): actual_qty_0 = self._get_actual_qty() # insert a pos invoice with update stock - si = frappe.get_doc(copy=sales_invoice_test_records[1]) + si = frappe.copy_doc(sales_invoice_test_records[1]) si.is_pos = si.update_stock = 1 si.doclist[1].warehouse = "_Test Warehouse - _TC" si.doclist[1].item_code = item_code @@ -271,7 +271,7 @@ class TestStockEntry(unittest.TestCase): self.assertEquals(actual_qty_0 - delivered_qty, actual_qty_1) # check if item is validated - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.purpose = "Sales Return" se.sales_invoice_no = si.name se.posting_date = "2013-03-10" @@ -284,7 +284,7 @@ class TestStockEntry(unittest.TestCase): self.assertRaises(frappe.DoesNotExistError, se.insert) # try again - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.purpose = "Sales Return" se.posting_date = "2013-03-10" se.fiscal_year = "_Test Fiscal Year 2013" @@ -321,7 +321,7 @@ class TestStockEntry(unittest.TestCase): actual_qty_0 = self._get_actual_qty() # make a delivery note based on this invoice - dn = frappe.get_doc(copy=delivery_note_test_records[0]) + dn = frappe.copy_doc(delivery_note_test_records[0]) dn.doclist[1].item_code = item_code dn.insert() dn.submit() @@ -342,7 +342,7 @@ class TestStockEntry(unittest.TestCase): si.submit() # insert and submit stock entry for sales return - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.purpose = "Sales Return" se.delivery_note_no = dn.name se.posting_date = "2013-03-10" @@ -410,7 +410,7 @@ class TestStockEntry(unittest.TestCase): actual_qty_0 = self._get_actual_qty() - so = frappe.get_doc(copy=sales_order_test_records[0]) + so = frappe.copy_doc(sales_order_test_records[0]) so.doclist[1].item_code = item_code so.doclist[1].qty = 5.0 so.insert() @@ -440,7 +440,7 @@ class TestStockEntry(unittest.TestCase): si.submit() # insert and submit stock entry for sales return - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.purpose = "Sales Return" se.delivery_note_no = dn.name se.posting_date = "2013-03-10" @@ -466,7 +466,7 @@ class TestStockEntry(unittest.TestCase): from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice # submit purchase receipt - pr = frappe.get_doc(copy=purchase_receipt_test_records[0]) + pr = frappe.copy_doc(purchase_receipt_test_records[0]) pr.insert() pr.submit() @@ -492,7 +492,7 @@ class TestStockEntry(unittest.TestCase): pi.submit() # submit purchase return - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.purpose = "Purchase Return" se.purchase_receipt_no = pr.name se.posting_date = "2013-03-01" @@ -518,7 +518,7 @@ class TestStockEntry(unittest.TestCase): prev_se, pr_docname = self.test_purchase_receipt_return() # submit purchase return - return another 6 qtys so that exception is raised - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.purpose = "Purchase Return" se.purchase_receipt_no = pr_docname se.posting_date = "2013-03-01" @@ -559,7 +559,7 @@ class TestStockEntry(unittest.TestCase): make_purchase_receipt, make_purchase_invoice # submit purchase receipt - po = frappe.get_doc(copy=purchase_order_test_records[0]) + po = frappe.copy_doc(purchase_order_test_records[0]) po.is_subcontracted = None po.doclist[1].item_code = "_Test Item" po.doclist[1].rate = 50 @@ -594,7 +594,7 @@ class TestStockEntry(unittest.TestCase): pi.submit() # submit purchase return - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.purpose = "Purchase Return" se.purchase_receipt_no = pr.name se.posting_date = "2013-03-01" @@ -621,13 +621,13 @@ class TestStockEntry(unittest.TestCase): frappe.db.set_default("company", "_Test Company") def test_serial_no_not_reqd(self): - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.doclist[1].serial_no = "ABCD" se.insert() self.assertRaises(SerialNoNotRequiredError, se.submit) def test_serial_no_reqd(self): - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.doclist[1].item_code = "_Test Serialized Item" se.doclist[1].qty = 2 se.doclist[1].transfer_qty = 2 @@ -635,7 +635,7 @@ class TestStockEntry(unittest.TestCase): self.assertRaises(SerialNoRequiredError, se.submit) def test_serial_no_qty_more(self): - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.doclist[1].item_code = "_Test Serialized Item" se.doclist[1].qty = 2 se.doclist[1].serial_no = "ABCD\nEFGH\nXYZ" @@ -644,7 +644,7 @@ class TestStockEntry(unittest.TestCase): self.assertRaises(SerialNoQtyError, se.submit) def test_serial_no_qty_less(self): - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.doclist[1].item_code = "_Test Serialized Item" se.doclist[1].qty = 2 se.doclist[1].serial_no = "ABCD" @@ -654,7 +654,7 @@ class TestStockEntry(unittest.TestCase): def test_serial_no_transfer_in(self): self._clear_stock_account_balance() - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.doclist[1].item_code = "_Test Serialized Item" se.doclist[1].qty = 2 se.doclist[1].serial_no = "ABCD\nEFGH" @@ -670,7 +670,7 @@ class TestStockEntry(unittest.TestCase): def test_serial_no_not_exists(self): self._clear_stock_account_balance() - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.purpose = "Material Issue" se.doclist[1].item_code = "_Test Serialized Item" se.doclist[1].qty = 2 @@ -685,7 +685,7 @@ class TestStockEntry(unittest.TestCase): self._clear_stock_account_balance() self.test_serial_by_series() - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.doclist[1].item_code = "_Test Serialized Item With Series" se.doclist[1].qty = 1 se.doclist[1].serial_no = "ABCD00001" @@ -708,7 +708,7 @@ class TestStockEntry(unittest.TestCase): self._clear_stock_account_balance() self.test_serial_by_series() - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.purpose = "Material Transfer" se.doclist[1].item_code = "_Test Serialized Item" se.doclist[1].qty = 1 @@ -724,7 +724,7 @@ class TestStockEntry(unittest.TestCase): se = make_serialized_item() serial_no = get_serial_nos(se.doclist[1].serial_no)[0] - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.purpose = "Material Transfer" se.doclist[1].item_code = "_Test Serialized Item With Series" se.doclist[1].qty = 1 @@ -743,7 +743,7 @@ class TestStockEntry(unittest.TestCase): self._clear_stock_account_balance() make_serialized_item() - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.purpose = "Material Transfer" se.doclist[1].item_code = "_Test Serialized Item With Series" se.doclist[1].qty = 1 @@ -770,7 +770,7 @@ class TestStockEntry(unittest.TestCase): frappe.set_user("test2@example.com") from erpnext.stock.utils import InvalidWarehouseCompany - st1 = frappe.get_doc(copy=test_records[0]) + st1 = frappe.copy_doc(test_records[0]) st1.doclist[1].t_warehouse="_Test Warehouse 2 - _TC1" st1.insert() self.assertRaises(InvalidWarehouseCompany, st1.submit) @@ -789,13 +789,13 @@ class TestStockEntry(unittest.TestCase): .add_roles("Sales User", "Sales Manager", "Material User", "Material Manager") frappe.set_user("test@example.com") - st1 = frappe.get_doc(copy=test_records[0]) + st1 = frappe.copy_doc(test_records[0]) st1.company = "_Test Company 1" st1.doclist[1].t_warehouse="_Test Warehouse 2 - _TC1" self.assertRaises(BeanPermissionError, st1.insert) frappe.set_user("test2@example.com") - st1 = frappe.get_doc(copy=test_records[0]) + st1 = frappe.copy_doc(test_records[0]) st1.company = "_Test Company 1" st1.doclist[1].t_warehouse="_Test Warehouse 2 - _TC1" st1.insert() @@ -811,18 +811,18 @@ class TestStockEntry(unittest.TestCase): # test freeze_stocks_upto date_newer_than_test_records = add_days(getdate(test_records[0][0]['posting_date']), 5) frappe.db.set_value("Stock Settings", None, "stock_frozen_upto", date_newer_than_test_records) - se = frappe.get_doc(copy=test_records[0]).insert() + se = frappe.copy_doc(test_records[0]).insert() self.assertRaises (StockFreezeError, se.submit) frappe.db.set_value("Stock Settings", None, "stock_frozen_upto", '') # test freeze_stocks_upto_days frappe.db.set_value("Stock Settings", None, "stock_frozen_upto_days", 7) - se = frappe.get_doc(copy=test_records[0]).insert() + se = frappe.copy_doc(test_records[0]).insert() self.assertRaises (StockFreezeError, se.submit) frappe.db.set_value("Stock Settings", None, "stock_frozen_upto_days", 0) def make_serialized_item(): - se = frappe.get_doc(copy=test_records[0]) + se = frappe.copy_doc(test_records[0]) se.doclist[1].item_code = "_Test Serialized Item With Series" se.doclist[1].qty = 2 se.doclist[1].transfer_qty = 2 @@ -830,116 +830,4 @@ def make_serialized_item(): se.submit() return se -test_records = [ - [ - { - "company": "_Test Company", - "doctype": "Stock Entry", - "posting_date": "2013-01-01", - "posting_time": "17:14:24", - "purpose": "Material Receipt", - "fiscal_year": "_Test Fiscal Year 2013", - }, - { - "conversion_factor": 1.0, - "doctype": "Stock Entry Detail", - "item_code": "_Test Item", - "parentfield": "mtn_details", - "incoming_rate": 100, - "qty": 50.0, - "stock_uom": "_Test UOM", - "transfer_qty": 50.0, - "uom": "_Test UOM", - "t_warehouse": "_Test Warehouse - _TC", - "expense_account": "Stock Adjustment - _TC", - "cost_center": "_Test Cost Center - _TC" - }, - ], - [ - { - "company": "_Test Company", - "doctype": "Stock Entry", - "posting_date": "2013-01-25", - "posting_time": "17:15", - "purpose": "Material Issue", - "fiscal_year": "_Test Fiscal Year 2013", - }, - { - "conversion_factor": 1.0, - "doctype": "Stock Entry Detail", - "item_code": "_Test Item", - "parentfield": "mtn_details", - "incoming_rate": 100, - "qty": 40.0, - "stock_uom": "_Test UOM", - "transfer_qty": 40.0, - "uom": "_Test UOM", - "s_warehouse": "_Test Warehouse - _TC", - "expense_account": "Stock Adjustment - _TC", - "cost_center": "_Test Cost Center - _TC" - }, - ], - [ - { - "company": "_Test Company", - "doctype": "Stock Entry", - "posting_date": "2013-01-25", - "posting_time": "17:14:24", - "purpose": "Material Transfer", - "fiscal_year": "_Test Fiscal Year 2013", - }, - { - "conversion_factor": 1.0, - "doctype": "Stock Entry Detail", - "item_code": "_Test Item", - "parentfield": "mtn_details", - "incoming_rate": 100, - "qty": 45.0, - "stock_uom": "_Test UOM", - "transfer_qty": 45.0, - "uom": "_Test UOM", - "s_warehouse": "_Test Warehouse - _TC", - "t_warehouse": "_Test Warehouse 1 - _TC", - "expense_account": "Stock Adjustment - _TC", - "cost_center": "_Test Cost Center - _TC" - } - ], - [ - { - "company": "_Test Company", - "doctype": "Stock Entry", - "posting_date": "2013-01-25", - "posting_time": "17:14:24", - "purpose": "Manufacture/Repack", - "fiscal_year": "_Test Fiscal Year 2013", - }, - { - "conversion_factor": 1.0, - "doctype": "Stock Entry Detail", - "item_code": "_Test Item", - "parentfield": "mtn_details", - "incoming_rate": 100, - "qty": 50.0, - "stock_uom": "_Test UOM", - "transfer_qty": 50.0, - "uom": "_Test UOM", - "s_warehouse": "_Test Warehouse - _TC", - "expense_account": "Stock Adjustment - _TC", - "cost_center": "_Test Cost Center - _TC" - }, - { - "conversion_factor": 1.0, - "doctype": "Stock Entry Detail", - "item_code": "_Test Item Home Desktop 100", - "parentfield": "mtn_details", - "incoming_rate": 5000, - "qty": 1, - "stock_uom": "_Test UOM", - "transfer_qty": 1, - "uom": "_Test UOM", - "t_warehouse": "_Test Warehouse - _TC", - "expense_account": "Stock Adjustment - _TC", - "cost_center": "_Test Cost Center - _TC" - }, - ], -] +test_records = frappe.get_test_records('Stock Entry') \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.txt b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json similarity index 100% rename from erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.txt rename to erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json diff --git a/erpnext/stock/doctype/stock_ledger/stock_ledger.py b/erpnext/stock/doctype/stock_ledger/stock_ledger.py index e55e51232d6..a20da191236 100644 --- a/erpnext/stock/doctype/stock_ledger/stock_ledger.py +++ b/erpnext/stock/doctype/stock_ledger/stock_ledger.py @@ -6,7 +6,6 @@ import frappe from frappe.utils import add_days, cstr, flt, nowdate, cint, now -from frappe.model.code import get_obj from frappe import session, msgprint from erpnext.stock.utils import get_valid_serial_nos @@ -37,7 +36,7 @@ class StockLedger(Document): "is_amended": is_amended }) - get_obj('Warehouse', v["warehouse"]).update_bin(args) + frappe.get_doc('Warehouse', v["warehouse"]).update_bin(args) def make_entry(self, args): @@ -52,4 +51,4 @@ class StockLedger(Document): Repost everything! """ for wh in frappe.db.sql("select name from tabWarehouse"): - get_obj('Warehouse', wh[0]).repost_stock() + frappe.get_doc('Warehouse', wh[0]).repost_stock() diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json similarity index 100% rename from erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt rename to erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.txt b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json similarity index 100% rename from erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.txt rename to erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json diff --git a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py index 0438d6e7ae8..2f88c5674a5 100644 --- a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py @@ -221,11 +221,11 @@ class TestStockReconciliation(unittest.TestCase): }, ] - pr = frappe.get_doc(copy=stock_entry) + pr = frappe.copy_doc(stock_entry) pr.insert() pr.submit() - pr1 = frappe.get_doc(copy=stock_entry) + pr1 = frappe.copy_doc(stock_entry) pr1.posting_date = "2012-12-15" pr1.posting_time = "02:00" pr1.doclist[1].qty = 10 @@ -234,7 +234,7 @@ class TestStockReconciliation(unittest.TestCase): pr1.insert() pr1.submit() - pr2 = frappe.get_doc(copy=stock_entry) + pr2 = frappe.copy_doc(stock_entry) pr2.posting_date = "2012-12-25" pr2.posting_time = "03:00" pr2.purpose = "Material Issue" @@ -246,7 +246,7 @@ class TestStockReconciliation(unittest.TestCase): pr2.insert() pr2.submit() - pr3 = frappe.get_doc(copy=stock_entry) + pr3 = frappe.copy_doc(stock_entry) pr3.posting_date = "2012-12-31" pr3.posting_time = "08:00" pr3.purpose = "Material Issue" @@ -259,7 +259,7 @@ class TestStockReconciliation(unittest.TestCase): pr3.submit() - pr4 = frappe.get_doc(copy=stock_entry) + pr4 = frappe.copy_doc(stock_entry) pr4.posting_date = "2013-01-05" pr4.fiscal_year = "_Test Fiscal Year 2013" pr4.posting_time = "07:00" diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.txt b/erpnext/stock/doctype/stock_settings/stock_settings.json similarity index 100% rename from erpnext/stock/doctype/stock_settings/stock_settings.txt rename to erpnext/stock/doctype/stock_settings/stock_settings.json diff --git a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.txt b/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.json similarity index 100% rename from erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.txt rename to erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.json diff --git a/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.txt b/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.json similarity index 100% rename from erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.txt rename to erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.json diff --git a/erpnext/stock/doctype/warehouse/test_warehouse.py b/erpnext/stock/doctype/warehouse/test_warehouse.py index b0e7641a288..dea61f8ee06 100644 --- a/erpnext/stock/doctype/warehouse/test_warehouse.py +++ b/erpnext/stock/doctype/warehouse/test_warehouse.py @@ -1,28 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Warehouse", - "warehouse_name": "_Test Warehouse", - "company": "_Test Company", - "create_account_under": "Stock Assets - _TC" - }], - [{ - "doctype": "Warehouse", - "warehouse_name": "_Test Warehouse 1", - "company": "_Test Company", - "create_account_under": "Fixed Assets - _TC" - }], - [{ - "doctype": "Warehouse", - "warehouse_name": "_Test Warehouse 2", - "create_account_under": "Stock Assets - _TC", - "company": "_Test Company 1" - }], - [{ - "doctype": "Warehouse", - "warehouse_name": "_Test Warehouse No Account", - "company": "_Test Company", - }], -] + +import frappe +test_records = frappe.get_test_records('Warehouse') \ No newline at end of file diff --git a/erpnext/stock/doctype/warehouse/warehouse.txt b/erpnext/stock/doctype/warehouse/warehouse.json similarity index 100% rename from erpnext/stock/doctype/warehouse/warehouse.txt rename to erpnext/stock/doctype/warehouse/warehouse.json diff --git a/erpnext/stock/doctype/warehouse_user/warehouse_user.txt b/erpnext/stock/doctype/warehouse_user/warehouse_user.json similarity index 100% rename from erpnext/stock/doctype/warehouse_user/warehouse_user.txt rename to erpnext/stock/doctype/warehouse_user/warehouse_user.json diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index f4588f582ca..57b2c2eda50 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe from frappe import _, throw from frappe.utils import flt, cint, add_days -from frappe.model.meta import has_field import json @frappe.whitelist() @@ -36,7 +35,7 @@ def get_item_details(args): args = frappe._dict(args) if not args.get("transaction_type"): - args.transaction_type = "buying" if has_field(args.get("doctype"), "supplier") \ + args.transaction_type = "buying" if frappe.get_meta(args.get("doctype")).get_field("supplier") \ else "selling" if not args.get("price_list"): diff --git a/erpnext/stock/page/stock_ageing/stock_ageing.txt b/erpnext/stock/page/stock_ageing/stock_ageing.json similarity index 100% rename from erpnext/stock/page/stock_ageing/stock_ageing.txt rename to erpnext/stock/page/stock_ageing/stock_ageing.json diff --git a/erpnext/stock/page/stock_analytics/stock_analytics.txt b/erpnext/stock/page/stock_analytics/stock_analytics.json similarity index 100% rename from erpnext/stock/page/stock_analytics/stock_analytics.txt rename to erpnext/stock/page/stock_analytics/stock_analytics.json diff --git a/erpnext/stock/page/stock_balance/stock_balance.txt b/erpnext/stock/page/stock_balance/stock_balance.json similarity index 100% rename from erpnext/stock/page/stock_balance/stock_balance.txt rename to erpnext/stock/page/stock_balance/stock_balance.json diff --git a/erpnext/stock/page/stock_ledger/stock_ledger.txt b/erpnext/stock/page/stock_ledger/stock_ledger.json similarity index 100% rename from erpnext/stock/page/stock_ledger/stock_ledger.txt rename to erpnext/stock/page/stock_ledger/stock_ledger.json diff --git a/erpnext/stock/page/stock_level/stock_level.txt b/erpnext/stock/page/stock_level/stock_level.json similarity index 100% rename from erpnext/stock/page/stock_level/stock_level.txt rename to erpnext/stock/page/stock_level/stock_level.json diff --git a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.txt b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.json similarity index 100% rename from erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.txt rename to erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.json diff --git a/erpnext/stock/report/delivery_note_trends/delivery_note_trends.txt b/erpnext/stock/report/delivery_note_trends/delivery_note_trends.json similarity index 100% rename from erpnext/stock/report/delivery_note_trends/delivery_note_trends.txt rename to erpnext/stock/report/delivery_note_trends/delivery_note_trends.json diff --git a/erpnext/stock/report/item_prices/item_prices.txt b/erpnext/stock/report/item_prices/item_prices.json similarity index 100% rename from erpnext/stock/report/item_prices/item_prices.txt rename to erpnext/stock/report/item_prices/item_prices.json diff --git a/erpnext/stock/report/item_shortage_report/item_shortage_report.txt b/erpnext/stock/report/item_shortage_report/item_shortage_report.json similarity index 100% rename from erpnext/stock/report/item_shortage_report/item_shortage_report.txt rename to erpnext/stock/report/item_shortage_report/item_shortage_report.json diff --git a/erpnext/stock/report/item_wise_price_list_rate/item_wise_price_list_rate.txt b/erpnext/stock/report/item_wise_price_list_rate/item_wise_price_list_rate.json similarity index 100% rename from erpnext/stock/report/item_wise_price_list_rate/item_wise_price_list_rate.txt rename to erpnext/stock/report/item_wise_price_list_rate/item_wise_price_list_rate.json diff --git a/erpnext/stock/report/items_to_be_requested/items_to_be_requested.txt b/erpnext/stock/report/items_to_be_requested/items_to_be_requested.json similarity index 100% rename from erpnext/stock/report/items_to_be_requested/items_to_be_requested.txt rename to erpnext/stock/report/items_to_be_requested/items_to_be_requested.json diff --git a/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.txt b/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.json similarity index 100% rename from erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.txt rename to erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.json diff --git a/erpnext/stock/report/material_requests_for_which_supplier_quotations_are_not_created/material_requests_for_which_supplier_quotations_are_not_created.txt b/erpnext/stock/report/material_requests_for_which_supplier_quotations_are_not_created/material_requests_for_which_supplier_quotations_are_not_created.json similarity index 100% rename from erpnext/stock/report/material_requests_for_which_supplier_quotations_are_not_created/material_requests_for_which_supplier_quotations_are_not_created.txt rename to erpnext/stock/report/material_requests_for_which_supplier_quotations_are_not_created/material_requests_for_which_supplier_quotations_are_not_created.json diff --git a/erpnext/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.txt b/erpnext/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.json similarity index 100% rename from erpnext/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.txt rename to erpnext/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.json diff --git a/erpnext/stock/report/purchase_in_transit/purchase_in_transit.txt b/erpnext/stock/report/purchase_in_transit/purchase_in_transit.json similarity index 100% rename from erpnext/stock/report/purchase_in_transit/purchase_in_transit.txt rename to erpnext/stock/report/purchase_in_transit/purchase_in_transit.json diff --git a/erpnext/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt b/erpnext/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.json similarity index 100% rename from erpnext/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt rename to erpnext/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.json diff --git a/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.txt b/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.json similarity index 100% rename from erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.txt rename to erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.json diff --git a/erpnext/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.txt b/erpnext/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.json similarity index 100% rename from erpnext/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.txt rename to erpnext/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.json diff --git a/erpnext/stock/report/serial_no_service_contract_expiry/serial_no_service_contract_expiry.txt b/erpnext/stock/report/serial_no_service_contract_expiry/serial_no_service_contract_expiry.json similarity index 100% rename from erpnext/stock/report/serial_no_service_contract_expiry/serial_no_service_contract_expiry.txt rename to erpnext/stock/report/serial_no_service_contract_expiry/serial_no_service_contract_expiry.json diff --git a/erpnext/stock/report/serial_no_status/serial_no_status.txt b/erpnext/stock/report/serial_no_status/serial_no_status.json similarity index 100% rename from erpnext/stock/report/serial_no_status/serial_no_status.txt rename to erpnext/stock/report/serial_no_status/serial_no_status.json diff --git a/erpnext/stock/report/serial_no_warranty_expiry/serial_no_warranty_expiry.txt b/erpnext/stock/report/serial_no_warranty_expiry/serial_no_warranty_expiry.json similarity index 100% rename from erpnext/stock/report/serial_no_warranty_expiry/serial_no_warranty_expiry.txt rename to erpnext/stock/report/serial_no_warranty_expiry/serial_no_warranty_expiry.json diff --git a/erpnext/stock/report/stock_ageing/stock_ageing.txt b/erpnext/stock/report/stock_ageing/stock_ageing.json similarity index 100% rename from erpnext/stock/report/stock_ageing/stock_ageing.txt rename to erpnext/stock/report/stock_ageing/stock_ageing.json diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.txt b/erpnext/stock/report/stock_ledger/stock_ledger.json similarity index 100% rename from erpnext/stock/report/stock_ledger/stock_ledger.txt rename to erpnext/stock/report/stock_ledger/stock_ledger.json diff --git a/erpnext/stock/report/stock_projected_qty/stock_projected_qty.txt b/erpnext/stock/report/stock_projected_qty/stock_projected_qty.json similarity index 100% rename from erpnext/stock/report/stock_projected_qty/stock_projected_qty.txt rename to erpnext/stock/report/stock_projected_qty/stock_projected_qty.json diff --git a/erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.txt b/erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.json similarity index 100% rename from erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.txt rename to erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.json diff --git a/erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.txt b/erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.json similarity index 100% rename from erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.txt rename to erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.json diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py index 2f28e1a0c81..69d27ba2776 100644 --- a/erpnext/stock/utils.py +++ b/erpnext/stock/utils.py @@ -49,8 +49,7 @@ def get_bin(item_code, warehouse): bin_wrapper.insert() bin_obj = bin_wrapper.make_controller() else: - from frappe.model.code import get_obj - bin_obj = get_obj('Bin', bin) + bin_obj = frappe.get_doc('Bin', bin) return bin_obj def update_bin(args): diff --git a/erpnext/support/doctype/customer_issue/customer_issue.txt b/erpnext/support/doctype/customer_issue/customer_issue.json similarity index 100% rename from erpnext/support/doctype/customer_issue/customer_issue.txt rename to erpnext/support/doctype/customer_issue/customer_issue.json diff --git a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.txt b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.json similarity index 100% rename from erpnext/support/doctype/maintenance_schedule/maintenance_schedule.txt rename to erpnext/support/doctype/maintenance_schedule/maintenance_schedule.json diff --git a/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.txt b/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.json similarity index 100% rename from erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.txt rename to erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.json diff --git a/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.txt b/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.json similarity index 100% rename from erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.txt rename to erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.json diff --git a/erpnext/support/doctype/maintenance_visit/maintenance_visit.txt b/erpnext/support/doctype/maintenance_visit/maintenance_visit.json similarity index 100% rename from erpnext/support/doctype/maintenance_visit/maintenance_visit.txt rename to erpnext/support/doctype/maintenance_visit/maintenance_visit.json diff --git a/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.txt b/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.json similarity index 100% rename from erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.txt rename to erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.json diff --git a/erpnext/support/doctype/newsletter/newsletter.txt b/erpnext/support/doctype/newsletter/newsletter.json similarity index 100% rename from erpnext/support/doctype/newsletter/newsletter.txt rename to erpnext/support/doctype/newsletter/newsletter.json diff --git a/erpnext/support/doctype/newsletter/newsletter.py b/erpnext/support/doctype/newsletter/newsletter.py index a2ac2de87b3..8518a377ad6 100644 --- a/erpnext/support/doctype/newsletter/newsletter.py +++ b/erpnext/support/doctype/newsletter/newsletter.py @@ -124,7 +124,7 @@ def get_lead_options(): def create_lead(email_id): """create a lead if it does not exist""" from email.utils import parseaddr - from frappe.model.doc import get_default_naming_series + from frappe.model.naming import get_default_naming_series real_name, email_id = parseaddr(email_id) if frappe.db.get_value("Lead", {"email_id": email_id}): diff --git a/erpnext/support/doctype/newsletter/test_newsletter.py b/erpnext/support/doctype/newsletter/test_newsletter.py index 01ed84eb982..3d89b9a136c 100644 --- a/erpnext/support/doctype/newsletter/test_newsletter.py +++ b/erpnext/support/doctype/newsletter/test_newsletter.py @@ -39,29 +39,4 @@ class TestNewsletter(unittest.TestCase): test_dependencies = ["Lead", "Contact"] -test_records =[ - [{ - "doctype": "Newsletter", - "subject": "_Test Newsletter to Lead", - "send_to_type": "Lead", - "lead_source": "All", - "message": "This is a test newsletter", - "send_from": "admin@example.com" - }], - [{ - "doctype": "Newsletter", - "subject": "_Test Newsletter to Contact", - "send_to_type": "Contact", - "contact_type": "Customer", - "message": "This is a test newsletter", - "send_from": "admin@example.com" - }], - [{ - "doctype": "Newsletter", - "subject": "_Test Newsletter to Custom", - "send_to_type": "Custom", - "email_list": "test_custom@example.com, test_custom1@example.com, test_custom2@example.com", - "message": "This is a test newsletter", - "send_from": "admin@example.com" - }], -] +test_records = frappe.get_test_records('Newsletter') \ No newline at end of file diff --git a/erpnext/support/doctype/support_email_settings/support_email_settings.txt b/erpnext/support/doctype/support_email_settings/support_email_settings.json similarity index 100% rename from erpnext/support/doctype/support_email_settings/support_email_settings.txt rename to erpnext/support/doctype/support_email_settings/support_email_settings.json diff --git a/erpnext/support/doctype/support_ticket/support_ticket.txt b/erpnext/support/doctype/support_ticket/support_ticket.json similarity index 100% rename from erpnext/support/doctype/support_ticket/support_ticket.txt rename to erpnext/support/doctype/support_ticket/support_ticket.json diff --git a/erpnext/support/page/support_analytics/support_analytics.txt b/erpnext/support/page/support_analytics/support_analytics.json similarity index 100% rename from erpnext/support/page/support_analytics/support_analytics.txt rename to erpnext/support/page/support_analytics/support_analytics.json diff --git a/erpnext/support/report/maintenance_schedules/maintenance_schedules.txt b/erpnext/support/report/maintenance_schedules/maintenance_schedules.json similarity index 100% rename from erpnext/support/report/maintenance_schedules/maintenance_schedules.txt rename to erpnext/support/report/maintenance_schedules/maintenance_schedules.json diff --git a/erpnext/utilities/cleanup_data.py b/erpnext/utilities/cleanup_data.py index 328eed1296e..30b16bcbf21 100644 --- a/erpnext/utilities/cleanup_data.py +++ b/erpnext/utilities/cleanup_data.py @@ -154,8 +154,7 @@ def reset_global_defaults(): 'default_price_list_currency': None, } - from frappe.model.code import get_obj - gd = get_obj('Global Defaults', 'Global Defaults') + gd = frappe.get_doc('Global Defaults', 'Global Defaults') for d in flds: gd.set(d, flds[d]) gd.save() diff --git a/erpnext/utilities/doctype/address/address.txt b/erpnext/utilities/doctype/address/address.json similarity index 100% rename from erpnext/utilities/doctype/address/address.txt rename to erpnext/utilities/doctype/address/address.json diff --git a/erpnext/utilities/doctype/address/test_address.py b/erpnext/utilities/doctype/address/test_address.py index befbe82b246..815449aaa7a 100644 --- a/erpnext/utilities/doctype/address/test_address.py +++ b/erpnext/utilities/doctype/address/test_address.py @@ -1,17 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Address", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "address_type": "Office", - "address_title": "_Test Address", - "address_line1": "_Test Address Line 1", - "city": "_Test City", - "country": "India", - "phone": "+91 0000000000", - "is_primary_address": 1 - }], -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Address') \ No newline at end of file diff --git a/erpnext/utilities/doctype/contact/contact.txt b/erpnext/utilities/doctype/contact/contact.json similarity index 100% rename from erpnext/utilities/doctype/contact/contact.txt rename to erpnext/utilities/doctype/contact/contact.json diff --git a/erpnext/utilities/doctype/contact/test_contact.py b/erpnext/utilities/doctype/contact/test_contact.py index 5e7898f08a5..129ec300525 100644 --- a/erpnext/utilities/doctype/contact/test_contact.py +++ b/erpnext/utilities/doctype/contact/test_contact.py @@ -1,25 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Contact", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "first_name": "_Test Contact For _Test Customer", - "email_id": "test_contact_customer@example.com", - "phone": "+91 0000000000", - "status": "Open", - "is_primary_contact": 1 - }], - [{ - "doctype": "Contact", - "supplier": "_Test Supplier", - "supplier_name": "_Test Supplier", - "first_name": "_Test Contact For _Test Supplier", - "email_id": "test_contact_supplier@example.com", - "phone": "+91 0000000000", - "status": "Open", - "is_primary_contact": 1 - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Contact') \ No newline at end of file diff --git a/erpnext/utilities/doctype/note/note.txt b/erpnext/utilities/doctype/note/note.json similarity index 100% rename from erpnext/utilities/doctype/note/note.txt rename to erpnext/utilities/doctype/note/note.json diff --git a/erpnext/utilities/doctype/note_user/note_user.txt b/erpnext/utilities/doctype/note_user/note_user.json similarity index 100% rename from erpnext/utilities/doctype/note_user/note_user.txt rename to erpnext/utilities/doctype/note_user/note_user.json diff --git a/erpnext/utilities/doctype/rename_tool/rename_tool.txt b/erpnext/utilities/doctype/rename_tool/rename_tool.json similarity index 100% rename from erpnext/utilities/doctype/rename_tool/rename_tool.txt rename to erpnext/utilities/doctype/rename_tool/rename_tool.json diff --git a/erpnext/utilities/doctype/sms_control/sms_control.txt b/erpnext/utilities/doctype/sms_control/sms_control.json similarity index 100% rename from erpnext/utilities/doctype/sms_control/sms_control.txt rename to erpnext/utilities/doctype/sms_control/sms_control.json diff --git a/erpnext/utilities/doctype/sms_control/sms_control.py b/erpnext/utilities/doctype/sms_control/sms_control.py index d16e54d8cc9..c0a46471fc6 100644 --- a/erpnext/utilities/doctype/sms_control/sms_control.py +++ b/erpnext/utilities/doctype/sms_control/sms_control.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe, json from frappe.utils import nowdate, cstr -from frappe.model.code import get_obj from frappe import msgprint, throw, _ @@ -69,7 +68,7 @@ class SmsControl(Document): msgprint(ret) def send_via_gateway(self, arg): - ss = get_obj('SMS Settings', 'SMS Settings', with_children=1) + ss = frappe.get_doc('SMS Settings', 'SMS Settings') args = {ss.message_parameter : arg.get('message')} for d in getlist(ss.doclist, 'static_parameter_details'): args[d.parameter] = d.value diff --git a/erpnext/utilities/doctype/sms_log/sms_log.txt b/erpnext/utilities/doctype/sms_log/sms_log.json similarity index 100% rename from erpnext/utilities/doctype/sms_log/sms_log.txt rename to erpnext/utilities/doctype/sms_log/sms_log.json