This commit is contained in:
parent
43405203b2
commit
b385ecf65e
@ -18,7 +18,7 @@ class AccountsSettings(Document):
|
|||||||
if cint(self.auto_accounting_for_stock):
|
if cint(self.auto_accounting_for_stock):
|
||||||
# set default perpetual account in company
|
# set default perpetual account in company
|
||||||
for company in frappe.db.sql("select name from tabCompany"):
|
for company in frappe.db.sql("select name from tabCompany"):
|
||||||
frappe.bean("Company", company[0]).save()
|
frappe.get_doc("Company", company[0]).save()
|
||||||
|
|
||||||
# Create account head for warehouses
|
# Create account head for warehouses
|
||||||
warehouse_list = frappe.db.sql("select name, company from tabWarehouse", as_dict=1)
|
warehouse_list = frappe.db.sql("select name, company from tabWarehouse", as_dict=1)
|
||||||
@ -27,5 +27,5 @@ class AccountsSettings(Document):
|
|||||||
frappe.throw(_("Company is missing in following warehouses") + ": \n" +
|
frappe.throw(_("Company is missing in following warehouses") + ": \n" +
|
||||||
"\n".join(warehouse_with_no_company))
|
"\n".join(warehouse_with_no_company))
|
||||||
for wh in warehouse_list:
|
for wh in warehouse_list:
|
||||||
wh_bean = frappe.bean("Warehouse", wh.name)
|
wh_bean = frappe.get_doc("Warehouse", wh.name)
|
||||||
wh_bean.save()
|
wh_bean.save()
|
@ -36,7 +36,7 @@ class ChartOfAccounts(Document):
|
|||||||
child.update(account_properties.get(chart.get("name"), {})\
|
child.update(account_properties.get(chart.get("name"), {})\
|
||||||
.get(account_name, {}))
|
.get(account_name, {}))
|
||||||
|
|
||||||
account = frappe.bean({
|
account = frappe.get_doc({
|
||||||
"doctype": "Account",
|
"doctype": "Account",
|
||||||
"account_name": account_name,
|
"account_name": account_name,
|
||||||
"company": company,
|
"company": company,
|
||||||
|
@ -13,7 +13,7 @@ def import_charts():
|
|||||||
chart = json.loads(f.read())
|
chart = json.loads(f.read())
|
||||||
country = frappe.db.get_value("Country", {"code": fname.split("_", 1)[0]})
|
country = frappe.db.get_value("Country", {"code": fname.split("_", 1)[0]})
|
||||||
if country:
|
if country:
|
||||||
bean = frappe.bean({
|
bean = frappe.get_doc({
|
||||||
"doctype":"Chart of Accounts",
|
"doctype":"Chart of Accounts",
|
||||||
"chart_name": chart.get("name"),
|
"chart_name": chart.get("name"),
|
||||||
"source_file": fname,
|
"source_file": fname,
|
||||||
|
@ -347,7 +347,7 @@ def get_default_bank_cash_account(company, voucher_type):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_payment_entry_from_sales_invoice(sales_invoice):
|
def get_payment_entry_from_sales_invoice(sales_invoice):
|
||||||
from erpnext.accounts.utils import get_balance_on
|
from erpnext.accounts.utils import get_balance_on
|
||||||
si = frappe.bean("Sales Invoice", sales_invoice)
|
si = frappe.get_doc("Sales Invoice", sales_invoice)
|
||||||
jv = get_payment_entry(si.doc)
|
jv = get_payment_entry(si.doc)
|
||||||
jv.remark = 'Payment received against Sales Invoice %(name)s. %(remarks)s' % si.fields
|
jv.remark = 'Payment received against Sales Invoice %(name)s. %(remarks)s' % si.fields
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ def get_payment_entry_from_sales_invoice(sales_invoice):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_payment_entry_from_purchase_invoice(purchase_invoice):
|
def get_payment_entry_from_purchase_invoice(purchase_invoice):
|
||||||
from erpnext.accounts.utils import get_balance_on
|
from erpnext.accounts.utils import get_balance_on
|
||||||
pi = frappe.bean("Purchase Invoice", purchase_invoice)
|
pi = frappe.get_doc("Purchase Invoice", purchase_invoice)
|
||||||
jv = get_payment_entry(pi.doc)
|
jv = get_payment_entry(pi.doc)
|
||||||
jv.remark = 'Payment against Purchase Invoice %(name)s. %(remarks)s' % pi.fields
|
jv.remark = 'Payment against Purchase Invoice %(name)s. %(remarks)s' % pi.fields
|
||||||
|
|
||||||
|
@ -9,14 +9,14 @@ import frappe
|
|||||||
class TestJournalVoucher(unittest.TestCase):
|
class TestJournalVoucher(unittest.TestCase):
|
||||||
def test_journal_voucher_with_against_jv(self):
|
def test_journal_voucher_with_against_jv(self):
|
||||||
self.clear_account_balance()
|
self.clear_account_balance()
|
||||||
jv_invoice = frappe.bean(copy=test_records[2])
|
jv_invoice = frappe.get_doc(copy=test_records[2])
|
||||||
jv_invoice.insert()
|
jv_invoice.insert()
|
||||||
jv_invoice.submit()
|
jv_invoice.submit()
|
||||||
|
|
||||||
self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||||
where against_jv=%s""", jv_invoice.name))
|
where against_jv=%s""", jv_invoice.name))
|
||||||
|
|
||||||
jv_payment = frappe.bean(copy=test_records[0])
|
jv_payment = frappe.get_doc(copy=test_records[0])
|
||||||
jv_payment.doclist[1].against_jv = jv_invoice.name
|
jv_payment.doclist[1].against_jv = jv_invoice.name
|
||||||
jv_payment.insert()
|
jv_payment.insert()
|
||||||
jv_payment.submit()
|
jv_payment.submit()
|
||||||
@ -37,7 +37,7 @@ class TestJournalVoucher(unittest.TestCase):
|
|||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
||||||
set_perpetual_inventory()
|
set_perpetual_inventory()
|
||||||
|
|
||||||
jv = frappe.bean(copy=test_records[0])
|
jv = frappe.get_doc(copy=test_records[0])
|
||||||
jv.doclist[1].account = "_Test Warehouse - _TC"
|
jv.doclist[1].account = "_Test Warehouse - _TC"
|
||||||
jv.insert()
|
jv.insert()
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ class TestJournalVoucher(unittest.TestCase):
|
|||||||
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore")
|
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore")
|
||||||
self.clear_account_balance()
|
self.clear_account_balance()
|
||||||
|
|
||||||
jv = frappe.bean(copy=test_records[0])
|
jv = frappe.get_doc(copy=test_records[0])
|
||||||
jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
|
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
|
||||||
jv.doclist[2].debit = 20000.0
|
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")
|
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop")
|
||||||
self.clear_account_balance()
|
self.clear_account_balance()
|
||||||
|
|
||||||
jv = frappe.bean(copy=test_records[0])
|
jv = frappe.get_doc(copy=test_records[0])
|
||||||
jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
|
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
|
||||||
jv.doclist[2].debit = 20000.0
|
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")
|
frappe.db.set_value("Company", "_Test Company", "yearly_bgt_flag", "Stop")
|
||||||
|
|
||||||
jv = frappe.bean(copy=test_records[0])
|
jv = frappe.get_doc(copy=test_records[0])
|
||||||
jv.posting_date = "2013-08-12"
|
jv.posting_date = "2013-08-12"
|
||||||
jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv.doclist[2].cost_center = "_Test Cost Center - _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")
|
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop")
|
||||||
self.clear_account_balance()
|
self.clear_account_balance()
|
||||||
|
|
||||||
jv = frappe.bean(copy=test_records[0])
|
jv = frappe.get_doc(copy=test_records[0])
|
||||||
jv.doclist[1].account = "_Test Account Cost for Goods Sold - _TC"
|
jv.doclist[1].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv.doclist[1].cost_center = "_Test Cost Center - _TC"
|
jv.doclist[1].cost_center = "_Test Cost Center - _TC"
|
||||||
jv.doclist[1].credit = 30000.0
|
jv.doclist[1].credit = 30000.0
|
||||||
@ -110,7 +110,7 @@ class TestJournalVoucher(unittest.TestCase):
|
|||||||
self.assertTrue(frappe.db.get_value("GL Entry",
|
self.assertTrue(frappe.db.get_value("GL Entry",
|
||||||
{"voucher_type": "Journal Voucher", "voucher_no": jv.name}))
|
{"voucher_type": "Journal Voucher", "voucher_no": jv.name}))
|
||||||
|
|
||||||
jv1 = frappe.bean(copy=test_records[0])
|
jv1 = frappe.get_doc(copy=test_records[0])
|
||||||
jv1.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
jv1.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv1.doclist[2].cost_center = "_Test Cost Center - _TC"
|
jv1.doclist[2].cost_center = "_Test Cost Center - _TC"
|
||||||
jv1.doclist[2].debit = 40000.0
|
jv1.doclist[2].debit = 40000.0
|
||||||
|
@ -12,18 +12,18 @@ class TestPeriodClosingVoucher(unittest.TestCase):
|
|||||||
frappe.db.sql("""delete from `tabGL Entry`""")
|
frappe.db.sql("""delete from `tabGL Entry`""")
|
||||||
|
|
||||||
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher import test_records as jv_records
|
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher import test_records as jv_records
|
||||||
jv = frappe.bean(copy=jv_records[2])
|
jv = frappe.get_doc(copy=jv_records[2])
|
||||||
jv.insert()
|
jv.insert()
|
||||||
jv.submit()
|
jv.submit()
|
||||||
|
|
||||||
jv1 = frappe.bean(copy=jv_records[0])
|
jv1 = frappe.get_doc(copy=jv_records[0])
|
||||||
jv1.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
jv1.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv1.doclist[2].debit = 600.0
|
jv1.doclist[2].debit = 600.0
|
||||||
jv1.doclist[1].credit = 600.0
|
jv1.doclist[1].credit = 600.0
|
||||||
jv1.insert()
|
jv1.insert()
|
||||||
jv1.submit()
|
jv1.submit()
|
||||||
|
|
||||||
pcv = frappe.bean(copy=test_record)
|
pcv = frappe.get_doc(copy=test_record)
|
||||||
pcv.insert()
|
pcv.insert()
|
||||||
pcv.submit()
|
pcv.submit()
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ class TestPricingRule(unittest.TestCase):
|
|||||||
"price": 0,
|
"price": 0,
|
||||||
"discount_percentage": 10,
|
"discount_percentage": 10,
|
||||||
}]
|
}]
|
||||||
frappe.bean(copy=test_record).insert()
|
frappe.get_doc(copy=test_record).insert()
|
||||||
|
|
||||||
args = frappe._dict({
|
args = frappe._dict({
|
||||||
"item_code": "_Test Item",
|
"item_code": "_Test Item",
|
||||||
@ -38,7 +38,7 @@ class TestPricingRule(unittest.TestCase):
|
|||||||
details = get_item_details(args)
|
details = get_item_details(args)
|
||||||
self.assertEquals(details.get("discount_percentage"), 10)
|
self.assertEquals(details.get("discount_percentage"), 10)
|
||||||
|
|
||||||
prule = frappe.bean(copy=test_record)
|
prule = frappe.get_doc(copy=test_record)
|
||||||
prule.applicable_for = "Customer"
|
prule.applicable_for = "Customer"
|
||||||
self.assertRaises(MandatoryError, prule.insert)
|
self.assertRaises(MandatoryError, prule.insert)
|
||||||
prule.customer = "_Test Customer"
|
prule.customer = "_Test Customer"
|
||||||
@ -47,7 +47,7 @@ class TestPricingRule(unittest.TestCase):
|
|||||||
details = get_item_details(args)
|
details = get_item_details(args)
|
||||||
self.assertEquals(details.get("discount_percentage"), 20)
|
self.assertEquals(details.get("discount_percentage"), 20)
|
||||||
|
|
||||||
prule = frappe.bean(copy=test_record)
|
prule = frappe.get_doc(copy=test_record)
|
||||||
prule.apply_on = "Item Group"
|
prule.apply_on = "Item Group"
|
||||||
prule.item_group = "All Item Groups"
|
prule.item_group = "All Item Groups"
|
||||||
prule.discount_percentage = 15
|
prule.discount_percentage = 15
|
||||||
@ -57,7 +57,7 @@ class TestPricingRule(unittest.TestCase):
|
|||||||
details = get_item_details(args)
|
details = get_item_details(args)
|
||||||
self.assertEquals(details.get("discount_percentage"), 10)
|
self.assertEquals(details.get("discount_percentage"), 10)
|
||||||
|
|
||||||
prule = frappe.bean(copy=test_record)
|
prule = frappe.get_doc(copy=test_record)
|
||||||
prule.applicable_for = "Campaign"
|
prule.applicable_for = "Campaign"
|
||||||
prule.campaign = "_Test Campaign"
|
prule.campaign = "_Test Campaign"
|
||||||
prule.discount_percentage = 5
|
prule.discount_percentage = 5
|
||||||
|
@ -19,7 +19,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
set_perpetual_inventory(0)
|
set_perpetual_inventory(0)
|
||||||
self.assertTrue(not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")))
|
self.assertTrue(not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")))
|
||||||
|
|
||||||
wrapper = frappe.bean(copy=test_records[0])
|
wrapper = frappe.get_doc(copy=test_records[0])
|
||||||
wrapper.insert()
|
wrapper.insert()
|
||||||
wrapper.submit()
|
wrapper.submit()
|
||||||
wrapper.load_from_db()
|
wrapper.load_from_db()
|
||||||
@ -45,7 +45,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
set_perpetual_inventory(1)
|
set_perpetual_inventory(1)
|
||||||
self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
||||||
|
|
||||||
pi = frappe.bean(copy=test_records[1])
|
pi = frappe.get_doc(copy=test_records[1])
|
||||||
pi.insert()
|
pi.insert()
|
||||||
pi.submit()
|
pi.submit()
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
set_perpetual_inventory()
|
set_perpetual_inventory()
|
||||||
self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
||||||
|
|
||||||
pi = frappe.bean(copy=test_records[1])
|
pi = frappe.get_doc(copy=test_records[1])
|
||||||
pi.doclist[1].item_code = "_Test Non Stock Item"
|
pi.doclist[1].item_code = "_Test Non Stock Item"
|
||||||
pi.doclist[1].expense_account = "_Test Account Cost for Goods Sold - _TC"
|
pi.doclist[1].expense_account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
pi.doclist.pop(2)
|
pi.doclist.pop(2)
|
||||||
@ -99,7 +99,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
set_perpetual_inventory(0)
|
set_perpetual_inventory(0)
|
||||||
|
|
||||||
def test_purchase_invoice_calculation(self):
|
def test_purchase_invoice_calculation(self):
|
||||||
wrapper = frappe.bean(copy=test_records[0])
|
wrapper = frappe.get_doc(copy=test_records[0])
|
||||||
wrapper.insert()
|
wrapper.insert()
|
||||||
wrapper.load_from_db()
|
wrapper.load_from_db()
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
self.assertEqual(tax.total, expected_values[i][2])
|
self.assertEqual(tax.total, expected_values[i][2])
|
||||||
|
|
||||||
def test_purchase_invoice_with_subcontracted_item(self):
|
def test_purchase_invoice_with_subcontracted_item(self):
|
||||||
wrapper = frappe.bean(copy=test_records[0])
|
wrapper = frappe.get_doc(copy=test_records[0])
|
||||||
wrapper.doclist[1].item_code = "_Test FG Item"
|
wrapper.doclist[1].item_code = "_Test FG Item"
|
||||||
wrapper.insert()
|
wrapper.insert()
|
||||||
wrapper.load_from_db()
|
wrapper.load_from_db()
|
||||||
@ -169,11 +169,11 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
|
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
|
||||||
import test_records as jv_test_records
|
import test_records as jv_test_records
|
||||||
|
|
||||||
jv = frappe.bean(copy=jv_test_records[1])
|
jv = frappe.get_doc(copy=jv_test_records[1])
|
||||||
jv.insert()
|
jv.insert()
|
||||||
jv.submit()
|
jv.submit()
|
||||||
|
|
||||||
pi = frappe.bean(copy=test_records[0])
|
pi = frappe.get_doc(copy=test_records[0])
|
||||||
pi.append("advance_allocation_details", {
|
pi.append("advance_allocation_details", {
|
||||||
"journal_voucher": jv.name,
|
"journal_voucher": jv.name,
|
||||||
"jv_detail_no": jv.doclist[1].name,
|
"jv_detail_no": jv.doclist[1].name,
|
||||||
|
@ -156,7 +156,7 @@ class SalesInvoice(SellingController):
|
|||||||
def update_time_log_batch(self, sales_invoice):
|
def update_time_log_batch(self, sales_invoice):
|
||||||
for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
|
for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
|
||||||
if d.time_log_batch:
|
if d.time_log_batch:
|
||||||
tlb = frappe.bean("Time Log Batch", d.time_log_batch)
|
tlb = frappe.get_doc("Time Log Batch", d.time_log_batch)
|
||||||
tlb.sales_invoice = sales_invoice
|
tlb.sales_invoice = sales_invoice
|
||||||
tlb.update_after_submit()
|
tlb.update_after_submit()
|
||||||
|
|
||||||
@ -672,7 +672,7 @@ def manage_recurring_invoices(next_date=None, commit=True):
|
|||||||
where posting_date=%s and recurring_id=%s and docstatus=1""",
|
where posting_date=%s and recurring_id=%s and docstatus=1""",
|
||||||
(next_date, recurring_id)):
|
(next_date, recurring_id)):
|
||||||
try:
|
try:
|
||||||
ref_wrapper = frappe.bean('Sales Invoice', ref_invoice)
|
ref_wrapper = frappe.get_doc('Sales Invoice', ref_invoice)
|
||||||
new_invoice_wrapper = make_new_invoice(ref_wrapper, next_date)
|
new_invoice_wrapper = make_new_invoice(ref_wrapper, next_date)
|
||||||
send_notification(new_invoice_wrapper)
|
send_notification(new_invoice_wrapper)
|
||||||
if commit:
|
if commit:
|
||||||
@ -798,7 +798,7 @@ def make_delivery_note(source_name, target_doc=None):
|
|||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
bean = frappe.bean(target)
|
bean = frappe.get_doc(target)
|
||||||
bean.run_method("onload_post_render")
|
bean.run_method("onload_post_render")
|
||||||
|
|
||||||
def update_item(source_doc, target_doc, source_parent):
|
def update_item(source_doc, target_doc, source_parent):
|
||||||
|
@ -10,29 +10,29 @@ from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_per
|
|||||||
|
|
||||||
class TestSalesInvoice(unittest.TestCase):
|
class TestSalesInvoice(unittest.TestCase):
|
||||||
def make(self):
|
def make(self):
|
||||||
w = frappe.bean(copy=test_records[0])
|
w = frappe.get_doc(copy=test_records[0])
|
||||||
w.is_pos = 0
|
w.is_pos = 0
|
||||||
w.insert()
|
w.insert()
|
||||||
w.submit()
|
w.submit()
|
||||||
return w
|
return w
|
||||||
|
|
||||||
def test_double_submission(self):
|
def test_double_submission(self):
|
||||||
w = frappe.bean(copy=test_records[0])
|
w = frappe.get_doc(copy=test_records[0])
|
||||||
w.docstatus = '0'
|
w.docstatus = '0'
|
||||||
w.insert()
|
w.insert()
|
||||||
|
|
||||||
w2 = [d for d in w.doclist]
|
w2 = [d for d in w.doclist]
|
||||||
w.submit()
|
w.submit()
|
||||||
|
|
||||||
w = frappe.bean(w2)
|
w = frappe.get_doc(w2)
|
||||||
self.assertRaises(DocstatusTransitionError, w.submit)
|
self.assertRaises(DocstatusTransitionError, w.submit)
|
||||||
|
|
||||||
def test_timestamp_change(self):
|
def test_timestamp_change(self):
|
||||||
w = frappe.bean(copy=test_records[0])
|
w = frappe.get_doc(copy=test_records[0])
|
||||||
w.docstatus = '0'
|
w.docstatus = '0'
|
||||||
w.insert()
|
w.insert()
|
||||||
|
|
||||||
w2 = frappe.bean([d.fields.copy() for d in w.doclist])
|
w2 = frappe.get_doc([d.fields.copy() for d in w.doclist])
|
||||||
|
|
||||||
import time
|
import time
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@ -43,7 +43,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self.assertRaises(TimestampMismatchError, w2.save)
|
self.assertRaises(TimestampMismatchError, w2.save)
|
||||||
|
|
||||||
def test_sales_invoice_calculation_base_currency(self):
|
def test_sales_invoice_calculation_base_currency(self):
|
||||||
si = frappe.bean(copy=test_records[2])
|
si = frappe.get_doc(copy=test_records[2])
|
||||||
si.insert()
|
si.insert()
|
||||||
|
|
||||||
expected_values = {
|
expected_values = {
|
||||||
@ -87,7 +87,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self.assertEquals(si.grand_total_export, 1627.05)
|
self.assertEquals(si.grand_total_export, 1627.05)
|
||||||
|
|
||||||
def test_sales_invoice_calculation_export_currency(self):
|
def test_sales_invoice_calculation_export_currency(self):
|
||||||
si = frappe.bean(copy=test_records[2])
|
si = frappe.get_doc(copy=test_records[2])
|
||||||
si.currency = "USD"
|
si.currency = "USD"
|
||||||
si.conversion_rate = 50
|
si.conversion_rate = 50
|
||||||
si.doclist[1].rate = 1
|
si.doclist[1].rate = 1
|
||||||
@ -137,7 +137,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self.assertEquals(si.grand_total_export, 32.54)
|
self.assertEquals(si.grand_total_export, 32.54)
|
||||||
|
|
||||||
def test_sales_invoice_discount_amount(self):
|
def test_sales_invoice_discount_amount(self):
|
||||||
si = frappe.bean(copy=test_records[3])
|
si = frappe.get_doc(copy=test_records[3])
|
||||||
si.discount_amount = 104.95
|
si.discount_amount = 104.95
|
||||||
si.append("other_charges", {
|
si.append("other_charges", {
|
||||||
"doctype": "Sales Taxes and Charges",
|
"doctype": "Sales Taxes and Charges",
|
||||||
@ -192,7 +192,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self.assertEquals(si.grand_total_export, 1500)
|
self.assertEquals(si.grand_total_export, 1500)
|
||||||
|
|
||||||
def test_discount_amount_gl_entry(self):
|
def test_discount_amount_gl_entry(self):
|
||||||
si = frappe.bean(copy=test_records[3])
|
si = frappe.get_doc(copy=test_records[3])
|
||||||
si.discount_amount = 104.95
|
si.discount_amount = 104.95
|
||||||
si.append("other_charges", {
|
si.append("other_charges", {
|
||||||
"doctype": "Sales Taxes and Charges",
|
"doctype": "Sales Taxes and Charges",
|
||||||
@ -240,7 +240,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self.assertFalse(gle)
|
self.assertFalse(gle)
|
||||||
|
|
||||||
def test_inclusive_rate_validations(self):
|
def test_inclusive_rate_validations(self):
|
||||||
si = frappe.bean(copy=test_records[2])
|
si = frappe.get_doc(copy=test_records[2])
|
||||||
for i, tax in enumerate(si.get("other_charges")):
|
for i, tax in enumerate(si.get("other_charges")):
|
||||||
tax.idx = i+1
|
tax.idx = i+1
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
def test_sales_invoice_calculation_base_currency_with_tax_inclusive_price(self):
|
def test_sales_invoice_calculation_base_currency_with_tax_inclusive_price(self):
|
||||||
# prepare
|
# prepare
|
||||||
si = frappe.bean(copy=test_records[3])
|
si = frappe.get_doc(copy=test_records[3])
|
||||||
si.insert()
|
si.insert()
|
||||||
|
|
||||||
expected_values = {
|
expected_values = {
|
||||||
@ -303,7 +303,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
def test_sales_invoice_calculation_export_currency_with_tax_inclusive_price(self):
|
def test_sales_invoice_calculation_export_currency_with_tax_inclusive_price(self):
|
||||||
# prepare
|
# prepare
|
||||||
si = frappe.bean(copy=test_records[3])
|
si = frappe.get_doc(copy=test_records[3])
|
||||||
si.currency = "USD"
|
si.currency = "USD"
|
||||||
si.conversion_rate = 50
|
si.conversion_rate = 50
|
||||||
si.doclist[1].price_list_rate = 55.56
|
si.doclist[1].price_list_rate = 55.56
|
||||||
@ -365,7 +365,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
|
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
|
||||||
import test_records as jv_test_records
|
import test_records as jv_test_records
|
||||||
|
|
||||||
jv = frappe.bean(frappe.copy_doc(jv_test_records[0]))
|
jv = frappe.get_doc(frappe.copy_doc(jv_test_records[0]))
|
||||||
jv.doclist[1].against_invoice = w.name
|
jv.doclist[1].against_invoice = w.name
|
||||||
jv.insert()
|
jv.insert()
|
||||||
jv.submit()
|
jv.submit()
|
||||||
@ -378,10 +378,10 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
561.8)
|
561.8)
|
||||||
|
|
||||||
def test_time_log_batch(self):
|
def test_time_log_batch(self):
|
||||||
tlb = frappe.bean("Time Log Batch", "_T-Time Log Batch-00001")
|
tlb = frappe.get_doc("Time Log Batch", "_T-Time Log Batch-00001")
|
||||||
tlb.submit()
|
tlb.submit()
|
||||||
|
|
||||||
si = frappe.bean(frappe.copy_doc(test_records[0]))
|
si = frappe.get_doc(frappe.copy_doc(test_records[0]))
|
||||||
si.doclist[1].time_log_batch = "_T-Time Log Batch-00001"
|
si.doclist[1].time_log_batch = "_T-Time Log Batch-00001"
|
||||||
si.insert()
|
si.insert()
|
||||||
si.submit()
|
si.submit()
|
||||||
@ -403,7 +403,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
def test_sales_invoice_gl_entry_without_aii(self):
|
def test_sales_invoice_gl_entry_without_aii(self):
|
||||||
self.clear_stock_account_balance()
|
self.clear_stock_account_balance()
|
||||||
set_perpetual_inventory(0)
|
set_perpetual_inventory(0)
|
||||||
si = frappe.bean(copy=test_records[1])
|
si = frappe.get_doc(copy=test_records[1])
|
||||||
si.insert()
|
si.insert()
|
||||||
si.submit()
|
si.submit()
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
pos[0]["cash_bank_account"] = "_Test Account Bank Account - _TC"
|
pos[0]["cash_bank_account"] = "_Test Account Bank Account - _TC"
|
||||||
pos[0]["paid_amount"] = 600.0
|
pos[0]["paid_amount"] = 600.0
|
||||||
|
|
||||||
si = frappe.bean(copy=pos)
|
si = frappe.get_doc(copy=pos)
|
||||||
si.insert()
|
si.insert()
|
||||||
si.submit()
|
si.submit()
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
# insert purchase receipt
|
# insert purchase receipt
|
||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
|
||||||
as pr_test_records
|
as pr_test_records
|
||||||
pr = frappe.bean(copy=pr_test_records[0])
|
pr = frappe.get_doc(copy=pr_test_records[0])
|
||||||
pr.naming_series = "_T-Purchase Receipt-"
|
pr.naming_series = "_T-Purchase Receipt-"
|
||||||
pr.doclist[1].warehouse = "_Test Warehouse No Account - _TC"
|
pr.doclist[1].warehouse = "_Test Warehouse No Account - _TC"
|
||||||
pr.insert()
|
pr.insert()
|
||||||
@ -511,7 +511,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
si_doclist[0]["posting_time"] = "12:05"
|
si_doclist[0]["posting_time"] = "12:05"
|
||||||
si_doclist[1]["warehouse"] = "_Test Warehouse No Account - _TC"
|
si_doclist[1]["warehouse"] = "_Test Warehouse No Account - _TC"
|
||||||
|
|
||||||
si = frappe.bean(copy=si_doclist)
|
si = frappe.get_doc(copy=si_doclist)
|
||||||
si.insert()
|
si.insert()
|
||||||
si.submit()
|
si.submit()
|
||||||
|
|
||||||
@ -553,7 +553,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
si_copy = frappe.copy_doc(test_records[1])
|
si_copy = frappe.copy_doc(test_records[1])
|
||||||
si_copy[1]["item_code"] = None
|
si_copy[1]["item_code"] = None
|
||||||
si = frappe.bean(si_copy)
|
si = frappe.get_doc(si_copy)
|
||||||
si.insert()
|
si.insert()
|
||||||
si.submit()
|
si.submit()
|
||||||
|
|
||||||
@ -580,7 +580,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
set_perpetual_inventory()
|
set_perpetual_inventory()
|
||||||
si_copy = frappe.copy_doc(test_records[1])
|
si_copy = frappe.copy_doc(test_records[1])
|
||||||
si_copy[1]["item_code"] = "_Test Non Stock Item"
|
si_copy[1]["item_code"] = "_Test Non Stock Item"
|
||||||
si = frappe.bean(si_copy)
|
si = frappe.get_doc(si_copy)
|
||||||
si.insert()
|
si.insert()
|
||||||
si.submit()
|
si.submit()
|
||||||
|
|
||||||
@ -605,7 +605,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
def _insert_purchase_receipt(self):
|
def _insert_purchase_receipt(self):
|
||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
|
||||||
as pr_test_records
|
as pr_test_records
|
||||||
pr = frappe.bean(copy=pr_test_records[0])
|
pr = frappe.get_doc(copy=pr_test_records[0])
|
||||||
pr.naming_series = "_T-Purchase Receipt-"
|
pr.naming_series = "_T-Purchase Receipt-"
|
||||||
pr.insert()
|
pr.insert()
|
||||||
pr.submit()
|
pr.submit()
|
||||||
@ -613,7 +613,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
def _insert_delivery_note(self):
|
def _insert_delivery_note(self):
|
||||||
from erpnext.stock.doctype.delivery_note.test_delivery_note import test_records \
|
from erpnext.stock.doctype.delivery_note.test_delivery_note import test_records \
|
||||||
as dn_test_records
|
as dn_test_records
|
||||||
dn = frappe.bean(copy=dn_test_records[0])
|
dn = frappe.get_doc(copy=dn_test_records[0])
|
||||||
dn.naming_series = "_T-Delivery Note-"
|
dn.naming_series = "_T-Delivery Note-"
|
||||||
dn.insert()
|
dn.insert()
|
||||||
dn.submit()
|
dn.submit()
|
||||||
@ -624,18 +624,18 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
import test_records as pos_setting_test_records
|
import test_records as pos_setting_test_records
|
||||||
frappe.db.sql("""delete from `tabPOS Setting`""")
|
frappe.db.sql("""delete from `tabPOS Setting`""")
|
||||||
|
|
||||||
ps = frappe.bean(copy=pos_setting_test_records[0])
|
ps = frappe.get_doc(copy=pos_setting_test_records[0])
|
||||||
ps.insert()
|
ps.insert()
|
||||||
|
|
||||||
def test_sales_invoice_with_advance(self):
|
def test_sales_invoice_with_advance(self):
|
||||||
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
|
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
|
||||||
import test_records as jv_test_records
|
import test_records as jv_test_records
|
||||||
|
|
||||||
jv = frappe.bean(copy=jv_test_records[0])
|
jv = frappe.get_doc(copy=jv_test_records[0])
|
||||||
jv.insert()
|
jv.insert()
|
||||||
jv.submit()
|
jv.submit()
|
||||||
|
|
||||||
si = frappe.bean(copy=test_records[0])
|
si = frappe.get_doc(copy=test_records[0])
|
||||||
si.append("advance_adjustment_details", {
|
si.append("advance_adjustment_details", {
|
||||||
"doctype": "Sales Invoice Advance",
|
"doctype": "Sales Invoice Advance",
|
||||||
"journal_voucher": jv.name,
|
"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 frappe.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
today = nowdate()
|
today = nowdate()
|
||||||
base_si = frappe.bean(copy=test_records[0])
|
base_si = frappe.get_doc(copy=test_records[0])
|
||||||
base_si.update({
|
base_si.update({
|
||||||
"convert_into_recurring_invoice": 1,
|
"convert_into_recurring_invoice": 1,
|
||||||
"recurring_type": "Monthly",
|
"recurring_type": "Monthly",
|
||||||
@ -678,13 +678,13 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
})
|
})
|
||||||
|
|
||||||
# monthly
|
# monthly
|
||||||
si1 = frappe.bean(copy=base_si.doclist)
|
si1 = frappe.get_doc(copy=base_si.doclist)
|
||||||
si1.insert()
|
si1.insert()
|
||||||
si1.submit()
|
si1.submit()
|
||||||
self._test_recurring_invoice(si1, True)
|
self._test_recurring_invoice(si1, True)
|
||||||
|
|
||||||
# monthly without a first and last day period
|
# monthly without a first and last day period
|
||||||
si2 = frappe.bean(copy=base_si.doclist)
|
si2 = frappe.get_doc(copy=base_si.doclist)
|
||||||
si2.update({
|
si2.update({
|
||||||
"invoice_period_from_date": today,
|
"invoice_period_from_date": today,
|
||||||
"invoice_period_to_date": add_to_date(today, days=30)
|
"invoice_period_to_date": add_to_date(today, days=30)
|
||||||
@ -694,7 +694,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self._test_recurring_invoice(si2, False)
|
self._test_recurring_invoice(si2, False)
|
||||||
|
|
||||||
# quarterly
|
# quarterly
|
||||||
si3 = frappe.bean(copy=base_si.doclist)
|
si3 = frappe.get_doc(copy=base_si.doclist)
|
||||||
si3.update({
|
si3.update({
|
||||||
"recurring_type": "Quarterly",
|
"recurring_type": "Quarterly",
|
||||||
"invoice_period_from_date": get_first_day(today),
|
"invoice_period_from_date": get_first_day(today),
|
||||||
@ -705,7 +705,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self._test_recurring_invoice(si3, True)
|
self._test_recurring_invoice(si3, True)
|
||||||
|
|
||||||
# quarterly without a first and last day period
|
# quarterly without a first and last day period
|
||||||
si4 = frappe.bean(copy=base_si.doclist)
|
si4 = frappe.get_doc(copy=base_si.doclist)
|
||||||
si4.update({
|
si4.update({
|
||||||
"recurring_type": "Quarterly",
|
"recurring_type": "Quarterly",
|
||||||
"invoice_period_from_date": today,
|
"invoice_period_from_date": today,
|
||||||
@ -716,7 +716,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self._test_recurring_invoice(si4, False)
|
self._test_recurring_invoice(si4, False)
|
||||||
|
|
||||||
# yearly
|
# yearly
|
||||||
si5 = frappe.bean(copy=base_si.doclist)
|
si5 = frappe.get_doc(copy=base_si.doclist)
|
||||||
si5.update({
|
si5.update({
|
||||||
"recurring_type": "Yearly",
|
"recurring_type": "Yearly",
|
||||||
"invoice_period_from_date": get_first_day(today),
|
"invoice_period_from_date": get_first_day(today),
|
||||||
@ -727,7 +727,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self._test_recurring_invoice(si5, True)
|
self._test_recurring_invoice(si5, True)
|
||||||
|
|
||||||
# yearly without a first and last day period
|
# yearly without a first and last day period
|
||||||
si6 = frappe.bean(copy=base_si.doclist)
|
si6 = frappe.get_doc(copy=base_si.doclist)
|
||||||
si6.update({
|
si6.update({
|
||||||
"recurring_type": "Yearly",
|
"recurring_type": "Yearly",
|
||||||
"invoice_period_from_date": today,
|
"invoice_period_from_date": today,
|
||||||
@ -738,7 +738,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self._test_recurring_invoice(si6, False)
|
self._test_recurring_invoice(si6, False)
|
||||||
|
|
||||||
# change posting date but keep recuring day to be today
|
# change posting date but keep recuring day to be today
|
||||||
si7 = frappe.bean(copy=base_si.doclist)
|
si7 = frappe.get_doc(copy=base_si.doclist)
|
||||||
si7.update({
|
si7.update({
|
||||||
"posting_date": add_to_date(today, days=-1)
|
"posting_date": add_to_date(today, days=-1)
|
||||||
})
|
})
|
||||||
@ -771,7 +771,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEquals(i+2, len(recurred_invoices))
|
self.assertEquals(i+2, len(recurred_invoices))
|
||||||
|
|
||||||
new_si = frappe.bean("Sales Invoice", recurred_invoices[0][0])
|
new_si = frappe.get_doc("Sales Invoice", recurred_invoices[0][0])
|
||||||
|
|
||||||
for fieldname in ["convert_into_recurring_invoice", "recurring_type",
|
for fieldname in ["convert_into_recurring_invoice", "recurring_type",
|
||||||
"repeat_on_day_of_month", "notification_email_address"]:
|
"repeat_on_day_of_month", "notification_email_address"]:
|
||||||
@ -811,7 +811,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
se = make_serialized_item()
|
se = make_serialized_item()
|
||||||
serial_nos = get_serial_nos(se.doclist[1].serial_no)
|
serial_nos = get_serial_nos(se.doclist[1].serial_no)
|
||||||
|
|
||||||
si = frappe.bean(copy=test_records[0])
|
si = frappe.get_doc(copy=test_records[0])
|
||||||
si.update_stock = 1
|
si.update_stock = 1
|
||||||
si.doclist[1].item_code = "_Test Serialized Item With Series"
|
si.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||||
si.doclist[1].qty = 1
|
si.doclist[1].qty = 1
|
||||||
@ -845,11 +845,11 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
se = make_serialized_item()
|
se = make_serialized_item()
|
||||||
serial_nos = get_serial_nos(se.doclist[1].serial_no)
|
serial_nos = get_serial_nos(se.doclist[1].serial_no)
|
||||||
|
|
||||||
sr = frappe.bean("Serial No", serial_nos[0])
|
sr = frappe.get_doc("Serial No", serial_nos[0])
|
||||||
sr.status = "Not Available"
|
sr.status = "Not Available"
|
||||||
sr.save()
|
sr.save()
|
||||||
|
|
||||||
si = frappe.bean(copy=test_records[0])
|
si = frappe.get_doc(copy=test_records[0])
|
||||||
si.update_stock = 1
|
si.update_stock = 1
|
||||||
si.doclist[1].item_code = "_Test Serialized Item With Series"
|
si.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||||
si.doclist[1].qty = 1
|
si.doclist[1].qty = 1
|
||||||
|
@ -7,12 +7,12 @@ from erpnext.accounts.doctype.shipping_rule.shipping_rule import FromGreaterThan
|
|||||||
|
|
||||||
class TestShippingRule(unittest.TestCase):
|
class TestShippingRule(unittest.TestCase):
|
||||||
def test_from_greater_than_to(self):
|
def test_from_greater_than_to(self):
|
||||||
shipping_rule = frappe.bean(copy=test_records[0])
|
shipping_rule = frappe.get_doc(copy=test_records[0])
|
||||||
shipping_rule.doclist[1].from_value = 101
|
shipping_rule.doclist[1].from_value = 101
|
||||||
self.assertRaises(FromGreaterThanToError, shipping_rule.insert)
|
self.assertRaises(FromGreaterThanToError, shipping_rule.insert)
|
||||||
|
|
||||||
def test_many_zero_to_values(self):
|
def test_many_zero_to_values(self):
|
||||||
shipping_rule = frappe.bean(copy=test_records[0])
|
shipping_rule = frappe.get_doc(copy=test_records[0])
|
||||||
shipping_rule.doclist[1].to_value = 0
|
shipping_rule.doclist[1].to_value = 0
|
||||||
self.assertRaises(ManyBlankToValuesError, shipping_rule.insert)
|
self.assertRaises(ManyBlankToValuesError, shipping_rule.insert)
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ class TestShippingRule(unittest.TestCase):
|
|||||||
((50, 150), (25, 175)),
|
((50, 150), (25, 175)),
|
||||||
((50, 150), (50, 150)),
|
((50, 150), (50, 150)),
|
||||||
]:
|
]:
|
||||||
shipping_rule = frappe.bean(copy=test_records[0])
|
shipping_rule = frappe.get_doc(copy=test_records[0])
|
||||||
shipping_rule.doclist[1].from_value = range_a[0]
|
shipping_rule.doclist[1].from_value = range_a[0]
|
||||||
shipping_rule.doclist[1].to_value = range_a[1]
|
shipping_rule.doclist[1].to_value = range_a[1]
|
||||||
shipping_rule.doclist[2].from_value = range_b[0]
|
shipping_rule.doclist[2].from_value = range_b[0]
|
||||||
|
@ -77,7 +77,7 @@ def save_entries(gl_map, adv_adj, update_outstanding):
|
|||||||
|
|
||||||
def make_entry(args, adv_adj, update_outstanding):
|
def make_entry(args, adv_adj, update_outstanding):
|
||||||
args.update({"doctype": "GL Entry"})
|
args.update({"doctype": "GL Entry"})
|
||||||
gle = frappe.bean([args])
|
gle = frappe.get_doc([args])
|
||||||
gle.ignore_permissions = 1
|
gle.ignore_permissions = 1
|
||||||
gle.insert()
|
gle.insert()
|
||||||
gle.run_method("on_update_with_args", adv_adj, update_outstanding)
|
gle.run_method("on_update_with_args", adv_adj, update_outstanding)
|
||||||
|
@ -25,7 +25,7 @@ def _get_party_details(party=None, account=None, party_type="Customer", company=
|
|||||||
if not ignore_permissions and not frappe.has_permission(party_type, "read", party):
|
if not ignore_permissions and not frappe.has_permission(party_type, "read", party):
|
||||||
frappe.throw("Not Permitted", frappe.PermissionError)
|
frappe.throw("Not Permitted", frappe.PermissionError)
|
||||||
|
|
||||||
party_bean = frappe.bean(party_type, party)
|
party_bean = frappe.get_doc(party_type, party)
|
||||||
party = party_bean.doc
|
party = party_bean.doc
|
||||||
|
|
||||||
set_address_details(out, party, party_type)
|
set_address_details(out, party, party_type)
|
||||||
@ -166,7 +166,7 @@ def create_party_account(party, party_type, company):
|
|||||||
frappe.throw(_("Please enter Account Receivable/Payable group in company master"))
|
frappe.throw(_("Please enter Account Receivable/Payable group in company master"))
|
||||||
|
|
||||||
# create
|
# create
|
||||||
account = frappe.bean({
|
account = frappe.get_doc({
|
||||||
"doctype": "Account",
|
"doctype": "Account",
|
||||||
'account_name': party,
|
'account_name': party,
|
||||||
'parent_account': parent_account,
|
'parent_account': parent_account,
|
||||||
|
@ -103,7 +103,7 @@ def add_ac(args=None):
|
|||||||
args = frappe.local.form_dict
|
args = frappe.local.form_dict
|
||||||
args.pop("cmd")
|
args.pop("cmd")
|
||||||
|
|
||||||
ac = frappe.bean(args)
|
ac = frappe.get_doc(args)
|
||||||
ac.doctype = "Account"
|
ac.doctype = "Account"
|
||||||
ac.old_parent = ""
|
ac.old_parent = ""
|
||||||
ac.freeze_account = "No"
|
ac.freeze_account = "No"
|
||||||
@ -116,7 +116,7 @@ def add_cc(args=None):
|
|||||||
args = frappe.local.form_dict
|
args = frappe.local.form_dict
|
||||||
args.pop("cmd")
|
args.pop("cmd")
|
||||||
|
|
||||||
cc = frappe.bean(args)
|
cc = frappe.get_doc(args)
|
||||||
cc.doctype = "Cost Center"
|
cc.doctype = "Cost Center"
|
||||||
cc.old_parent = ""
|
cc.old_parent = ""
|
||||||
cc.insert()
|
cc.insert()
|
||||||
|
@ -185,7 +185,7 @@ def make_purchase_receipt(source_name, target_doc=None):
|
|||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
bean = frappe.bean(target)
|
bean = frappe.get_doc(target)
|
||||||
bean.run_method("set_missing_values")
|
bean.run_method("set_missing_values")
|
||||||
|
|
||||||
def update_item(obj, target, source_parent):
|
def update_item(obj, target, source_parent):
|
||||||
@ -224,7 +224,7 @@ def make_purchase_invoice(source_name, target_doc=None):
|
|||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
bean = frappe.bean(target)
|
bean = frappe.get_doc(target)
|
||||||
bean.run_method("set_missing_values")
|
bean.run_method("set_missing_values")
|
||||||
|
|
||||||
def update_item(obj, target, source_parent):
|
def update_item(obj, target, source_parent):
|
||||||
|
@ -11,12 +11,12 @@ class TestPurchaseOrder(unittest.TestCase):
|
|||||||
def test_make_purchase_receipt(self):
|
def test_make_purchase_receipt(self):
|
||||||
from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_receipt
|
from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_receipt
|
||||||
|
|
||||||
po = frappe.bean(copy=test_records[0]).insert()
|
po = frappe.get_doc(copy=test_records[0]).insert()
|
||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, make_purchase_receipt,
|
self.assertRaises(frappe.ValidationError, make_purchase_receipt,
|
||||||
po.name)
|
po.name)
|
||||||
|
|
||||||
po = frappe.bean("Purchase Order", po.name)
|
po = frappe.get_doc("Purchase Order", po.name)
|
||||||
po.submit()
|
po.submit()
|
||||||
|
|
||||||
pr = make_purchase_receipt(po.name)
|
pr = make_purchase_receipt(po.name)
|
||||||
@ -26,7 +26,7 @@ class TestPurchaseOrder(unittest.TestCase):
|
|||||||
self.assertEquals(len(pr), len(test_records[0]))
|
self.assertEquals(len(pr), len(test_records[0]))
|
||||||
|
|
||||||
pr[0]["naming_series"] = "_T-Purchase Receipt-"
|
pr[0]["naming_series"] = "_T-Purchase Receipt-"
|
||||||
pr_bean = frappe.bean(pr)
|
pr_bean = frappe.get_doc(pr)
|
||||||
pr_bean.insert()
|
pr_bean.insert()
|
||||||
|
|
||||||
def test_ordered_qty(self):
|
def test_ordered_qty(self):
|
||||||
@ -34,12 +34,12 @@ class TestPurchaseOrder(unittest.TestCase):
|
|||||||
|
|
||||||
from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_receipt
|
from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_receipt
|
||||||
|
|
||||||
po = frappe.bean(copy=test_records[0]).insert()
|
po = frappe.get_doc(copy=test_records[0]).insert()
|
||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, make_purchase_receipt,
|
self.assertRaises(frappe.ValidationError, make_purchase_receipt,
|
||||||
po.name)
|
po.name)
|
||||||
|
|
||||||
po = frappe.bean("Purchase Order", po.name)
|
po = frappe.get_doc("Purchase Order", po.name)
|
||||||
po.is_subcontracted = "No"
|
po.is_subcontracted = "No"
|
||||||
po.doclist[1].item_code = "_Test Item"
|
po.doclist[1].item_code = "_Test Item"
|
||||||
po.submit()
|
po.submit()
|
||||||
@ -54,7 +54,7 @@ class TestPurchaseOrder(unittest.TestCase):
|
|||||||
pr[0]["posting_date"] = "2013-05-12"
|
pr[0]["posting_date"] = "2013-05-12"
|
||||||
pr[0]["naming_series"] = "_T-Purchase Receipt-"
|
pr[0]["naming_series"] = "_T-Purchase Receipt-"
|
||||||
pr[1]["qty"] = 4.0
|
pr[1]["qty"] = 4.0
|
||||||
pr_bean = frappe.bean(pr)
|
pr_bean = frappe.get_doc(pr)
|
||||||
pr_bean.insert()
|
pr_bean.insert()
|
||||||
pr_bean.submit()
|
pr_bean.submit()
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ class TestPurchaseOrder(unittest.TestCase):
|
|||||||
pr1[0]["naming_series"] = "_T-Purchase Receipt-"
|
pr1[0]["naming_series"] = "_T-Purchase Receipt-"
|
||||||
pr1[0]["posting_date"] = "2013-05-12"
|
pr1[0]["posting_date"] = "2013-05-12"
|
||||||
pr1[1]["qty"] = 8
|
pr1[1]["qty"] = 8
|
||||||
pr1_bean = frappe.bean(pr1)
|
pr1_bean = frappe.get_doc(pr1)
|
||||||
pr1_bean.insert()
|
pr1_bean.insert()
|
||||||
pr1_bean.submit()
|
pr1_bean.submit()
|
||||||
|
|
||||||
@ -77,12 +77,12 @@ class TestPurchaseOrder(unittest.TestCase):
|
|||||||
def test_make_purchase_invoice(self):
|
def test_make_purchase_invoice(self):
|
||||||
from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_invoice
|
from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_invoice
|
||||||
|
|
||||||
po = frappe.bean(copy=test_records[0]).insert()
|
po = frappe.get_doc(copy=test_records[0]).insert()
|
||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, make_purchase_invoice,
|
self.assertRaises(frappe.ValidationError, make_purchase_invoice,
|
||||||
po.name)
|
po.name)
|
||||||
|
|
||||||
po = frappe.bean("Purchase Order", po.name)
|
po = frappe.get_doc("Purchase Order", po.name)
|
||||||
po.submit()
|
po.submit()
|
||||||
pi = make_purchase_invoice(po.name)
|
pi = make_purchase_invoice(po.name)
|
||||||
|
|
||||||
@ -90,23 +90,23 @@ class TestPurchaseOrder(unittest.TestCase):
|
|||||||
self.assertEquals(len(pi), len(test_records[0]))
|
self.assertEquals(len(pi), len(test_records[0]))
|
||||||
pi[0]["posting_date"] = "2013-05-12"
|
pi[0]["posting_date"] = "2013-05-12"
|
||||||
pi[0]["bill_no"] = "NA"
|
pi[0]["bill_no"] = "NA"
|
||||||
frappe.bean(pi).insert()
|
frappe.get_doc(pi).insert()
|
||||||
|
|
||||||
def test_subcontracting(self):
|
def test_subcontracting(self):
|
||||||
po = frappe.bean(copy=test_records[0])
|
po = frappe.get_doc(copy=test_records[0])
|
||||||
po.insert()
|
po.insert()
|
||||||
self.assertEquals(len(po.get("po_raw_material_details")), 2)
|
self.assertEquals(len(po.get("po_raw_material_details")), 2)
|
||||||
|
|
||||||
def test_warehouse_company_validation(self):
|
def test_warehouse_company_validation(self):
|
||||||
from erpnext.stock.utils import InvalidWarehouseCompany
|
from erpnext.stock.utils import InvalidWarehouseCompany
|
||||||
po = frappe.bean(copy=test_records[0])
|
po = frappe.get_doc(copy=test_records[0])
|
||||||
po.company = "_Test Company 1"
|
po.company = "_Test Company 1"
|
||||||
po.conversion_rate = 0.0167
|
po.conversion_rate = 0.0167
|
||||||
self.assertRaises(InvalidWarehouseCompany, po.insert)
|
self.assertRaises(InvalidWarehouseCompany, po.insert)
|
||||||
|
|
||||||
def test_uom_integer_validation(self):
|
def test_uom_integer_validation(self):
|
||||||
from erpnext.utilities.transaction_base import UOMMustBeIntegerError
|
from erpnext.utilities.transaction_base import UOMMustBeIntegerError
|
||||||
po = frappe.bean(copy=test_records[0])
|
po = frappe.get_doc(copy=test_records[0])
|
||||||
po.doclist[1].qty = 3.4
|
po.doclist[1].qty = 3.4
|
||||||
self.assertRaises(UOMMustBeIntegerError, po.insert)
|
self.assertRaises(UOMMustBeIntegerError, po.insert)
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ def make_purchase_order(source_name, target_doc=None):
|
|||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
bean = frappe.bean(target)
|
bean = frappe.get_doc(target)
|
||||||
bean.run_method("set_missing_values")
|
bean.run_method("set_missing_values")
|
||||||
bean.run_method("get_schedule_dates")
|
bean.run_method("get_schedule_dates")
|
||||||
|
|
||||||
|
@ -11,12 +11,12 @@ class TestPurchaseOrder(unittest.TestCase):
|
|||||||
def test_make_purchase_order(self):
|
def test_make_purchase_order(self):
|
||||||
from erpnext.buying.doctype.supplier_quotation.supplier_quotation import make_purchase_order
|
from erpnext.buying.doctype.supplier_quotation.supplier_quotation import make_purchase_order
|
||||||
|
|
||||||
sq = frappe.bean(copy=test_records[0]).insert()
|
sq = frappe.get_doc(copy=test_records[0]).insert()
|
||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, make_purchase_order,
|
self.assertRaises(frappe.ValidationError, make_purchase_order,
|
||||||
sq.name)
|
sq.name)
|
||||||
|
|
||||||
sq = frappe.bean("Supplier Quotation", sq.name)
|
sq = frappe.get_doc("Supplier Quotation", sq.name)
|
||||||
sq.submit()
|
sq.submit()
|
||||||
po = make_purchase_order(sq.name)
|
po = make_purchase_order(sq.name)
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ class TestPurchaseOrder(unittest.TestCase):
|
|||||||
if doc.get("item_code"):
|
if doc.get("item_code"):
|
||||||
doc["schedule_date"] = "2013-04-12"
|
doc["schedule_date"] = "2013-04-12"
|
||||||
|
|
||||||
frappe.bean(po).insert()
|
frappe.get_doc(po).insert()
|
||||||
|
|
||||||
test_records = [
|
test_records = [
|
||||||
[
|
[
|
||||||
|
@ -118,7 +118,7 @@ class AccountsController(TransactionBase):
|
|||||||
tax_doctype = self.meta.get_field(tax_parentfield).options
|
tax_doctype = self.meta.get_field(tax_parentfield).options
|
||||||
|
|
||||||
from frappe.model import default_fields
|
from frappe.model import default_fields
|
||||||
tax_master = frappe.bean(tax_master_doctype, self.get(tax_master_field))
|
tax_master = frappe.get_doc(tax_master_doctype, self.get(tax_master_field))
|
||||||
|
|
||||||
for i, tax in enumerate(tax_master.get(tax_parentfield)):
|
for i, tax in enumerate(tax_master.get(tax_parentfield)):
|
||||||
for fieldname in default_fields:
|
for fieldname in default_fields:
|
||||||
|
@ -35,7 +35,7 @@ class SellingController(StockController):
|
|||||||
if self.customer:
|
if self.customer:
|
||||||
from erpnext.accounts.party import _get_party_details
|
from erpnext.accounts.party import _get_party_details
|
||||||
self.update_if_missing(_get_party_details(self.customer,
|
self.update_if_missing(_get_party_details(self.customer,
|
||||||
ignore_permissions=self.bean.ignore_permissions))
|
ignore_permissions=self.ignore_permissions))
|
||||||
|
|
||||||
elif self.lead:
|
elif self.lead:
|
||||||
from erpnext.selling.doctype.lead.lead import get_lead_details
|
from erpnext.selling.doctype.lead.lead import get_lead_details
|
||||||
@ -47,7 +47,7 @@ class SellingController(StockController):
|
|||||||
|
|
||||||
def apply_shipping_rule(self):
|
def apply_shipping_rule(self):
|
||||||
if self.shipping_rule:
|
if self.shipping_rule:
|
||||||
shipping_rule = frappe.bean("Shipping Rule", self.shipping_rule)
|
shipping_rule = frappe.get_doc("Shipping Rule", self.shipping_rule)
|
||||||
value = self.net_total
|
value = self.net_total
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
@ -274,7 +274,7 @@ class SellingController(StockController):
|
|||||||
total_outstanding = total_outstanding[0][0] if total_outstanding else 0
|
total_outstanding = total_outstanding[0][0] if total_outstanding else 0
|
||||||
|
|
||||||
outstanding_including_current = flt(total_outstanding) + flt(grand_total)
|
outstanding_including_current = flt(total_outstanding) + flt(grand_total)
|
||||||
frappe.bean('Account', customer_account).run_method("check_credit_limit",
|
frappe.get_doc('Account', customer_account).run_method("check_credit_limit",
|
||||||
outstanding_including_current)
|
outstanding_including_current)
|
||||||
|
|
||||||
def validate_max_discount(self):
|
def validate_max_discount(self):
|
||||||
|
@ -101,7 +101,7 @@ class Employee(DocListController):
|
|||||||
if not user_wrapper.user_image == self.image:
|
if not user_wrapper.user_image == self.image:
|
||||||
user_wrapper.user_image = self.image
|
user_wrapper.user_image = self.image
|
||||||
try:
|
try:
|
||||||
frappe.doc({
|
frappe.get_doc({
|
||||||
"doctype": "File Data",
|
"doctype": "File Data",
|
||||||
"file_name": self.image,
|
"file_name": self.image,
|
||||||
"attached_to_doctype": "User",
|
"attached_to_doctype": "User",
|
||||||
|
@ -9,7 +9,7 @@ from frappe.core.doctype.communication.communication import _make
|
|||||||
|
|
||||||
class JobsMailbox(POP3Mailbox):
|
class JobsMailbox(POP3Mailbox):
|
||||||
def setup(self, args=None):
|
def setup(self, args=None):
|
||||||
self.settings = args or frappe.doc("Jobs Email Settings", "Jobs Email Settings")
|
self.settings = args or frappe.get_doc("Jobs Email Settings", "Jobs Email Settings")
|
||||||
|
|
||||||
def process_message(self, mail):
|
def process_message(self, mail):
|
||||||
if mail.from_email == self.settings.email_id:
|
if mail.from_email == self.settings.email_id:
|
||||||
@ -18,7 +18,7 @@ class JobsMailbox(POP3Mailbox):
|
|||||||
name = frappe.db.get_value("Job Applicant", {"email_id": mail.from_email},
|
name = frappe.db.get_value("Job Applicant", {"email_id": mail.from_email},
|
||||||
"name")
|
"name")
|
||||||
if name:
|
if name:
|
||||||
applicant = frappe.bean("Job Applicant", name)
|
applicant = frappe.get_doc("Job Applicant", name)
|
||||||
if applicant.status!="Rejected":
|
if applicant.status!="Rejected":
|
||||||
applicant.status = "Open"
|
applicant.status = "Open"
|
||||||
applicant.ignore_permissions = True
|
applicant.ignore_permissions = True
|
||||||
@ -26,7 +26,7 @@ class JobsMailbox(POP3Mailbox):
|
|||||||
else:
|
else:
|
||||||
name = (mail.from_real_name and (mail.from_real_name + " - ") or "") \
|
name = (mail.from_real_name and (mail.from_real_name + " - ") or "") \
|
||||||
+ mail.from_email
|
+ mail.from_email
|
||||||
applicant = frappe.bean({
|
applicant = frappe.get_doc({
|
||||||
"creation": mail.date,
|
"creation": mail.date,
|
||||||
"doctype":"Job Applicant",
|
"doctype":"Job Applicant",
|
||||||
"applicant_name": name,
|
"applicant_name": name,
|
||||||
|
@ -18,7 +18,7 @@ from frappe.model.controller import DocListController
|
|||||||
class LeaveApplication(DocListController):
|
class LeaveApplication(DocListController):
|
||||||
def setup(self):
|
def setup(self):
|
||||||
if frappe.db.exists(self.doctype, self.name):
|
if frappe.db.exists(self.doctype, self.name):
|
||||||
self.previous_doc = frappe.doc(self.doctype, self.name)
|
self.previous_doc = frappe.get_doc(self.doctype, self.name)
|
||||||
else:
|
else:
|
||||||
self.previous_doc = None
|
self.previous_doc = None
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ class LeaveApplication(DocListController):
|
|||||||
(self.leave_type, max_days))
|
(self.leave_type, max_days))
|
||||||
|
|
||||||
def validate_leave_approver(self):
|
def validate_leave_approver(self):
|
||||||
employee = frappe.bean("Employee", self.employee)
|
employee = frappe.get_doc("Employee", self.employee)
|
||||||
leave_approvers = [l.leave_approver for l in
|
leave_approvers = [l.leave_approver for l in
|
||||||
employee.get("employee_leave_approvers")]
|
employee.get("employee_leave_approvers")]
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ class LeaveApplication(DocListController):
|
|||||||
raise_exception=LeaveApproverIdentityError)
|
raise_exception=LeaveApproverIdentityError)
|
||||||
|
|
||||||
def notify_employee(self, status):
|
def notify_employee(self, status):
|
||||||
employee = frappe.doc("Employee", self.employee)
|
employee = frappe.get_doc("Employee", self.employee)
|
||||||
if not employee.user_id:
|
if not employee.user_id:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ class LeaveApplication(DocListController):
|
|||||||
})
|
})
|
||||||
|
|
||||||
def notify_leave_approver(self):
|
def notify_leave_approver(self):
|
||||||
employee = frappe.doc("Employee", self.employee)
|
employee = frappe.get_doc("Employee", self.employee)
|
||||||
|
|
||||||
def _get_message(url=False):
|
def _get_message(url=False):
|
||||||
name = self.name
|
name = self.name
|
||||||
|
@ -23,7 +23,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
def _add_employee_leave_approver(self, employee, leave_approver):
|
def _add_employee_leave_approver(self, employee, leave_approver):
|
||||||
temp_session_user = frappe.session.user
|
temp_session_user = frappe.session.user
|
||||||
frappe.set_user("Administrator")
|
frappe.set_user("Administrator")
|
||||||
employee = frappe.bean("Employee", employee)
|
employee = frappe.get_doc("Employee", employee)
|
||||||
employee.append("employee_leave_approvers", {
|
employee.append("employee_leave_approvers", {
|
||||||
"doctype": "Employee Leave Approver",
|
"doctype": "Employee Leave Approver",
|
||||||
"leave_approver": leave_approver
|
"leave_approver": leave_approver
|
||||||
|
@ -86,7 +86,7 @@ class SalaryManager(Document):
|
|||||||
if not frappe.db.sql("""select name from `tabSalary Slip`
|
if not frappe.db.sql("""select name from `tabSalary Slip`
|
||||||
where docstatus!= 2 and employee = %s and month = %s and fiscal_year = %s and company = %s
|
where docstatus!= 2 and employee = %s and month = %s and fiscal_year = %s and company = %s
|
||||||
""", (emp[0], self.month, self.fiscal_year, self.company)):
|
""", (emp[0], self.month, self.fiscal_year, self.company)):
|
||||||
ss = frappe.bean({
|
ss = frappe.get_doc({
|
||||||
"doctype": "Salary Slip",
|
"doctype": "Salary Slip",
|
||||||
"fiscal_year": self.fiscal_year,
|
"fiscal_year": self.fiscal_year,
|
||||||
"employee": emp[0],
|
"employee": emp[0],
|
||||||
|
@ -9,7 +9,7 @@ class TestSalarySlip(unittest.TestCase):
|
|||||||
frappe.db.sql("""delete from `tabLeave Application`""")
|
frappe.db.sql("""delete from `tabLeave Application`""")
|
||||||
frappe.db.sql("""delete from `tabSalary Slip`""")
|
frappe.db.sql("""delete from `tabSalary Slip`""")
|
||||||
from erpnext.hr.doctype.leave_application.test_leave_application import test_records as leave_applications
|
from erpnext.hr.doctype.leave_application.test_leave_application import test_records as leave_applications
|
||||||
la = frappe.bean(copy=leave_applications[4])
|
la = frappe.get_doc(copy=leave_applications[4])
|
||||||
la.insert()
|
la.insert()
|
||||||
la.status = "Approved"
|
la.status = "Approved"
|
||||||
la.submit()
|
la.submit()
|
||||||
@ -19,7 +19,7 @@ class TestSalarySlip(unittest.TestCase):
|
|||||||
|
|
||||||
def test_salary_slip_with_holidays_included(self):
|
def test_salary_slip_with_holidays_included(self):
|
||||||
frappe.db.set_value("HR Settings", "HR Settings", "include_holidays_in_total_working_days", 1)
|
frappe.db.set_value("HR Settings", "HR Settings", "include_holidays_in_total_working_days", 1)
|
||||||
ss = frappe.bean(copy=test_records[0])
|
ss = frappe.get_doc(copy=test_records[0])
|
||||||
ss.insert()
|
ss.insert()
|
||||||
self.assertEquals(ss.total_days_in_month, 31)
|
self.assertEquals(ss.total_days_in_month, 31)
|
||||||
self.assertEquals(ss.payment_days, 30)
|
self.assertEquals(ss.payment_days, 30)
|
||||||
@ -31,7 +31,7 @@ class TestSalarySlip(unittest.TestCase):
|
|||||||
self.assertEquals(ss.net_pay, 14867.74)
|
self.assertEquals(ss.net_pay, 14867.74)
|
||||||
|
|
||||||
def test_salary_slip_with_holidays_excluded(self):
|
def test_salary_slip_with_holidays_excluded(self):
|
||||||
ss = frappe.bean(copy=test_records[0])
|
ss = frappe.get_doc(copy=test_records[0])
|
||||||
ss.insert()
|
ss.insert()
|
||||||
self.assertEquals(ss.total_days_in_month, 30)
|
self.assertEquals(ss.total_days_in_month, 30)
|
||||||
self.assertEquals(ss.payment_days, 29)
|
self.assertEquals(ss.payment_days, 29)
|
||||||
|
@ -77,7 +77,7 @@ def get_mapped_doc(source_name, target_doc=None):
|
|||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
def postprocess(source, target):
|
def postprocess(source, target):
|
||||||
sal_slip = frappe.bean(target)
|
sal_slip = frappe.get_doc(target)
|
||||||
sal_slip.run_method("pull_emp_details")
|
sal_slip.run_method("pull_emp_details")
|
||||||
sal_slip.run_method("get_leave_details")
|
sal_slip.run_method("get_leave_details")
|
||||||
sal_slip.run_method("calculate_net_pay")
|
sal_slip.run_method("calculate_net_pay")
|
||||||
|
@ -134,11 +134,11 @@ class Bom(Document):
|
|||||||
})["rate"]
|
})["rate"]
|
||||||
|
|
||||||
if self.docstatus == 0:
|
if self.docstatus == 0:
|
||||||
frappe.bean(self.doclist).save()
|
frappe.get_doc(self.doclist).save()
|
||||||
elif self.docstatus == 1:
|
elif self.docstatus == 1:
|
||||||
self.calculate_cost()
|
self.calculate_cost()
|
||||||
self.update_exploded_items()
|
self.update_exploded_items()
|
||||||
frappe.bean(self.doclist).update_after_submit()
|
frappe.get_doc(self.doclist).update_after_submit()
|
||||||
|
|
||||||
def get_bom_unitcost(self, bom_no):
|
def get_bom_unitcost(self, bom_no):
|
||||||
bom = frappe.db.sql("""select name, total_cost/quantity as unit_cost from `tabBOM`
|
bom = frappe.db.sql("""select name, total_cost/quantity as unit_cost from `tabBOM`
|
||||||
|
@ -152,7 +152,7 @@ def get_item_details(item):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_stock_entry(production_order_id, purpose):
|
def make_stock_entry(production_order_id, purpose):
|
||||||
production_order = frappe.bean("Production Order", production_order_id)
|
production_order = frappe.get_doc("Production Order", production_order_id)
|
||||||
|
|
||||||
stock_entry = frappe.new_bean("Stock Entry")
|
stock_entry = frappe.new_bean("Stock Entry")
|
||||||
stock_entry.purpose = purpose
|
stock_entry.purpose = purpose
|
||||||
|
@ -17,22 +17,22 @@ class TestProductionOrder(unittest.TestCase):
|
|||||||
frappe.db.sql("""delete from `tabBin`""")
|
frappe.db.sql("""delete from `tabBin`""")
|
||||||
frappe.db.sql("""delete from `tabGL Entry`""")
|
frappe.db.sql("""delete from `tabGL Entry`""")
|
||||||
|
|
||||||
pro_bean = frappe.bean(copy = test_records[0])
|
pro_bean = frappe.get_doc(copy = test_records[0])
|
||||||
pro_bean.insert()
|
pro_bean.insert()
|
||||||
pro_bean.submit()
|
pro_bean.submit()
|
||||||
|
|
||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import test_records as se_test_records
|
from erpnext.stock.doctype.stock_entry.test_stock_entry import test_records as se_test_records
|
||||||
mr1 = frappe.bean(copy = se_test_records[0])
|
mr1 = frappe.get_doc(copy = se_test_records[0])
|
||||||
mr1.insert()
|
mr1.insert()
|
||||||
mr1.submit()
|
mr1.submit()
|
||||||
|
|
||||||
mr2 = frappe.bean(copy = se_test_records[0])
|
mr2 = frappe.get_doc(copy = se_test_records[0])
|
||||||
mr2.doclist[1].item_code = "_Test Item Home Desktop 100"
|
mr2.doclist[1].item_code = "_Test Item Home Desktop 100"
|
||||||
mr2.insert()
|
mr2.insert()
|
||||||
mr2.submit()
|
mr2.submit()
|
||||||
|
|
||||||
stock_entry = make_stock_entry(pro_bean.name, "Manufacture/Repack")
|
stock_entry = make_stock_entry(pro_bean.name, "Manufacture/Repack")
|
||||||
stock_entry = frappe.bean(stock_entry)
|
stock_entry = frappe.get_doc(stock_entry)
|
||||||
stock_entry.fiscal_year = "_Test Fiscal Year 2013"
|
stock_entry.fiscal_year = "_Test Fiscal Year 2013"
|
||||||
stock_entry.fg_completed_qty = 4
|
stock_entry.fg_completed_qty = 4
|
||||||
stock_entry.posting_date = "2013-05-12"
|
stock_entry.posting_date = "2013-05-12"
|
||||||
@ -52,7 +52,7 @@ class TestProductionOrder(unittest.TestCase):
|
|||||||
pro_order = self.test_planned_qty()
|
pro_order = self.test_planned_qty()
|
||||||
|
|
||||||
stock_entry = make_stock_entry(pro_order, "Manufacture/Repack")
|
stock_entry = make_stock_entry(pro_order, "Manufacture/Repack")
|
||||||
stock_entry = frappe.bean(stock_entry)
|
stock_entry = frappe.get_doc(stock_entry)
|
||||||
stock_entry.posting_date = "2013-05-12"
|
stock_entry.posting_date = "2013-05-12"
|
||||||
stock_entry.fiscal_year = "_Test Fiscal Year 2013"
|
stock_entry.fiscal_year = "_Test Fiscal Year 2013"
|
||||||
stock_entry.fg_completed_qty = 15
|
stock_entry.fg_completed_qty = 15
|
||||||
|
@ -365,7 +365,7 @@ class ProductionPlanningTool(Document):
|
|||||||
purchase_request_list = []
|
purchase_request_list = []
|
||||||
if items_to_be_requested:
|
if items_to_be_requested:
|
||||||
for item in items_to_be_requested:
|
for item in items_to_be_requested:
|
||||||
item_wrapper = frappe.bean("Item", item)
|
item_wrapper = frappe.get_doc("Item", item)
|
||||||
pr_doc = frappe.get_doc({
|
pr_doc = frappe.get_doc({
|
||||||
"doctype": "Material Request",
|
"doctype": "Material Request",
|
||||||
"__islocal": 1,
|
"__islocal": 1,
|
||||||
|
@ -17,7 +17,7 @@ def execute():
|
|||||||
else:
|
else:
|
||||||
item_group = d.item_group
|
item_group = d.item_group
|
||||||
|
|
||||||
frappe.bean([{
|
frappe.get_doc([{
|
||||||
"doctype": "Pricing Rule",
|
"doctype": "Pricing Rule",
|
||||||
"apply_on": "Item Group",
|
"apply_on": "Item Group",
|
||||||
"item_group": item_group,
|
"item_group": item_group,
|
||||||
|
@ -4,8 +4,8 @@ def execute():
|
|||||||
frappe.reload_doc("website", "doctype", "contact_us_settings")
|
frappe.reload_doc("website", "doctype", "contact_us_settings")
|
||||||
address = frappe.db.get_value("Contact Us Settings", None, "address")
|
address = frappe.db.get_value("Contact Us Settings", None, "address")
|
||||||
if address:
|
if address:
|
||||||
address = frappe.doc("Address", address)
|
address = frappe.get_doc("Address", address)
|
||||||
contact = frappe.bean("Contact Us Settings", "Contact Us Settings")
|
contact = frappe.get_doc("Contact Us Settings", "Contact Us Settings")
|
||||||
for f in ("address_title", "address_line1", "address_line2", "city", "state", "country", "pincode"):
|
for f in ("address_title", "address_line1", "address_line2", "city", "state", "country", "pincode"):
|
||||||
contact.set(f, address.get(f))
|
contact.set(f, address.get(f))
|
||||||
|
|
||||||
|
@ -8,13 +8,13 @@ def execute():
|
|||||||
frappe.reload_doc("core", "doctype", "outgoing_email_settings")
|
frappe.reload_doc("core", "doctype", "outgoing_email_settings")
|
||||||
frappe.reload_doc("support", "doctype", "support_email_settings")
|
frappe.reload_doc("support", "doctype", "support_email_settings")
|
||||||
|
|
||||||
email_settings = frappe.bean("Email Settings")
|
email_settings = frappe.get_doc("Email Settings")
|
||||||
map_outgoing_email_settings(email_settings)
|
map_outgoing_email_settings(email_settings)
|
||||||
map_support_email_settings(email_settings)
|
map_support_email_settings(email_settings)
|
||||||
frappe.delete_doc("Doctype", "Email Settings")
|
frappe.delete_doc("Doctype", "Email Settings")
|
||||||
|
|
||||||
def map_outgoing_email_settings(email_settings):
|
def map_outgoing_email_settings(email_settings):
|
||||||
outgoing_email_settings = frappe.bean("Outgoing Email Settings")
|
outgoing_email_settings = frappe.get_doc("Outgoing Email Settings")
|
||||||
for fieldname in (("outgoing_mail_server", "mail_server"),
|
for fieldname in (("outgoing_mail_server", "mail_server"),
|
||||||
"use_ssl", "mail_port", "mail_login", "mail_password",
|
"use_ssl", "mail_port", "mail_login", "mail_password",
|
||||||
"always_use_login_id_as_sender",
|
"always_use_login_id_as_sender",
|
||||||
@ -30,7 +30,7 @@ def map_outgoing_email_settings(email_settings):
|
|||||||
outgoing_email_settings.save()
|
outgoing_email_settings.save()
|
||||||
|
|
||||||
def map_support_email_settings(email_settings):
|
def map_support_email_settings(email_settings):
|
||||||
support_email_settings = frappe.bean("Support Email Settings")
|
support_email_settings = frappe.get_doc("Support Email Settings")
|
||||||
|
|
||||||
for fieldname in ("sync_support_mails", "support_email",
|
for fieldname in ("sync_support_mails", "support_email",
|
||||||
("support_host", "mail_server"),
|
("support_host", "mail_server"),
|
||||||
|
@ -87,7 +87,7 @@ def add_employee_restrictions_to_leave_approver():
|
|||||||
where `tabEmployee Leave Approver`.parent=`tabEmployee`.name)
|
where `tabEmployee Leave Approver`.parent=`tabEmployee`.name)
|
||||||
or ifnull(`reports_to`, '')!=''"""):
|
or ifnull(`reports_to`, '')!=''"""):
|
||||||
|
|
||||||
frappe.bean("Employee", employee).save()
|
frappe.get_doc("Employee", employee).save()
|
||||||
|
|
||||||
def update_permissions():
|
def update_permissions():
|
||||||
# clear match conditions other than owner
|
# clear match conditions other than owner
|
||||||
|
@ -47,7 +47,7 @@ class Project(Document):
|
|||||||
for milestone in self.get("project_milestones"):
|
for milestone in self.get("project_milestones"):
|
||||||
if milestone.milestone_date:
|
if milestone.milestone_date:
|
||||||
description = (milestone.milestone or "Milestone") + " for " + self.name
|
description = (milestone.milestone or "Milestone") + " for " + self.name
|
||||||
frappe.bean({
|
frappe.get_doc({
|
||||||
"doctype": "Event",
|
"doctype": "Event",
|
||||||
"owner": self.owner,
|
"owner": self.owner,
|
||||||
"subject": description,
|
"subject": description,
|
||||||
|
@ -44,7 +44,7 @@ class Task(Document):
|
|||||||
def on_update(self):
|
def on_update(self):
|
||||||
"""update percent complete in project"""
|
"""update percent complete in project"""
|
||||||
if self.project:
|
if self.project:
|
||||||
project = frappe.bean("Project", self.project)
|
project = frappe.get_doc("Project", self.project)
|
||||||
project.run_method("update_percent_complete")
|
project.run_method("update_percent_complete")
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
@ -8,7 +8,7 @@ from erpnext.projects.doctype.time_log.time_log import OverlapError
|
|||||||
|
|
||||||
class TestTimeLog(unittest.TestCase):
|
class TestTimeLog(unittest.TestCase):
|
||||||
def test_duplication(self):
|
def test_duplication(self):
|
||||||
ts = frappe.bean(frappe.copy_doc(test_records[0]))
|
ts = frappe.get_doc(frappe.copy_doc(test_records[0]))
|
||||||
self.assertRaises(OverlapError, ts.insert)
|
self.assertRaises(OverlapError, ts.insert)
|
||||||
|
|
||||||
test_records = [[{
|
test_records = [[{
|
||||||
|
@ -6,7 +6,7 @@ import frappe, unittest
|
|||||||
class TimeLogBatchTest(unittest.TestCase):
|
class TimeLogBatchTest(unittest.TestCase):
|
||||||
def test_time_log_status(self):
|
def test_time_log_status(self):
|
||||||
from erpnext.projects.doctype.time_log.test_time_log import test_records as time_log_records
|
from erpnext.projects.doctype.time_log.test_time_log import test_records as time_log_records
|
||||||
time_log = frappe.bean(copy=time_log_records[0])
|
time_log = frappe.get_doc(copy=time_log_records[0])
|
||||||
time_log.update({
|
time_log.update({
|
||||||
"from_time": "2013-01-02 10:00:00.000000",
|
"from_time": "2013-01-02 10:00:00.000000",
|
||||||
"to_time": "2013-01-02 11:00:00.000000",
|
"to_time": "2013-01-02 11:00:00.000000",
|
||||||
@ -16,7 +16,7 @@ class TimeLogBatchTest(unittest.TestCase):
|
|||||||
time_log.submit()
|
time_log.submit()
|
||||||
|
|
||||||
self.assertEquals(frappe.db.get_value("Time Log", time_log.name, "status"), "Submitted")
|
self.assertEquals(frappe.db.get_value("Time Log", time_log.name, "status"), "Submitted")
|
||||||
tlb = frappe.bean(copy=test_records[0])
|
tlb = frappe.get_doc(copy=test_records[0])
|
||||||
tlb.doclist[1].time_log = time_log.name
|
tlb.doclist[1].time_log = time_log.name
|
||||||
tlb.insert()
|
tlb.insert()
|
||||||
tlb.submit()
|
tlb.submit()
|
||||||
|
@ -15,7 +15,7 @@ class TimeLogBatch(Document):
|
|||||||
self.set_status()
|
self.set_status()
|
||||||
self.total_hours = 0.0
|
self.total_hours = 0.0
|
||||||
for d in self.doclist.get({"doctype":"Time Log Batch Detail"}):
|
for d in self.doclist.get({"doctype":"Time Log Batch Detail"}):
|
||||||
tl = frappe.doc("Time Log", d.time_log)
|
tl = frappe.get_doc("Time Log", d.time_log)
|
||||||
self.update_time_log_values(d, tl)
|
self.update_time_log_values(d, tl)
|
||||||
self.validate_time_log_is_submitted(tl)
|
self.validate_time_log_is_submitted(tl)
|
||||||
self.total_hours += float(tl.hours or 0.0)
|
self.total_hours += float(tl.hours or 0.0)
|
||||||
@ -54,7 +54,7 @@ class TimeLogBatch(Document):
|
|||||||
def update_status(self, time_log_batch):
|
def update_status(self, time_log_batch):
|
||||||
self.set_status()
|
self.set_status()
|
||||||
for d in self.doclist.get({"doctype":"Time Log Batch Detail"}):
|
for d in self.doclist.get({"doctype":"Time Log Batch Detail"}):
|
||||||
tl = frappe.bean("Time Log", d.time_log)
|
tl = frappe.get_doc("Time Log", d.time_log)
|
||||||
tl.time_log_batch = time_log_batch
|
tl.time_log_batch = time_log_batch
|
||||||
tl.sales_invoice = self.sales_invoice
|
tl.sales_invoice = self.sales_invoice
|
||||||
tl.update_after_submit()
|
tl.update_after_submit()
|
@ -14,7 +14,7 @@ def add_sales_communication(subject, content, sender, real_name, mail=None,
|
|||||||
|
|
||||||
if not (lead_name or contact_name):
|
if not (lead_name or contact_name):
|
||||||
# none, create a new Lead
|
# none, create a new Lead
|
||||||
lead = frappe.bean({
|
lead = frappe.get_doc({
|
||||||
"doctype":"Lead",
|
"doctype":"Lead",
|
||||||
"lead_name": real_name or sender,
|
"lead_name": real_name or sender,
|
||||||
"email_id": sender,
|
"email_id": sender,
|
||||||
@ -34,12 +34,12 @@ def add_sales_communication(subject, content, sender, real_name, mail=None,
|
|||||||
|
|
||||||
if mail:
|
if mail:
|
||||||
# save attachments to parent if from mail
|
# save attachments to parent if from mail
|
||||||
bean = frappe.bean(parent_doctype, parent_name)
|
bean = frappe.get_doc(parent_doctype, parent_name)
|
||||||
mail.save_attachments_in_doc(bean.doc)
|
mail.save_attachments_in_doc(bean.doc)
|
||||||
|
|
||||||
class SalesMailbox(POP3Mailbox):
|
class SalesMailbox(POP3Mailbox):
|
||||||
def setup(self, args=None):
|
def setup(self, args=None):
|
||||||
self.settings = args or frappe.doc("Sales Email Settings", "Sales Email Settings")
|
self.settings = args or frappe.get_doc("Sales Email Settings", "Sales Email Settings")
|
||||||
|
|
||||||
def process_message(self, mail):
|
def process_message(self, mail):
|
||||||
if mail.from_email == self.settings.email_id:
|
if mail.from_email == self.settings.email_id:
|
||||||
|
@ -127,7 +127,7 @@ def get_lead_details(lead):
|
|||||||
from erpnext.accounts.party import set_address_details
|
from erpnext.accounts.party import set_address_details
|
||||||
out = frappe._dict()
|
out = frappe._dict()
|
||||||
|
|
||||||
lead_bean = frappe.bean("Lead", lead)
|
lead_bean = frappe.get_doc("Lead", lead)
|
||||||
lead = lead_bean.doc
|
lead = lead_bean.doc
|
||||||
|
|
||||||
out.update({
|
out.update({
|
||||||
|
@ -28,5 +28,5 @@ class TestLead(unittest.TestCase):
|
|||||||
|
|
||||||
customer[0]["company"] = "_Test Company"
|
customer[0]["company"] = "_Test Company"
|
||||||
customer[0]["customer_group"] = "_Test Customer Group"
|
customer[0]["customer_group"] = "_Test Customer Group"
|
||||||
frappe.bean(customer).insert()
|
frappe.get_doc(customer).insert()
|
||||||
|
|
@ -109,7 +109,7 @@ class Opportunity(TransactionBase):
|
|||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
if self.lead:
|
if self.lead:
|
||||||
frappe.bean("Lead", self.lead).get_controller().set_status(update=True)
|
frappe.get_doc("Lead", self.lead).set_status(update=True)
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
if self.has_quotation():
|
if self.has_quotation():
|
||||||
@ -134,7 +134,7 @@ def make_quotation(source_name, target_doc=None):
|
|||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
quotation = frappe.bean(target)
|
quotation = frappe.get_doc(target)
|
||||||
quotation.run_method("onload_post_render")
|
quotation.run_method("onload_post_render")
|
||||||
quotation.run_method("calculate_taxes_and_totals")
|
quotation.run_method("calculate_taxes_and_totals")
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class Quotation(SellingController):
|
|||||||
|
|
||||||
def update_opportunity(self):
|
def update_opportunity(self):
|
||||||
for opportunity in self.doclist.get_distinct_values("prevdoc_docname"):
|
for opportunity in self.doclist.get_distinct_values("prevdoc_docname"):
|
||||||
frappe.bean("Opportunity", opportunity).get_controller().set_status(update=True)
|
frappe.get_doc("Opportunity", opportunity).set_status(update=True)
|
||||||
|
|
||||||
def declare_order_lost(self, arg):
|
def declare_order_lost(self, arg):
|
||||||
if not self.has_sales_order():
|
if not self.has_sales_order():
|
||||||
@ -108,7 +108,7 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False):
|
|||||||
target[0].customer = customer.name
|
target[0].customer = customer.name
|
||||||
target[0].customer_name = customer.customer_name
|
target[0].customer_name = customer.customer_name
|
||||||
|
|
||||||
si = frappe.bean(target)
|
si = frappe.get_doc(target)
|
||||||
si.ignore_permissions = ignore_permissions
|
si.ignore_permissions = ignore_permissions
|
||||||
si.run_method("onload_post_render")
|
si.run_method("onload_post_render")
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ def _make_customer(source_name, ignore_permissions=False):
|
|||||||
if not customer_name:
|
if not customer_name:
|
||||||
from erpnext.selling.doctype.lead.lead import _make_customer
|
from erpnext.selling.doctype.lead.lead import _make_customer
|
||||||
customer_doclist = _make_customer(lead_name, ignore_permissions=ignore_permissions)
|
customer_doclist = _make_customer(lead_name, ignore_permissions=ignore_permissions)
|
||||||
customer = frappe.bean(customer_doclist)
|
customer = frappe.get_doc(customer_doclist)
|
||||||
customer.ignore_permissions = ignore_permissions
|
customer.ignore_permissions = ignore_permissions
|
||||||
if quotation[1] == "Shopping Cart":
|
if quotation[1] == "Shopping Cart":
|
||||||
customer.customer_group = frappe.db.get_value("Shopping Cart Settings", None,
|
customer.customer_group = frappe.db.get_value("Shopping Cart Settings", None,
|
||||||
|
@ -11,7 +11,7 @@ class TestQuotation(unittest.TestCase):
|
|||||||
def test_make_sales_order(self):
|
def test_make_sales_order(self):
|
||||||
from erpnext.selling.doctype.quotation.quotation import make_sales_order
|
from erpnext.selling.doctype.quotation.quotation import make_sales_order
|
||||||
|
|
||||||
quotation = frappe.bean(copy=test_records[0])
|
quotation = frappe.get_doc(copy=test_records[0])
|
||||||
quotation.insert()
|
quotation.insert()
|
||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, make_sales_order, quotation.name)
|
self.assertRaises(frappe.ValidationError, make_sales_order, quotation.name)
|
||||||
@ -29,7 +29,7 @@ class TestQuotation(unittest.TestCase):
|
|||||||
sales_order[0]["delivery_date"] = "2014-01-01"
|
sales_order[0]["delivery_date"] = "2014-01-01"
|
||||||
sales_order[0]["naming_series"] = "_T-Quotation-"
|
sales_order[0]["naming_series"] = "_T-Quotation-"
|
||||||
sales_order[0]["transaction_date"] = "2013-05-12"
|
sales_order[0]["transaction_date"] = "2013-05-12"
|
||||||
frappe.bean(sales_order).insert()
|
frappe.get_doc(sales_order).insert()
|
||||||
|
|
||||||
|
|
||||||
test_records = [
|
test_records = [
|
||||||
|
@ -150,11 +150,11 @@ class SalesOrder(SellingController):
|
|||||||
|
|
||||||
def update_prevdoc_status(self, flag):
|
def update_prevdoc_status(self, flag):
|
||||||
for quotation in self.doclist.get_distinct_values("prevdoc_docname"):
|
for quotation in self.doclist.get_distinct_values("prevdoc_docname"):
|
||||||
bean = frappe.bean("Quotation", quotation)
|
bean = frappe.get_doc("Quotation", quotation)
|
||||||
if bean.docstatus==2:
|
if bean.docstatus==2:
|
||||||
frappe.throw(quotation + ": " + frappe._("Quotation is cancelled."))
|
frappe.throw(quotation + ": " + frappe._("Quotation is cancelled."))
|
||||||
|
|
||||||
bean.get_controller().set_status(update=True)
|
bean.set_status(update=True)
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
self.update_stock_ledger(update_stock = 1)
|
self.update_stock_ledger(update_stock = 1)
|
||||||
@ -253,7 +253,7 @@ class SalesOrder(SellingController):
|
|||||||
return "order" if self.docstatus==1 else None
|
return "order" if self.docstatus==1 else None
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
bean = frappe.bean(target)
|
bean = frappe.get_doc(target)
|
||||||
bean.run_method("onload_post_render")
|
bean.run_method("onload_post_render")
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
@ -322,7 +322,7 @@ def make_delivery_note(source_name, target_doc=None):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_sales_invoice(source_name, target_doc=None):
|
def make_sales_invoice(source_name, target_doc=None):
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
bean = frappe.bean(target)
|
bean = frappe.get_doc(target)
|
||||||
bean.is_pos = 0
|
bean.is_pos = 0
|
||||||
bean.run_method("onload_post_render")
|
bean.run_method("onload_post_render")
|
||||||
|
|
||||||
|
@ -12,12 +12,12 @@ class TestSalesOrder(unittest.TestCase):
|
|||||||
def test_make_material_request(self):
|
def test_make_material_request(self):
|
||||||
from erpnext.selling.doctype.sales_order.sales_order import make_material_request
|
from erpnext.selling.doctype.sales_order.sales_order import make_material_request
|
||||||
|
|
||||||
so = frappe.bean(copy=test_records[0]).insert()
|
so = frappe.get_doc(copy=test_records[0]).insert()
|
||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, make_material_request,
|
self.assertRaises(frappe.ValidationError, make_material_request,
|
||||||
so.name)
|
so.name)
|
||||||
|
|
||||||
sales_order = frappe.bean("Sales Order", so.name)
|
sales_order = frappe.get_doc("Sales Order", so.name)
|
||||||
sales_order.submit()
|
sales_order.submit()
|
||||||
mr = make_material_request(so.name)
|
mr = make_material_request(so.name)
|
||||||
|
|
||||||
@ -27,12 +27,12 @@ class TestSalesOrder(unittest.TestCase):
|
|||||||
def test_make_delivery_note(self):
|
def test_make_delivery_note(self):
|
||||||
from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note
|
from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note
|
||||||
|
|
||||||
so = frappe.bean(copy=test_records[0]).insert()
|
so = frappe.get_doc(copy=test_records[0]).insert()
|
||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, make_delivery_note,
|
self.assertRaises(frappe.ValidationError, make_delivery_note,
|
||||||
so.name)
|
so.name)
|
||||||
|
|
||||||
sales_order = frappe.bean("Sales Order", so.name)
|
sales_order = frappe.get_doc("Sales Order", so.name)
|
||||||
sales_order.submit()
|
sales_order.submit()
|
||||||
dn = make_delivery_note(so.name)
|
dn = make_delivery_note(so.name)
|
||||||
|
|
||||||
@ -42,12 +42,12 @@ class TestSalesOrder(unittest.TestCase):
|
|||||||
def test_make_sales_invoice(self):
|
def test_make_sales_invoice(self):
|
||||||
from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice
|
from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice
|
||||||
|
|
||||||
so = frappe.bean(copy=test_records[0]).insert()
|
so = frappe.get_doc(copy=test_records[0]).insert()
|
||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, make_sales_invoice,
|
self.assertRaises(frappe.ValidationError, make_sales_invoice,
|
||||||
so.name)
|
so.name)
|
||||||
|
|
||||||
sales_order = frappe.bean("Sales Order", so.name)
|
sales_order = frappe.get_doc("Sales Order", so.name)
|
||||||
sales_order.submit()
|
sales_order.submit()
|
||||||
si = make_sales_invoice(so.name)
|
si = make_sales_invoice(so.name)
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ class TestSalesOrder(unittest.TestCase):
|
|||||||
self.assertEquals(len(si), len(sales_order.doclist))
|
self.assertEquals(len(si), len(sales_order.doclist))
|
||||||
self.assertEquals(len([d for d in si if d["doctype"]=="Sales Invoice Item"]), 1)
|
self.assertEquals(len([d for d in si if d["doctype"]=="Sales Invoice Item"]), 1)
|
||||||
|
|
||||||
si = frappe.bean(si)
|
si = frappe.get_doc(si)
|
||||||
si.posting_date = "2013-10-10"
|
si.posting_date = "2013-10-10"
|
||||||
si.insert()
|
si.insert()
|
||||||
si.submit()
|
si.submit()
|
||||||
@ -68,7 +68,7 @@ class TestSalesOrder(unittest.TestCase):
|
|||||||
if not so_doclist:
|
if not so_doclist:
|
||||||
so_doclist = test_records[0]
|
so_doclist = test_records[0]
|
||||||
|
|
||||||
w = frappe.bean(copy=so_doclist)
|
w = frappe.get_doc(copy=so_doclist)
|
||||||
w.insert()
|
w.insert()
|
||||||
w.submit()
|
w.submit()
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ class TestSalesOrder(unittest.TestCase):
|
|||||||
|
|
||||||
_insert_purchase_receipt(so.doclist[1].item_code)
|
_insert_purchase_receipt(so.doclist[1].item_code)
|
||||||
|
|
||||||
dn = frappe.bean(frappe.copy_doc(dn_test_records[0]))
|
dn = frappe.get_doc(frappe.copy_doc(dn_test_records[0]))
|
||||||
dn.doclist[1].item_code = so.doclist[1].item_code
|
dn.doclist[1].item_code = so.doclist[1].item_code
|
||||||
dn.doclist[1].against_sales_order = so.name
|
dn.doclist[1].against_sales_order = so.name
|
||||||
dn.doclist[1].prevdoc_detail_docname = so.doclist[1].name
|
dn.doclist[1].prevdoc_detail_docname = so.doclist[1].name
|
||||||
@ -281,16 +281,16 @@ class TestSalesOrder(unittest.TestCase):
|
|||||||
|
|
||||||
def test_warehouse_user(self):
|
def test_warehouse_user(self):
|
||||||
frappe.defaults.add_default("Warehouse", "_Test Warehouse 1 - _TC1", "test@example.com", "Restriction")
|
frappe.defaults.add_default("Warehouse", "_Test Warehouse 1 - _TC1", "test@example.com", "Restriction")
|
||||||
frappe.bean("User", "test@example.com").get_controller()\
|
frappe.get_doc("User", "test@example.com").get_controller()\
|
||||||
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
||||||
|
|
||||||
frappe.bean("User", "test2@example.com").get_controller()\
|
frappe.get_doc("User", "test2@example.com").get_controller()\
|
||||||
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
||||||
|
|
||||||
frappe.set_user("test@example.com")
|
frappe.set_user("test@example.com")
|
||||||
|
|
||||||
from frappe.model.bean import BeanPermissionError
|
from frappe.model.bean import BeanPermissionError
|
||||||
so = frappe.bean(copy = test_records[0])
|
so = frappe.get_doc(copy = test_records[0])
|
||||||
so.company = "_Test Company 1"
|
so.company = "_Test Company 1"
|
||||||
so.conversion_rate = 0.02
|
so.conversion_rate = 0.02
|
||||||
so.plc_conversion_rate = 0.02
|
so.plc_conversion_rate = 0.02
|
||||||
|
@ -35,4 +35,4 @@ def add_node():
|
|||||||
if ctype == "Sales Person":
|
if ctype == "Sales Person":
|
||||||
doclist[0]["employee"] = frappe.form_dict.get('employee')
|
doclist[0]["employee"] = frappe.form_dict.get('employee')
|
||||||
|
|
||||||
frappe.bean(doclist).save()
|
frappe.get_doc(doclist).save()
|
@ -61,7 +61,7 @@ class Company(Document):
|
|||||||
stock_group = frappe.db.get_value("Account", {"account_type": "Stock",
|
stock_group = frappe.db.get_value("Account", {"account_type": "Stock",
|
||||||
"group_or_ledger": "Group"})
|
"group_or_ledger": "Group"})
|
||||||
if stock_group:
|
if stock_group:
|
||||||
frappe.bean({
|
frappe.get_doc({
|
||||||
"doctype":"Warehouse",
|
"doctype":"Warehouse",
|
||||||
"warehouse_name": whname,
|
"warehouse_name": whname,
|
||||||
"company": self.name,
|
"company": self.name,
|
||||||
@ -73,7 +73,7 @@ class Company(Document):
|
|||||||
not frappe.db.sql("select name from tabCompany where name!=%s", self.name):
|
not frappe.db.sql("select name from tabCompany where name!=%s", self.name):
|
||||||
import os
|
import os
|
||||||
with open(os.path.join(os.path.dirname(__file__), "sample_home_page.html"), "r") as webfile:
|
with open(os.path.join(os.path.dirname(__file__), "sample_home_page.html"), "r") as webfile:
|
||||||
webpage = frappe.bean({
|
webpage = frappe.get_doc({
|
||||||
"doctype": "Web Page",
|
"doctype": "Web Page",
|
||||||
"title": self.name + " Home",
|
"title": self.name + " Home",
|
||||||
"published": 1,
|
"published": 1,
|
||||||
@ -82,7 +82,7 @@ class Company(Document):
|
|||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
# update in home page in settings
|
# update in home page in settings
|
||||||
website_settings = frappe.bean("Website Settings", "Website Settings")
|
website_settings = frappe.get_doc("Website Settings", "Website Settings")
|
||||||
website_settings.home_page = webpage.name
|
website_settings.home_page = webpage.name
|
||||||
website_settings.brand_html = self.name
|
website_settings.brand_html = self.name
|
||||||
website_settings.copyright = self.name
|
website_settings.copyright = self.name
|
||||||
@ -97,7 +97,7 @@ class Company(Document):
|
|||||||
"url": "blog"
|
"url": "blog"
|
||||||
})
|
})
|
||||||
website_settings.save()
|
website_settings.save()
|
||||||
style_settings = frappe.bean("Style Settings", "Style Settings")
|
style_settings = frappe.get_doc("Style Settings", "Style Settings")
|
||||||
style_settings.top_bar_background = "F2F2F2"
|
style_settings.top_bar_background = "F2F2F2"
|
||||||
style_settings.font_size = "15px"
|
style_settings.font_size = "15px"
|
||||||
style_settings.save()
|
style_settings.save()
|
||||||
@ -111,11 +111,11 @@ class Company(Document):
|
|||||||
frappe.db.set(self, "payables_group", "Accounts Payable - " + self.abbr)
|
frappe.db.set(self, "payables_group", "Accounts Payable - " + self.abbr)
|
||||||
|
|
||||||
def import_chart_of_account(self):
|
def import_chart_of_account(self):
|
||||||
chart = frappe.bean("Chart of Accounts", self.chart_of_accounts)
|
chart = frappe.get_doc("Chart of Accounts", self.chart_of_accounts)
|
||||||
chart.make_controller().create_accounts(self.name)
|
chart.make_controller().create_accounts(self.name)
|
||||||
|
|
||||||
def add_acc(self,lst):
|
def add_acc(self,lst):
|
||||||
account = frappe.bean({
|
account = frappe.get_doc({
|
||||||
"doctype": "Account",
|
"doctype": "Account",
|
||||||
"freeze_account": "No",
|
"freeze_account": "No",
|
||||||
"master_type": "",
|
"master_type": "",
|
||||||
@ -163,7 +163,7 @@ class Company(Document):
|
|||||||
]
|
]
|
||||||
for cc in cc_list:
|
for cc in cc_list:
|
||||||
cc.update({"doctype": "Cost Center"})
|
cc.update({"doctype": "Cost Center"})
|
||||||
cc_bean = frappe.bean(cc)
|
cc_bean = frappe.get_doc(cc)
|
||||||
cc_bean.ignore_permissions = True
|
cc_bean.ignore_permissions = True
|
||||||
|
|
||||||
if cc.get("cost_center_name") == self.name:
|
if cc.get("cost_center_name") == self.name:
|
||||||
|
@ -13,7 +13,7 @@ class TestCompany(unittest.TestCase):
|
|||||||
print "Country: ", country
|
print "Country: ", country
|
||||||
print "Chart Name: ", chart_name
|
print "Chart Name: ", chart_name
|
||||||
|
|
||||||
company_bean = frappe.bean({
|
company_bean = frappe.get_doc({
|
||||||
"doctype": "Company",
|
"doctype": "Company",
|
||||||
"company_name": "_Test Company 2",
|
"company_name": "_Test Company 2",
|
||||||
"abbr": "_TC2",
|
"abbr": "_TC2",
|
||||||
|
@ -60,7 +60,7 @@ class GlobalDefaults(Document):
|
|||||||
raise_exception=1)
|
raise_exception=1)
|
||||||
|
|
||||||
def update_control_panel(self):
|
def update_control_panel(self):
|
||||||
cp_bean = frappe.bean("Control Panel")
|
cp_bean = frappe.get_doc("Control Panel")
|
||||||
if self.country:
|
if self.country:
|
||||||
cp_bean.country = self.country
|
cp_bean.country = self.country
|
||||||
if self.time_zone:
|
if self.time_zone:
|
||||||
|
@ -127,7 +127,7 @@ class TestItem(unittest.TestCase):
|
|||||||
return get_no_of_children([item_group], 0)
|
return get_no_of_children([item_group], 0)
|
||||||
|
|
||||||
def test_recursion(self):
|
def test_recursion(self):
|
||||||
group_b = frappe.bean("Item Group", "_Test Item Group B")
|
group_b = frappe.get_doc("Item Group", "_Test Item Group B")
|
||||||
group_b.parent_item_group = "_Test Item Group B - 3"
|
group_b.parent_item_group = "_Test Item Group B - 3"
|
||||||
self.assertRaises(NestedSetRecursionError, group_b.save)
|
self.assertRaises(NestedSetRecursionError, group_b.save)
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ class TestItem(unittest.TestCase):
|
|||||||
self.test_basic_tree()
|
self.test_basic_tree()
|
||||||
|
|
||||||
def move_it_back(self):
|
def move_it_back(self):
|
||||||
group_b = frappe.bean("Item Group", "_Test Item Group B")
|
group_b = frappe.get_doc("Item Group", "_Test Item Group B")
|
||||||
group_b.parent_item_group = "All Item Groups"
|
group_b.parent_item_group = "All Item Groups"
|
||||||
group_b.save()
|
group_b.save()
|
||||||
self.test_basic_tree()
|
self.test_basic_tree()
|
||||||
@ -150,7 +150,7 @@ class TestItem(unittest.TestCase):
|
|||||||
old_lft, old_rgt = frappe.db.get_value("Item Group", "_Test Item Group C", ["lft", "rgt"])
|
old_lft, old_rgt = frappe.db.get_value("Item Group", "_Test Item Group C", ["lft", "rgt"])
|
||||||
|
|
||||||
# put B under C
|
# put B under C
|
||||||
group_b = frappe.bean("Item Group", "_Test Item Group B")
|
group_b = frappe.get_doc("Item Group", "_Test Item Group B")
|
||||||
lft, rgt = group_b.lft, group_b.rgt
|
lft, rgt = group_b.lft, group_b.rgt
|
||||||
|
|
||||||
group_b.parent_item_group = "_Test Item Group C"
|
group_b.parent_item_group = "_Test Item Group C"
|
||||||
@ -169,7 +169,7 @@ class TestItem(unittest.TestCase):
|
|||||||
self.move_it_back()
|
self.move_it_back()
|
||||||
|
|
||||||
def test_move_group_into_root(self):
|
def test_move_group_into_root(self):
|
||||||
group_b = frappe.bean("Item Group", "_Test Item Group B")
|
group_b = frappe.get_doc("Item Group", "_Test Item Group B")
|
||||||
group_b.parent_item_group = ""
|
group_b.parent_item_group = ""
|
||||||
self.assertRaises(NestedSetMultipleRootsError, group_b.save)
|
self.assertRaises(NestedSetMultipleRootsError, group_b.save)
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ class TestItem(unittest.TestCase):
|
|||||||
# before move
|
# before move
|
||||||
old_lft, old_rgt = frappe.db.get_value("Item Group", "_Test Item Group C", ["lft", "rgt"])
|
old_lft, old_rgt = frappe.db.get_value("Item Group", "_Test Item Group C", ["lft", "rgt"])
|
||||||
|
|
||||||
group_b_3 = frappe.bean("Item Group", "_Test Item Group B - 3")
|
group_b_3 = frappe.get_doc("Item Group", "_Test Item Group B - 3")
|
||||||
lft, rgt = group_b_3.lft, group_b_3.rgt
|
lft, rgt = group_b_3.lft, group_b_3.rgt
|
||||||
|
|
||||||
# child of right sibling is moved into it
|
# child of right sibling is moved into it
|
||||||
@ -203,7 +203,7 @@ class TestItem(unittest.TestCase):
|
|||||||
self.assertEquals(new_rgt - old_rgt, rgt - lft + 1)
|
self.assertEquals(new_rgt - old_rgt, rgt - lft + 1)
|
||||||
|
|
||||||
# move it back
|
# move it back
|
||||||
group_b_3 = frappe.bean("Item Group", "_Test Item Group B - 3")
|
group_b_3 = frappe.get_doc("Item Group", "_Test Item Group B - 3")
|
||||||
group_b_3.parent_item_group = "_Test Item Group B"
|
group_b_3.parent_item_group = "_Test Item Group B"
|
||||||
group_b_3.save()
|
group_b_3.save()
|
||||||
self.test_basic_tree()
|
self.test_basic_tree()
|
||||||
@ -228,7 +228,7 @@ class TestItem(unittest.TestCase):
|
|||||||
self.assertEquals(new_rgt, item_group.rgt - 2)
|
self.assertEquals(new_rgt, item_group.rgt - 2)
|
||||||
|
|
||||||
# insert it back
|
# insert it back
|
||||||
frappe.bean(copy=test_records[6]).insert()
|
frappe.get_doc(copy=test_records[6]).insert()
|
||||||
|
|
||||||
self.test_basic_tree()
|
self.test_basic_tree()
|
||||||
|
|
||||||
@ -243,14 +243,14 @@ class TestItem(unittest.TestCase):
|
|||||||
self.test_basic_tree(records=records_to_test)
|
self.test_basic_tree(records=records_to_test)
|
||||||
|
|
||||||
# insert Group B back
|
# insert Group B back
|
||||||
frappe.bean(copy=test_records[3]).insert()
|
frappe.get_doc(copy=test_records[3]).insert()
|
||||||
self.test_basic_tree()
|
self.test_basic_tree()
|
||||||
|
|
||||||
# move its children back
|
# move its children back
|
||||||
for name in frappe.db.sql_list("""select name from `tabItem Group`
|
for name in frappe.db.sql_list("""select name from `tabItem Group`
|
||||||
where parent_item_group='_Test Item Group C'"""):
|
where parent_item_group='_Test Item Group C'"""):
|
||||||
|
|
||||||
bean = frappe.bean("Item Group", name)
|
bean = frappe.get_doc("Item Group", name)
|
||||||
bean.parent_item_group = "_Test Item Group B"
|
bean.parent_item_group = "_Test Item Group B"
|
||||||
bean.save()
|
bean.save()
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ class TestItem(unittest.TestCase):
|
|||||||
self.test_basic_tree(records=records_to_test)
|
self.test_basic_tree(records=records_to_test)
|
||||||
|
|
||||||
# insert Group B - 2back
|
# insert Group B - 2back
|
||||||
frappe.bean(copy=test_records[5]).insert()
|
frappe.get_doc(copy=test_records[5]).insert()
|
||||||
self.test_basic_tree()
|
self.test_basic_tree()
|
||||||
|
|
||||||
def test_merge_leaf_into_group(self):
|
def test_merge_leaf_into_group(self):
|
||||||
|
@ -24,7 +24,7 @@ def import_country_and_currency():
|
|||||||
for name in data:
|
for name in data:
|
||||||
country = frappe._dict(data[name])
|
country = frappe._dict(data[name])
|
||||||
if not frappe.db.exists("Country", name):
|
if not frappe.db.exists("Country", name):
|
||||||
frappe.doc({
|
frappe.get_doc({
|
||||||
"doctype": "Country",
|
"doctype": "Country",
|
||||||
"country_name": name,
|
"country_name": name,
|
||||||
"code": country.code,
|
"code": country.code,
|
||||||
@ -33,7 +33,7 @@ def import_country_and_currency():
|
|||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
if country.currency and not frappe.db.exists("Currency", country.currency):
|
if country.currency and not frappe.db.exists("Currency", country.currency):
|
||||||
frappe.doc({
|
frappe.get_doc({
|
||||||
"doctype": "Currency",
|
"doctype": "Currency",
|
||||||
"currency_name": country.currency,
|
"currency_name": country.currency,
|
||||||
"fraction": country.currency_fraction,
|
"fraction": country.currency_fraction,
|
||||||
@ -111,7 +111,7 @@ def import_defaults():
|
|||||||
|
|
||||||
from frappe.modules import scrub
|
from frappe.modules import scrub
|
||||||
for r in records:
|
for r in records:
|
||||||
bean = frappe.bean(r)
|
bean = frappe.get_doc(r)
|
||||||
|
|
||||||
# ignore mandatory for root
|
# ignore mandatory for root
|
||||||
parent_link_field = ("parent_" + scrub(bean.doctype))
|
parent_link_field = ("parent_" + scrub(bean.doctype))
|
||||||
@ -122,7 +122,7 @@ def import_defaults():
|
|||||||
|
|
||||||
def feature_setup():
|
def feature_setup():
|
||||||
"""save global defaults and features setup"""
|
"""save global defaults and features setup"""
|
||||||
bean = frappe.bean("Features Setup", "Features Setup")
|
bean = frappe.get_doc("Features Setup", "Features Setup")
|
||||||
bean.ignore_permissions = True
|
bean.ignore_permissions = True
|
||||||
|
|
||||||
# store value as 1 for all these fields
|
# store value as 1 for all these fields
|
||||||
@ -142,7 +142,7 @@ def set_single_defaults():
|
|||||||
where parent=%s""", dt, as_dict=True)
|
where parent=%s""", dt, as_dict=True)
|
||||||
if default_values:
|
if default_values:
|
||||||
try:
|
try:
|
||||||
b = frappe.bean(dt, dt)
|
b = frappe.get_doc(dt, dt)
|
||||||
for fieldname, value in default_values:
|
for fieldname, value in default_values:
|
||||||
b.set(fieldname, value)
|
b.set(fieldname, value)
|
||||||
b.save()
|
b.save()
|
||||||
|
@ -45,7 +45,7 @@ def update_user_name(args):
|
|||||||
if args.get("email"):
|
if args.get("email"):
|
||||||
args['name'] = args.get("email")
|
args['name'] = args.get("email")
|
||||||
frappe.flags.mute_emails = True
|
frappe.flags.mute_emails = True
|
||||||
frappe.bean({
|
frappe.get_doc({
|
||||||
"doctype":"User",
|
"doctype":"User",
|
||||||
"email": args.get("email"),
|
"email": args.get("email"),
|
||||||
"first_name": args.get("first_name"),
|
"first_name": args.get("first_name"),
|
||||||
@ -73,7 +73,7 @@ def update_user_name(args):
|
|||||||
|
|
||||||
def create_fiscal_year_and_company(args):
|
def create_fiscal_year_and_company(args):
|
||||||
curr_fiscal_year = get_fy_details(args.get('fy_start_date'), args.get('fy_end_date'))
|
curr_fiscal_year = get_fy_details(args.get('fy_start_date'), args.get('fy_end_date'))
|
||||||
frappe.bean([{
|
frappe.get_doc([{
|
||||||
"doctype":"Fiscal Year",
|
"doctype":"Fiscal Year",
|
||||||
'year': curr_fiscal_year,
|
'year': curr_fiscal_year,
|
||||||
'year_start_date': args.get('fy_start_date'),
|
'year_start_date': args.get('fy_start_date'),
|
||||||
@ -82,7 +82,7 @@ def create_fiscal_year_and_company(args):
|
|||||||
|
|
||||||
print args
|
print args
|
||||||
# Company
|
# Company
|
||||||
frappe.bean([{
|
frappe.get_doc([{
|
||||||
"doctype":"Company",
|
"doctype":"Company",
|
||||||
'domain': args.get("industry"),
|
'domain': args.get("industry"),
|
||||||
'company_name':args.get('company_name'),
|
'company_name':args.get('company_name'),
|
||||||
@ -96,7 +96,7 @@ def create_fiscal_year_and_company(args):
|
|||||||
|
|
||||||
def create_price_lists(args):
|
def create_price_lists(args):
|
||||||
for pl_type in ["Selling", "Buying"]:
|
for pl_type in ["Selling", "Buying"]:
|
||||||
frappe.bean([
|
frappe.get_doc([
|
||||||
{
|
{
|
||||||
"doctype": "Price List",
|
"doctype": "Price List",
|
||||||
"price_list_name": "Standard " + pl_type,
|
"price_list_name": "Standard " + pl_type,
|
||||||
@ -116,7 +116,7 @@ def set_defaults(args):
|
|||||||
# enable default currency
|
# enable default currency
|
||||||
frappe.db.set_value("Currency", args.get("currency"), "enabled", 1)
|
frappe.db.set_value("Currency", args.get("currency"), "enabled", 1)
|
||||||
|
|
||||||
global_defaults = frappe.bean("Global Defaults", "Global Defaults")
|
global_defaults = frappe.get_doc("Global Defaults", "Global Defaults")
|
||||||
global_defaults.update({
|
global_defaults.update({
|
||||||
'current_fiscal_year': args.curr_fiscal_year,
|
'current_fiscal_year': args.curr_fiscal_year,
|
||||||
'default_currency': args.get('currency'),
|
'default_currency': args.get('currency'),
|
||||||
@ -128,46 +128,46 @@ def set_defaults(args):
|
|||||||
})
|
})
|
||||||
global_defaults.save()
|
global_defaults.save()
|
||||||
|
|
||||||
accounts_settings = frappe.bean("Accounts Settings")
|
accounts_settings = frappe.get_doc("Accounts Settings")
|
||||||
accounts_settings.auto_accounting_for_stock = 1
|
accounts_settings.auto_accounting_for_stock = 1
|
||||||
accounts_settings.save()
|
accounts_settings.save()
|
||||||
|
|
||||||
stock_settings = frappe.bean("Stock Settings")
|
stock_settings = frappe.get_doc("Stock Settings")
|
||||||
stock_settings.item_naming_by = "Item Code"
|
stock_settings.item_naming_by = "Item Code"
|
||||||
stock_settings.valuation_method = "FIFO"
|
stock_settings.valuation_method = "FIFO"
|
||||||
stock_settings.stock_uom = "Nos"
|
stock_settings.stock_uom = "Nos"
|
||||||
stock_settings.auto_indent = 1
|
stock_settings.auto_indent = 1
|
||||||
stock_settings.save()
|
stock_settings.save()
|
||||||
|
|
||||||
selling_settings = frappe.bean("Selling Settings")
|
selling_settings = frappe.get_doc("Selling Settings")
|
||||||
selling_settings.cust_master_name = "Customer Name"
|
selling_settings.cust_master_name = "Customer Name"
|
||||||
selling_settings.so_required = "No"
|
selling_settings.so_required = "No"
|
||||||
selling_settings.dn_required = "No"
|
selling_settings.dn_required = "No"
|
||||||
selling_settings.save()
|
selling_settings.save()
|
||||||
|
|
||||||
buying_settings = frappe.bean("Buying Settings")
|
buying_settings = frappe.get_doc("Buying Settings")
|
||||||
buying_settings.supp_master_name = "Supplier Name"
|
buying_settings.supp_master_name = "Supplier Name"
|
||||||
buying_settings.po_required = "No"
|
buying_settings.po_required = "No"
|
||||||
buying_settings.pr_required = "No"
|
buying_settings.pr_required = "No"
|
||||||
buying_settings.maintain_same_rate = 1
|
buying_settings.maintain_same_rate = 1
|
||||||
buying_settings.save()
|
buying_settings.save()
|
||||||
|
|
||||||
notification_control = frappe.bean("Notification Control")
|
notification_control = frappe.get_doc("Notification Control")
|
||||||
notification_control.quotation = 1
|
notification_control.quotation = 1
|
||||||
notification_control.sales_invoice = 1
|
notification_control.sales_invoice = 1
|
||||||
notification_control.purchase_order = 1
|
notification_control.purchase_order = 1
|
||||||
notification_control.save()
|
notification_control.save()
|
||||||
|
|
||||||
hr_settings = frappe.bean("HR Settings")
|
hr_settings = frappe.get_doc("HR Settings")
|
||||||
hr_settings.emp_created_by = "Naming Series"
|
hr_settings.emp_created_by = "Naming Series"
|
||||||
hr_settings.save()
|
hr_settings.save()
|
||||||
|
|
||||||
email_settings = frappe.bean("Outgoing Email Settings")
|
email_settings = frappe.get_doc("Outgoing Email Settings")
|
||||||
email_settings.send_print_in_body_and_attachment = 1
|
email_settings.send_print_in_body_and_attachment = 1
|
||||||
email_settings.save()
|
email_settings.save()
|
||||||
|
|
||||||
# control panel
|
# control panel
|
||||||
cp = frappe.doc("Control Panel", "Control Panel")
|
cp = frappe.get_doc("Control Panel", "Control Panel")
|
||||||
cp.company_name = args["company_name"]
|
cp.company_name = args["company_name"]
|
||||||
cp.save()
|
cp.save()
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ def create_email_digest():
|
|||||||
companies = frappe.db.sql_list("select name FROM `tabCompany`")
|
companies = frappe.db.sql_list("select name FROM `tabCompany`")
|
||||||
for company in companies:
|
for company in companies:
|
||||||
if not frappe.db.exists("Email Digest", "Default Weekly Digest - " + company):
|
if not frappe.db.exists("Email Digest", "Default Weekly Digest - " + company):
|
||||||
edigest = frappe.bean({
|
edigest = frappe.get_doc({
|
||||||
"doctype": "Email Digest",
|
"doctype": "Email Digest",
|
||||||
"name": "Default Weekly Digest - " + company,
|
"name": "Default Weekly Digest - " + company,
|
||||||
"company": company,
|
"company": company,
|
||||||
@ -224,7 +224,7 @@ def get_fy_details(fy_start_date, fy_end_date):
|
|||||||
def create_taxes(args):
|
def create_taxes(args):
|
||||||
for i in xrange(1,6):
|
for i in xrange(1,6):
|
||||||
if args.get("tax_" + str(i)):
|
if args.get("tax_" + str(i)):
|
||||||
frappe.bean({
|
frappe.get_doc({
|
||||||
"doctype":"Account",
|
"doctype":"Account",
|
||||||
"company": args.get("company_name"),
|
"company": args.get("company_name"),
|
||||||
"parent_account": "Duties and Taxes - " + args.get("company_abbr"),
|
"parent_account": "Duties and Taxes - " + args.get("company_abbr"),
|
||||||
@ -240,7 +240,7 @@ def create_items(args):
|
|||||||
item = args.get("item_" + str(i))
|
item = args.get("item_" + str(i))
|
||||||
if item:
|
if item:
|
||||||
item_group = args.get("item_group_" + str(i))
|
item_group = args.get("item_group_" + str(i))
|
||||||
frappe.bean({
|
frappe.get_doc({
|
||||||
"doctype":"Item",
|
"doctype":"Item",
|
||||||
"item_code": item,
|
"item_code": item,
|
||||||
"item_name": item,
|
"item_name": item,
|
||||||
@ -261,7 +261,7 @@ def create_items(args):
|
|||||||
item = args.get("item_buy_" + str(i))
|
item = args.get("item_buy_" + str(i))
|
||||||
if item:
|
if item:
|
||||||
item_group = args.get("item_buy_group_" + str(i))
|
item_group = args.get("item_buy_group_" + str(i))
|
||||||
frappe.bean({
|
frappe.get_doc({
|
||||||
"doctype":"Item",
|
"doctype":"Item",
|
||||||
"item_code": item,
|
"item_code": item,
|
||||||
"item_name": item,
|
"item_name": item,
|
||||||
@ -283,7 +283,7 @@ def create_customers(args):
|
|||||||
for i in xrange(1,6):
|
for i in xrange(1,6):
|
||||||
customer = args.get("customer_" + str(i))
|
customer = args.get("customer_" + str(i))
|
||||||
if customer:
|
if customer:
|
||||||
frappe.bean({
|
frappe.get_doc({
|
||||||
"doctype":"Customer",
|
"doctype":"Customer",
|
||||||
"customer_name": customer,
|
"customer_name": customer,
|
||||||
"customer_type": "Company",
|
"customer_type": "Company",
|
||||||
@ -294,7 +294,7 @@ def create_customers(args):
|
|||||||
|
|
||||||
if args.get("customer_contact_" + str(i)):
|
if args.get("customer_contact_" + str(i)):
|
||||||
contact = args.get("customer_contact_" + str(i)).split(" ")
|
contact = args.get("customer_contact_" + str(i)).split(" ")
|
||||||
frappe.bean({
|
frappe.get_doc({
|
||||||
"doctype":"Contact",
|
"doctype":"Contact",
|
||||||
"customer": customer,
|
"customer": customer,
|
||||||
"first_name":contact[0],
|
"first_name":contact[0],
|
||||||
@ -305,7 +305,7 @@ def create_suppliers(args):
|
|||||||
for i in xrange(1,6):
|
for i in xrange(1,6):
|
||||||
supplier = args.get("supplier_" + str(i))
|
supplier = args.get("supplier_" + str(i))
|
||||||
if supplier:
|
if supplier:
|
||||||
frappe.bean({
|
frappe.get_doc({
|
||||||
"doctype":"Supplier",
|
"doctype":"Supplier",
|
||||||
"supplier_name": supplier,
|
"supplier_name": supplier,
|
||||||
"supplier_type": "Local",
|
"supplier_type": "Local",
|
||||||
@ -314,7 +314,7 @@ def create_suppliers(args):
|
|||||||
|
|
||||||
if args.get("supplier_contact_" + str(i)):
|
if args.get("supplier_contact_" + str(i)):
|
||||||
contact = args.get("supplier_contact_" + str(i)).split(" ")
|
contact = args.get("supplier_contact_" + str(i)).split(" ")
|
||||||
frappe.bean({
|
frappe.get_doc({
|
||||||
"doctype":"Contact",
|
"doctype":"Contact",
|
||||||
"supplier": supplier,
|
"supplier": supplier,
|
||||||
"first_name":contact[0],
|
"first_name":contact[0],
|
||||||
@ -324,7 +324,7 @@ def create_suppliers(args):
|
|||||||
|
|
||||||
def create_letter_head(args):
|
def create_letter_head(args):
|
||||||
if args.get("attach_letterhead"):
|
if args.get("attach_letterhead"):
|
||||||
lh = frappe.bean({
|
lh = frappe.get_doc({
|
||||||
"doctype":"Letter Head",
|
"doctype":"Letter Head",
|
||||||
"letter_head_name": "Standard",
|
"letter_head_name": "Standard",
|
||||||
"is_default": 1
|
"is_default": 1
|
||||||
@ -349,7 +349,7 @@ def create_territories():
|
|||||||
root_territory = get_root_of("Territory")
|
root_territory = get_root_of("Territory")
|
||||||
for name in (country, "Rest Of The World"):
|
for name in (country, "Rest Of The World"):
|
||||||
if name and not frappe.db.exists("Territory", name):
|
if name and not frappe.db.exists("Territory", name):
|
||||||
frappe.bean({
|
frappe.get_doc({
|
||||||
"doctype": "Territory",
|
"doctype": "Territory",
|
||||||
"territory_name": name.replace("'", ""),
|
"territory_name": name.replace("'", ""),
|
||||||
"parent_territory": root_territory,
|
"parent_territory": root_territory,
|
||||||
|
@ -19,7 +19,7 @@ def boot_session(bootinfo):
|
|||||||
load_country_and_currency(bootinfo)
|
load_country_and_currency(bootinfo)
|
||||||
|
|
||||||
import frappe.model.doctype
|
import frappe.model.doctype
|
||||||
bootinfo['notification_settings'] = frappe.doc("Notification Control",
|
bootinfo['notification_settings'] = frappe.get_doc("Notification Control",
|
||||||
"Notification Control").get_values()
|
"Notification Control").get_values()
|
||||||
|
|
||||||
# if no company, show a dialog box to create a new company
|
# if no company, show a dialog box to create a new company
|
||||||
@ -35,7 +35,7 @@ def boot_session(bootinfo):
|
|||||||
def load_country_and_currency(bootinfo):
|
def load_country_and_currency(bootinfo):
|
||||||
if bootinfo.control_panel.country and \
|
if bootinfo.control_panel.country and \
|
||||||
frappe.db.exists("Country", bootinfo.control_panel.country):
|
frappe.db.exists("Country", bootinfo.control_panel.country):
|
||||||
bootinfo["docs"] += [frappe.doc("Country", bootinfo.control_panel.country)]
|
bootinfo["docs"] += [frappe.get_doc("Country", bootinfo.control_panel.country)]
|
||||||
|
|
||||||
bootinfo["docs"] += frappe.db.sql("""select * from tabCurrency
|
bootinfo["docs"] += frappe.db.sql("""select * from tabCurrency
|
||||||
where ifnull(enabled,0)=1""", as_dict=1, update={"doctype":":Currency"})
|
where ifnull(enabled,0)=1""", as_dict=1, update={"doctype":":Currency"})
|
||||||
|
@ -289,7 +289,7 @@ def make_sales_invoice(source_name, target_doc=None):
|
|||||||
invoiced_qty_map = get_invoiced_qty_map(source_name)
|
invoiced_qty_map = get_invoiced_qty_map(source_name)
|
||||||
|
|
||||||
def update_accounts(source, target):
|
def update_accounts(source, target):
|
||||||
si = frappe.bean(target)
|
si = frappe.get_doc(target)
|
||||||
si.is_pos = 0
|
si.is_pos = 0
|
||||||
si.run_method("onload_post_render")
|
si.run_method("onload_post_render")
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ def _insert_purchase_receipt(item_code=None):
|
|||||||
if not item_code:
|
if not item_code:
|
||||||
item_code = pr_test_records[0][1]["item_code"]
|
item_code = pr_test_records[0][1]["item_code"]
|
||||||
|
|
||||||
pr = frappe.bean(copy=pr_test_records[0])
|
pr = frappe.get_doc(copy=pr_test_records[0])
|
||||||
pr.doclist[1].item_code = item_code
|
pr.doclist[1].item_code = item_code
|
||||||
pr.insert()
|
pr.insert()
|
||||||
pr.submit()
|
pr.submit()
|
||||||
@ -25,12 +25,12 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
|
|
||||||
from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_invoice
|
from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_invoice
|
||||||
_insert_purchase_receipt()
|
_insert_purchase_receipt()
|
||||||
dn = frappe.bean(copy=test_records[0]).insert()
|
dn = frappe.get_doc(copy=test_records[0]).insert()
|
||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, make_sales_invoice,
|
self.assertRaises(frappe.ValidationError, make_sales_invoice,
|
||||||
dn.name)
|
dn.name)
|
||||||
|
|
||||||
dn = frappe.bean("Delivery Note", dn.name)
|
dn = frappe.get_doc("Delivery Note", dn.name)
|
||||||
dn.submit()
|
dn.submit()
|
||||||
si = make_sales_invoice(dn.name)
|
si = make_sales_invoice(dn.name)
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
|
|
||||||
# modify amount
|
# modify amount
|
||||||
si[1]["rate"] = 200
|
si[1]["rate"] = 200
|
||||||
self.assertRaises(frappe.ValidationError, frappe.bean(si).insert)
|
self.assertRaises(frappe.ValidationError, frappe.get_doc(si).insert)
|
||||||
|
|
||||||
|
|
||||||
def test_delivery_note_no_gl_entry(self):
|
def test_delivery_note_no_gl_entry(self):
|
||||||
@ -48,7 +48,7 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
|
|
||||||
_insert_purchase_receipt()
|
_insert_purchase_receipt()
|
||||||
|
|
||||||
dn = frappe.bean(copy=test_records[0])
|
dn = frappe.get_doc(copy=test_records[0])
|
||||||
dn.insert()
|
dn.insert()
|
||||||
dn.submit()
|
dn.submit()
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
|
|
||||||
_insert_purchase_receipt()
|
_insert_purchase_receipt()
|
||||||
|
|
||||||
dn = frappe.bean(copy=test_records[0])
|
dn = frappe.get_doc(copy=test_records[0])
|
||||||
dn.doclist[1].expense_account = "Cost of Goods Sold - _TC"
|
dn.doclist[1].expense_account = "Cost of Goods Sold - _TC"
|
||||||
dn.doclist[1].cost_center = "Main - _TC"
|
dn.doclist[1].cost_center = "Main - _TC"
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
self.assertEquals(bal, prev_bal - 375.0)
|
self.assertEquals(bal, prev_bal - 375.0)
|
||||||
|
|
||||||
# back dated purchase receipt
|
# back dated purchase receipt
|
||||||
pr = frappe.bean(copy=pr_test_records[0])
|
pr = frappe.get_doc(copy=pr_test_records[0])
|
||||||
pr.posting_date = "2013-01-01"
|
pr.posting_date = "2013-01-01"
|
||||||
pr.doclist[1].rate = 100
|
pr.doclist[1].rate = 100
|
||||||
pr.doclist[1].base_amount = 100
|
pr.doclist[1].base_amount = 100
|
||||||
@ -123,7 +123,7 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
_insert_purchase_receipt()
|
_insert_purchase_receipt()
|
||||||
_insert_purchase_receipt("_Test Item Home Desktop 100")
|
_insert_purchase_receipt("_Test Item Home Desktop 100")
|
||||||
|
|
||||||
dn = frappe.bean(copy=test_records[0])
|
dn = frappe.get_doc(copy=test_records[0])
|
||||||
dn.doclist[1].item_code = "_Test Sales BOM Item"
|
dn.doclist[1].item_code = "_Test Sales BOM Item"
|
||||||
dn.doclist[1].qty = 1
|
dn.doclist[1].qty = 1
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
se = make_serialized_item()
|
se = make_serialized_item()
|
||||||
serial_nos = get_serial_nos(se.doclist[1].serial_no)
|
serial_nos = get_serial_nos(se.doclist[1].serial_no)
|
||||||
|
|
||||||
dn = frappe.bean(copy=test_records[0])
|
dn = frappe.get_doc(copy=test_records[0])
|
||||||
dn.doclist[1].item_code = "_Test Serialized Item With Series"
|
dn.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||||
dn.doclist[1].qty = 1
|
dn.doclist[1].qty = 1
|
||||||
dn.doclist[1].serial_no = serial_nos[0]
|
dn.doclist[1].serial_no = serial_nos[0]
|
||||||
@ -195,11 +195,11 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
se = make_serialized_item()
|
se = make_serialized_item()
|
||||||
serial_nos = get_serial_nos(se.doclist[1].serial_no)
|
serial_nos = get_serial_nos(se.doclist[1].serial_no)
|
||||||
|
|
||||||
sr = frappe.bean("Serial No", serial_nos[0])
|
sr = frappe.get_doc("Serial No", serial_nos[0])
|
||||||
sr.status = "Not Available"
|
sr.status = "Not Available"
|
||||||
sr.save()
|
sr.save()
|
||||||
|
|
||||||
dn = frappe.bean(copy=test_records[0])
|
dn = frappe.get_doc(copy=test_records[0])
|
||||||
dn.doclist[1].item_code = "_Test Serialized Item With Series"
|
dn.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||||
dn.doclist[1].qty = 1
|
dn.doclist[1].qty = 1
|
||||||
dn.doclist[1].serial_no = serial_nos[0]
|
dn.doclist[1].serial_no = serial_nos[0]
|
||||||
|
@ -13,7 +13,7 @@ test_dependencies = ["Warehouse"]
|
|||||||
class TestItem(unittest.TestCase):
|
class TestItem(unittest.TestCase):
|
||||||
def test_default_warehouse(self):
|
def test_default_warehouse(self):
|
||||||
from erpnext.stock.doctype.item.item import WarehouseNotSet
|
from erpnext.stock.doctype.item.item import WarehouseNotSet
|
||||||
item = frappe.bean(copy=test_records[0])
|
item = frappe.get_doc(copy=test_records[0])
|
||||||
item.is_stock_item = "Yes"
|
item.is_stock_item = "Yes"
|
||||||
item.default_warehouse = None
|
item.default_warehouse = None
|
||||||
self.assertRaises(WarehouseNotSet, item.insert)
|
self.assertRaises(WarehouseNotSet, item.insert)
|
||||||
|
@ -8,7 +8,7 @@ import frappe
|
|||||||
class TestItem(unittest.TestCase):
|
class TestItem(unittest.TestCase):
|
||||||
def test_duplicate_item(self):
|
def test_duplicate_item(self):
|
||||||
from erpnext.stock.doctype.item_price.item_price import ItemPriceDuplicateItem
|
from erpnext.stock.doctype.item_price.item_price import ItemPriceDuplicateItem
|
||||||
bean = frappe.bean(copy=test_records[0])
|
bean = frappe.get_doc(copy=test_records[0])
|
||||||
self.assertRaises(ItemPriceDuplicateItem, bean.insert)
|
self.assertRaises(ItemPriceDuplicateItem, bean.insert)
|
||||||
|
|
||||||
test_records = [
|
test_records = [
|
||||||
|
@ -34,7 +34,7 @@ class LandedCostWizard(Document):
|
|||||||
total_amt = self.get_total_pr_amt(purchase_receipts)
|
total_amt = self.get_total_pr_amt(purchase_receipts)
|
||||||
|
|
||||||
for pr in purchase_receipts:
|
for pr in purchase_receipts:
|
||||||
pr_bean = frappe.bean('Purchase Receipt', pr)
|
pr_bean = frappe.get_doc('Purchase Receipt', pr)
|
||||||
pr_items = pr_bean.get("purchase_tax_details")
|
pr_items = pr_bean.get("purchase_tax_details")
|
||||||
|
|
||||||
for lc in self.get("landed_cost_details"):
|
for lc in self.get("landed_cost_details"):
|
||||||
@ -76,7 +76,7 @@ class LandedCostWizard(Document):
|
|||||||
|
|
||||||
def cancel_pr(self, purchase_receipts):
|
def cancel_pr(self, purchase_receipts):
|
||||||
for pr in purchase_receipts:
|
for pr in purchase_receipts:
|
||||||
pr_bean = frappe.bean("Purchase Receipt", pr)
|
pr_bean = frappe.get_doc("Purchase Receipt", pr)
|
||||||
|
|
||||||
pr_bean.run_method("update_ordered_qty")
|
pr_bean.run_method("update_ordered_qty")
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ class LandedCostWizard(Document):
|
|||||||
|
|
||||||
def submit_pr(self, purchase_receipts):
|
def submit_pr(self, purchase_receipts):
|
||||||
for pr in purchase_receipts:
|
for pr in purchase_receipts:
|
||||||
pr_bean = frappe.bean("Purchase Receipt", pr)
|
pr_bean = frappe.get_doc("Purchase Receipt", pr)
|
||||||
pr_bean.run_method("update_ordered_qty")
|
pr_bean.run_method("update_ordered_qty")
|
||||||
pr_bean.run_method("update_stock")
|
pr_bean.run_method("update_stock")
|
||||||
pr_bean.run_method("make_gl_entries")
|
pr_bean.run_method("make_gl_entries")
|
@ -218,7 +218,7 @@ def _update_requested_qty(bean, mr_obj, mr_items):
|
|||||||
})
|
})
|
||||||
|
|
||||||
def set_missing_values(source, target_doc):
|
def set_missing_values(source, target_doc):
|
||||||
po = frappe.bean(target_doc)
|
po = frappe.get_doc(target_doc)
|
||||||
po.run_method("set_missing_values")
|
po.run_method("set_missing_values")
|
||||||
|
|
||||||
def update_item(obj, target, source_parent):
|
def update_item(obj, target, source_parent):
|
||||||
@ -343,7 +343,7 @@ def make_stock_entry(source_name, target_doc=None):
|
|||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
target[0].purpose = "Material Transfer"
|
target[0].purpose = "Material Transfer"
|
||||||
se = frappe.bean(target)
|
se = frappe.get_doc(target)
|
||||||
se.run_method("get_stock_and_rate")
|
se.run_method("get_stock_and_rate")
|
||||||
|
|
||||||
doclist = get_mapped_doc("Material Request", source_name, {
|
doclist = get_mapped_doc("Material Request", source_name, {
|
||||||
|
@ -15,12 +15,12 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
def test_make_purchase_order(self):
|
def test_make_purchase_order(self):
|
||||||
from erpnext.stock.doctype.material_request.material_request import make_purchase_order
|
from erpnext.stock.doctype.material_request.material_request import make_purchase_order
|
||||||
|
|
||||||
mr = frappe.bean(copy=test_records[0]).insert()
|
mr = frappe.get_doc(copy=test_records[0]).insert()
|
||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, make_purchase_order,
|
self.assertRaises(frappe.ValidationError, make_purchase_order,
|
||||||
mr.name)
|
mr.name)
|
||||||
|
|
||||||
mr = frappe.bean("Material Request", mr.name)
|
mr = frappe.get_doc("Material Request", mr.name)
|
||||||
mr.submit()
|
mr.submit()
|
||||||
po = make_purchase_order(mr.name)
|
po = make_purchase_order(mr.name)
|
||||||
|
|
||||||
@ -30,12 +30,12 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
def test_make_supplier_quotation(self):
|
def test_make_supplier_quotation(self):
|
||||||
from erpnext.stock.doctype.material_request.material_request import make_supplier_quotation
|
from erpnext.stock.doctype.material_request.material_request import make_supplier_quotation
|
||||||
|
|
||||||
mr = frappe.bean(copy=test_records[0]).insert()
|
mr = frappe.get_doc(copy=test_records[0]).insert()
|
||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, make_supplier_quotation,
|
self.assertRaises(frappe.ValidationError, make_supplier_quotation,
|
||||||
mr.name)
|
mr.name)
|
||||||
|
|
||||||
mr = frappe.bean("Material Request", mr.name)
|
mr = frappe.get_doc("Material Request", mr.name)
|
||||||
mr.submit()
|
mr.submit()
|
||||||
sq = make_supplier_quotation(mr.name)
|
sq = make_supplier_quotation(mr.name)
|
||||||
|
|
||||||
@ -46,12 +46,12 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
def test_make_stock_entry(self):
|
def test_make_stock_entry(self):
|
||||||
from erpnext.stock.doctype.material_request.material_request import make_stock_entry
|
from erpnext.stock.doctype.material_request.material_request import make_stock_entry
|
||||||
|
|
||||||
mr = frappe.bean(copy=test_records[0]).insert()
|
mr = frappe.get_doc(copy=test_records[0]).insert()
|
||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, make_stock_entry,
|
self.assertRaises(frappe.ValidationError, make_stock_entry,
|
||||||
mr.name)
|
mr.name)
|
||||||
|
|
||||||
mr = frappe.bean("Material Request", mr.name)
|
mr = frappe.get_doc("Material Request", mr.name)
|
||||||
mr.material_request_type = "Transfer"
|
mr.material_request_type = "Transfer"
|
||||||
mr.submit()
|
mr.submit()
|
||||||
se = make_stock_entry(mr.name)
|
se = make_stock_entry(mr.name)
|
||||||
@ -71,7 +71,7 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
"warehouse": "_Test Warehouse - _TC"}, "indented_qty")), qty2)
|
"warehouse": "_Test Warehouse - _TC"}, "indented_qty")), qty2)
|
||||||
|
|
||||||
def _insert_stock_entry(self, qty1, qty2):
|
def _insert_stock_entry(self, qty1, qty2):
|
||||||
se = frappe.bean([
|
se = frappe.get_doc([
|
||||||
{
|
{
|
||||||
"company": "_Test Company",
|
"company": "_Test Company",
|
||||||
"doctype": "Stock Entry",
|
"doctype": "Stock Entry",
|
||||||
@ -112,7 +112,7 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
frappe.db.sql("""delete from `tabBin`""")
|
frappe.db.sql("""delete from `tabBin`""")
|
||||||
|
|
||||||
# submit material request of type Purchase
|
# submit material request of type Purchase
|
||||||
mr = frappe.bean(copy=test_records[0])
|
mr = frappe.get_doc(copy=test_records[0])
|
||||||
mr.insert()
|
mr.insert()
|
||||||
mr.submit()
|
mr.submit()
|
||||||
|
|
||||||
@ -133,14 +133,14 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
# check for stopped status of Material Request
|
# check for stopped status of Material Request
|
||||||
po = frappe.bean(copy=po_doclist)
|
po = frappe.get_doc(copy=po_doclist)
|
||||||
po.insert()
|
po.insert()
|
||||||
mr.obj.update_status('Stopped')
|
mr.obj.update_status('Stopped')
|
||||||
self.assertRaises(frappe.ValidationError, po.submit)
|
self.assertRaises(frappe.ValidationError, po.submit)
|
||||||
self.assertRaises(frappe.ValidationError, po.cancel)
|
self.assertRaises(frappe.ValidationError, po.cancel)
|
||||||
|
|
||||||
mr.obj.update_status('Submitted')
|
mr.obj.update_status('Submitted')
|
||||||
po = frappe.bean(copy=po_doclist)
|
po = frappe.get_doc(copy=po_doclist)
|
||||||
po.insert()
|
po.insert()
|
||||||
po.submit()
|
po.submit()
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
frappe.db.sql("""delete from `tabStock Ledger Entry`""")
|
frappe.db.sql("""delete from `tabStock Ledger Entry`""")
|
||||||
|
|
||||||
# submit material request of type Purchase
|
# submit material request of type Purchase
|
||||||
mr = frappe.bean(copy=test_records[0])
|
mr = frappe.get_doc(copy=test_records[0])
|
||||||
mr.material_request_type = "Transfer"
|
mr.material_request_type = "Transfer"
|
||||||
mr.insert()
|
mr.insert()
|
||||||
mr.submit()
|
mr.submit()
|
||||||
@ -196,14 +196,14 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
self._insert_stock_entry(27.0, 1.5)
|
self._insert_stock_entry(27.0, 1.5)
|
||||||
|
|
||||||
# check for stopped status of Material Request
|
# check for stopped status of Material Request
|
||||||
se = frappe.bean(copy=se_doclist)
|
se = frappe.get_doc(copy=se_doclist)
|
||||||
se.insert()
|
se.insert()
|
||||||
mr.obj.update_status('Stopped')
|
mr.obj.update_status('Stopped')
|
||||||
self.assertRaises(frappe.ValidationError, se.submit)
|
self.assertRaises(frappe.ValidationError, se.submit)
|
||||||
self.assertRaises(frappe.ValidationError, se.cancel)
|
self.assertRaises(frappe.ValidationError, se.cancel)
|
||||||
|
|
||||||
mr.obj.update_status('Submitted')
|
mr.obj.update_status('Submitted')
|
||||||
se = frappe.bean(copy=se_doclist)
|
se = frappe.get_doc(copy=se_doclist)
|
||||||
se.insert()
|
se.insert()
|
||||||
se.submit()
|
se.submit()
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
frappe.db.sql("""delete from `tabStock Ledger Entry`""")
|
frappe.db.sql("""delete from `tabStock Ledger Entry`""")
|
||||||
|
|
||||||
# submit material request of type Purchase
|
# submit material request of type Purchase
|
||||||
mr = frappe.bean(copy=test_records[0])
|
mr = frappe.get_doc(copy=test_records[0])
|
||||||
mr.material_request_type = "Transfer"
|
mr.material_request_type = "Transfer"
|
||||||
mr.insert()
|
mr.insert()
|
||||||
mr.submit()
|
mr.submit()
|
||||||
@ -259,14 +259,14 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
self._insert_stock_entry(60.0, 3.0)
|
self._insert_stock_entry(60.0, 3.0)
|
||||||
|
|
||||||
# check for stopped status of Material Request
|
# check for stopped status of Material Request
|
||||||
se = frappe.bean(copy=se_doclist)
|
se = frappe.get_doc(copy=se_doclist)
|
||||||
se.insert()
|
se.insert()
|
||||||
mr.obj.update_status('Stopped')
|
mr.obj.update_status('Stopped')
|
||||||
self.assertRaises(frappe.ValidationError, se.submit)
|
self.assertRaises(frappe.ValidationError, se.submit)
|
||||||
self.assertRaises(frappe.ValidationError, se.cancel)
|
self.assertRaises(frappe.ValidationError, se.cancel)
|
||||||
|
|
||||||
mr.obj.update_status('Submitted')
|
mr.obj.update_status('Submitted')
|
||||||
se = frappe.bean(copy=se_doclist)
|
se = frappe.get_doc(copy=se_doclist)
|
||||||
se.insert()
|
se.insert()
|
||||||
se.submit()
|
se.submit()
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_incorrect_mapping_of_stock_entry(self):
|
def test_incorrect_mapping_of_stock_entry(self):
|
||||||
# submit material request of type Purchase
|
# submit material request of type Purchase
|
||||||
mr = frappe.bean(copy=test_records[0])
|
mr = frappe.get_doc(copy=test_records[0])
|
||||||
mr.material_request_type = "Transfer"
|
mr.material_request_type = "Transfer"
|
||||||
mr.insert()
|
mr.insert()
|
||||||
mr.submit()
|
mr.submit()
|
||||||
@ -312,12 +312,12 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
})
|
})
|
||||||
|
|
||||||
# check for stopped status of Material Request
|
# check for stopped status of Material Request
|
||||||
se = frappe.bean(copy=se_doclist)
|
se = frappe.get_doc(copy=se_doclist)
|
||||||
self.assertRaises(frappe.MappingMismatchError, se.insert)
|
self.assertRaises(frappe.MappingMismatchError, se.insert)
|
||||||
|
|
||||||
def test_warehouse_company_validation(self):
|
def test_warehouse_company_validation(self):
|
||||||
from erpnext.stock.utils import InvalidWarehouseCompany
|
from erpnext.stock.utils import InvalidWarehouseCompany
|
||||||
mr = frappe.bean(copy=test_records[0])
|
mr = frappe.get_doc(copy=test_records[0])
|
||||||
mr.company = "_Test Company 1"
|
mr.company = "_Test Company 1"
|
||||||
self.assertRaises(InvalidWarehouseCompany, mr.insert)
|
self.assertRaises(InvalidWarehouseCompany, mr.insert)
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class PriceList(DocListController):
|
|||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
def _update_default_price_list(module):
|
def _update_default_price_list(module):
|
||||||
b = frappe.bean(module + " Settings")
|
b = frappe.get_doc(module + " Settings")
|
||||||
price_list_fieldname = module.lower() + "_price_list"
|
price_list_fieldname = module.lower() + "_price_list"
|
||||||
|
|
||||||
if self.name == b.fields[price_list_fieldname]:
|
if self.name == b.fields[price_list_fieldname]:
|
||||||
|
@ -299,7 +299,7 @@ def make_purchase_invoice(source_name, target_doc=None):
|
|||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
bean = frappe.bean(target)
|
bean = frappe.get_doc(target)
|
||||||
bean.run_method("set_missing_values")
|
bean.run_method("set_missing_values")
|
||||||
|
|
||||||
doclist = get_mapped_doc("Purchase Receipt", source_name, {
|
doclist = get_mapped_doc("Purchase Receipt", source_name, {
|
||||||
|
@ -14,12 +14,12 @@ class TestPurchaseReceipt(unittest.TestCase):
|
|||||||
set_perpetual_inventory(0)
|
set_perpetual_inventory(0)
|
||||||
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
|
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
|
||||||
|
|
||||||
pr = frappe.bean(copy=test_records[0]).insert()
|
pr = frappe.get_doc(copy=test_records[0]).insert()
|
||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, make_purchase_invoice,
|
self.assertRaises(frappe.ValidationError, make_purchase_invoice,
|
||||||
pr.name)
|
pr.name)
|
||||||
|
|
||||||
pr = frappe.bean("Purchase Receipt", pr.name)
|
pr = frappe.get_doc("Purchase Receipt", pr.name)
|
||||||
pr.submit()
|
pr.submit()
|
||||||
pi = make_purchase_invoice(pr.name)
|
pi = make_purchase_invoice(pr.name)
|
||||||
|
|
||||||
@ -28,12 +28,12 @@ class TestPurchaseReceipt(unittest.TestCase):
|
|||||||
|
|
||||||
# modify rate
|
# modify rate
|
||||||
pi[1]["rate"] = 200
|
pi[1]["rate"] = 200
|
||||||
self.assertRaises(frappe.ValidationError, frappe.bean(pi).submit)
|
self.assertRaises(frappe.ValidationError, frappe.get_doc(pi).submit)
|
||||||
|
|
||||||
def test_purchase_receipt_no_gl_entry(self):
|
def test_purchase_receipt_no_gl_entry(self):
|
||||||
self._clear_stock_account_balance()
|
self._clear_stock_account_balance()
|
||||||
set_perpetual_inventory(0)
|
set_perpetual_inventory(0)
|
||||||
pr = frappe.bean(copy=test_records[0])
|
pr = frappe.get_doc(copy=test_records[0])
|
||||||
pr.insert()
|
pr.insert()
|
||||||
pr.submit()
|
pr.submit()
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class TestPurchaseReceipt(unittest.TestCase):
|
|||||||
set_perpetual_inventory()
|
set_perpetual_inventory()
|
||||||
self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
||||||
|
|
||||||
pr = frappe.bean(copy=test_records[0])
|
pr = frappe.get_doc(copy=test_records[0])
|
||||||
pr.insert()
|
pr.insert()
|
||||||
pr.submit()
|
pr.submit()
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ class TestPurchaseReceipt(unittest.TestCase):
|
|||||||
frappe.db.sql("""delete from `tabGL Entry`""")
|
frappe.db.sql("""delete from `tabGL Entry`""")
|
||||||
|
|
||||||
def test_subcontracting(self):
|
def test_subcontracting(self):
|
||||||
pr = frappe.bean(copy=test_records[1])
|
pr = frappe.get_doc(copy=test_records[1])
|
||||||
pr.run_method("calculate_taxes_and_totals")
|
pr.run_method("calculate_taxes_and_totals")
|
||||||
pr.insert()
|
pr.insert()
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ class TestPurchaseReceipt(unittest.TestCase):
|
|||||||
self.assertEquals(len(pr.get("pr_raw_material_details")), 2)
|
self.assertEquals(len(pr.get("pr_raw_material_details")), 2)
|
||||||
|
|
||||||
def test_serial_no_supplier(self):
|
def test_serial_no_supplier(self):
|
||||||
pr = frappe.bean(copy=test_records[0])
|
pr = frappe.get_doc(copy=test_records[0])
|
||||||
pr.doclist[1].item_code = "_Test Serialized Item With Series"
|
pr.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||||
pr.doclist[1].qty = 1
|
pr.doclist[1].qty = 1
|
||||||
pr.doclist[1].received_qty = 1
|
pr.doclist[1].received_qty = 1
|
||||||
@ -123,7 +123,7 @@ def get_gl_entries(voucher_type, voucher_no):
|
|||||||
order by account desc""", (voucher_type, voucher_no), as_dict=1)
|
order by account desc""", (voucher_type, voucher_no), as_dict=1)
|
||||||
|
|
||||||
def set_perpetual_inventory(enable=1):
|
def set_perpetual_inventory(enable=1):
|
||||||
accounts_settings = frappe.bean("Accounts Settings")
|
accounts_settings = frappe.get_doc("Accounts Settings")
|
||||||
accounts_settings.auto_accounting_for_stock = enable
|
accounts_settings.auto_accounting_for_stock = enable
|
||||||
accounts_settings.save()
|
accounts_settings.save()
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ class SerialNo(StockController):
|
|||||||
"""
|
"""
|
||||||
Validate whether serial no is required for this item
|
Validate whether serial no is required for this item
|
||||||
"""
|
"""
|
||||||
item = frappe.doc("Item", self.item_code)
|
item = frappe.get_doc("Item", self.item_code)
|
||||||
if item.has_serial_no!="Yes":
|
if item.has_serial_no!="Yes":
|
||||||
frappe.throw(_("Item must have 'Has Serial No' as 'Yes'") + ": " + self.item_code)
|
frappe.throw(_("Item must have 'Has Serial No' as 'Yes'") + ": " + self.item_code)
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ def validate_serial_no(sle, item_det):
|
|||||||
|
|
||||||
for serial_no in serial_nos:
|
for serial_no in serial_nos:
|
||||||
if frappe.db.exists("Serial No", serial_no):
|
if frappe.db.exists("Serial No", serial_no):
|
||||||
sr = frappe.bean("Serial No", serial_no)
|
sr = frappe.get_doc("Serial No", serial_no)
|
||||||
|
|
||||||
if sr.item_code!=sle.item_code:
|
if sr.item_code!=sle.item_code:
|
||||||
frappe.throw(_("Serial No does not belong to Item") +
|
frappe.throw(_("Serial No does not belong to Item") +
|
||||||
@ -263,7 +263,7 @@ def update_serial_nos(sle, item_det):
|
|||||||
serial_nos = get_serial_nos(sle.serial_no)
|
serial_nos = get_serial_nos(sle.serial_no)
|
||||||
for serial_no in serial_nos:
|
for serial_no in serial_nos:
|
||||||
if frappe.db.exists("Serial No", serial_no):
|
if frappe.db.exists("Serial No", serial_no):
|
||||||
sr = frappe.bean("Serial No", serial_no)
|
sr = frappe.get_doc("Serial No", serial_no)
|
||||||
sr.make_controller().via_stock_ledger = True
|
sr.make_controller().via_stock_ledger = True
|
||||||
sr.warehouse = sle.warehouse if sle.actual_qty > 0 else None
|
sr.warehouse = sle.warehouse if sle.actual_qty > 0 else None
|
||||||
sr.save()
|
sr.save()
|
||||||
|
@ -337,7 +337,7 @@ class StockEntry(StockController):
|
|||||||
self.production_order)
|
self.production_order)
|
||||||
|
|
||||||
if self.production_order:
|
if self.production_order:
|
||||||
pro_bean = frappe.bean("Production Order", self.production_order)
|
pro_bean = frappe.get_doc("Production Order", self.production_order)
|
||||||
_validate_production_order(pro_bean)
|
_validate_production_order(pro_bean)
|
||||||
self.update_produced_qty(pro_bean)
|
self.update_produced_qty(pro_bean)
|
||||||
if self.purpose == "Manufacture/Repack":
|
if self.purpose == "Manufacture/Repack":
|
||||||
@ -749,7 +749,7 @@ return_map = {
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_return_jv(stock_entry):
|
def make_return_jv(stock_entry):
|
||||||
se = frappe.bean("Stock Entry", stock_entry)
|
se = frappe.get_doc("Stock Entry", stock_entry)
|
||||||
if not se.purpose in ["Sales Return", "Purchase Return"]:
|
if not se.purpose in ["Sales Return", "Purchase Return"]:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -840,7 +840,7 @@ def make_return_jv_from_delivery_note(se, ref):
|
|||||||
|
|
||||||
for se_item in se.get("mtn_details"):
|
for se_item in se.get("mtn_details"):
|
||||||
for sales_invoice in invoices_against_delivery:
|
for sales_invoice in invoices_against_delivery:
|
||||||
si = frappe.bean("Sales Invoice", sales_invoice)
|
si = frappe.get_doc("Sales Invoice", sales_invoice)
|
||||||
|
|
||||||
if se_item.item_code in packing_item_parent_map:
|
if se_item.item_code in packing_item_parent_map:
|
||||||
ref_item = si.doclist.get({"item_code": packing_item_parent_map[se_item.item_code]})
|
ref_item = si.doclist.get({"item_code": packing_item_parent_map[se_item.item_code]})
|
||||||
@ -897,7 +897,7 @@ def make_return_jv_from_purchase_receipt(se, ref):
|
|||||||
|
|
||||||
for se_item in se.get("mtn_details"):
|
for se_item in se.get("mtn_details"):
|
||||||
for purchase_invoice in invoice_against_receipt:
|
for purchase_invoice in invoice_against_receipt:
|
||||||
pi = frappe.bean("Purchase Invoice", purchase_invoice)
|
pi = frappe.get_doc("Purchase Invoice", purchase_invoice)
|
||||||
ref_item = pi.doclist.get({"item_code": se_item.item_code})
|
ref_item = pi.doclist.get({"item_code": se_item.item_code})
|
||||||
|
|
||||||
if not ref_item:
|
if not ref_item:
|
||||||
|
@ -22,11 +22,11 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
frappe.db.set_value("Stock Settings", None, "auto_indent", True)
|
frappe.db.set_value("Stock Settings", None, "auto_indent", True)
|
||||||
|
|
||||||
st1 = frappe.bean(copy=test_records[0])
|
st1 = frappe.get_doc(copy=test_records[0])
|
||||||
st1.insert()
|
st1.insert()
|
||||||
st1.submit()
|
st1.submit()
|
||||||
|
|
||||||
st2 = frappe.bean(copy=test_records[1])
|
st2 = frappe.get_doc(copy=test_records[1])
|
||||||
st2.insert()
|
st2.insert()
|
||||||
st2.submit()
|
st2.submit()
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
self._clear_stock_account_balance()
|
self._clear_stock_account_balance()
|
||||||
set_perpetual_inventory()
|
set_perpetual_inventory()
|
||||||
|
|
||||||
mr = frappe.bean(copy=test_records[0])
|
mr = frappe.get_doc(copy=test_records[0])
|
||||||
mr.insert()
|
mr.insert()
|
||||||
mr.submit()
|
mr.submit()
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
self._insert_material_receipt()
|
self._insert_material_receipt()
|
||||||
|
|
||||||
mi = frappe.bean(copy=test_records[1])
|
mi = frappe.get_doc(copy=test_records[1])
|
||||||
mi.insert()
|
mi.insert()
|
||||||
mi.submit()
|
mi.submit()
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
self._insert_material_receipt()
|
self._insert_material_receipt()
|
||||||
|
|
||||||
mtn = frappe.bean(copy=test_records[2])
|
mtn = frappe.get_doc(copy=test_records[2])
|
||||||
mtn.insert()
|
mtn.insert()
|
||||||
mtn.submit()
|
mtn.submit()
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
self._insert_material_receipt()
|
self._insert_material_receipt()
|
||||||
|
|
||||||
repack = frappe.bean(copy=test_records[3])
|
repack = frappe.get_doc(copy=test_records[3])
|
||||||
repack.insert()
|
repack.insert()
|
||||||
repack.submit()
|
repack.submit()
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
self._insert_material_receipt()
|
self._insert_material_receipt()
|
||||||
|
|
||||||
repack = frappe.bean(copy=test_records[3])
|
repack = frappe.get_doc(copy=test_records[3])
|
||||||
repack.doclist[2].incoming_rate = 6000
|
repack.doclist[2].incoming_rate = 6000
|
||||||
repack.insert()
|
repack.insert()
|
||||||
repack.submit()
|
repack.submit()
|
||||||
@ -218,11 +218,11 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
def _insert_material_receipt(self):
|
def _insert_material_receipt(self):
|
||||||
self._clear_stock_account_balance()
|
self._clear_stock_account_balance()
|
||||||
se1 = frappe.bean(copy=test_records[0])
|
se1 = frappe.get_doc(copy=test_records[0])
|
||||||
se1.insert()
|
se1.insert()
|
||||||
se1.submit()
|
se1.submit()
|
||||||
|
|
||||||
se2 = frappe.bean(copy=test_records[0])
|
se2 = frappe.get_doc(copy=test_records[0])
|
||||||
se2.doclist[1].item_code = "_Test Item Home Desktop 100"
|
se2.doclist[1].item_code = "_Test Item Home Desktop 100"
|
||||||
se2.insert()
|
se2.insert()
|
||||||
se2.submit()
|
se2.submit()
|
||||||
@ -240,11 +240,11 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
import test_records as sales_invoice_test_records
|
import test_records as sales_invoice_test_records
|
||||||
|
|
||||||
# invalid sales invoice as update stock not checked
|
# invalid sales invoice as update stock not checked
|
||||||
si = frappe.bean(copy=sales_invoice_test_records[1])
|
si = frappe.get_doc(copy=sales_invoice_test_records[1])
|
||||||
si.insert()
|
si.insert()
|
||||||
si.submit()
|
si.submit()
|
||||||
|
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.purpose = "Sales Return"
|
se.purpose = "Sales Return"
|
||||||
se.sales_invoice_no = si.name
|
se.sales_invoice_no = si.name
|
||||||
se.doclist[1].qty = returned_qty
|
se.doclist[1].qty = returned_qty
|
||||||
@ -257,7 +257,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
actual_qty_0 = self._get_actual_qty()
|
actual_qty_0 = self._get_actual_qty()
|
||||||
|
|
||||||
# insert a pos invoice with update stock
|
# insert a pos invoice with update stock
|
||||||
si = frappe.bean(copy=sales_invoice_test_records[1])
|
si = frappe.get_doc(copy=sales_invoice_test_records[1])
|
||||||
si.is_pos = si.update_stock = 1
|
si.is_pos = si.update_stock = 1
|
||||||
si.doclist[1].warehouse = "_Test Warehouse - _TC"
|
si.doclist[1].warehouse = "_Test Warehouse - _TC"
|
||||||
si.doclist[1].item_code = item_code
|
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)
|
self.assertEquals(actual_qty_0 - delivered_qty, actual_qty_1)
|
||||||
|
|
||||||
# check if item is validated
|
# check if item is validated
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.purpose = "Sales Return"
|
se.purpose = "Sales Return"
|
||||||
se.sales_invoice_no = si.name
|
se.sales_invoice_no = si.name
|
||||||
se.posting_date = "2013-03-10"
|
se.posting_date = "2013-03-10"
|
||||||
@ -284,7 +284,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
self.assertRaises(frappe.DoesNotExistError, se.insert)
|
self.assertRaises(frappe.DoesNotExistError, se.insert)
|
||||||
|
|
||||||
# try again
|
# try again
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.purpose = "Sales Return"
|
se.purpose = "Sales Return"
|
||||||
se.posting_date = "2013-03-10"
|
se.posting_date = "2013-03-10"
|
||||||
se.fiscal_year = "_Test Fiscal Year 2013"
|
se.fiscal_year = "_Test Fiscal Year 2013"
|
||||||
@ -321,7 +321,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
actual_qty_0 = self._get_actual_qty()
|
actual_qty_0 = self._get_actual_qty()
|
||||||
# make a delivery note based on this invoice
|
# make a delivery note based on this invoice
|
||||||
dn = frappe.bean(copy=delivery_note_test_records[0])
|
dn = frappe.get_doc(copy=delivery_note_test_records[0])
|
||||||
dn.doclist[1].item_code = item_code
|
dn.doclist[1].item_code = item_code
|
||||||
dn.insert()
|
dn.insert()
|
||||||
dn.submit()
|
dn.submit()
|
||||||
@ -332,7 +332,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
si_doclist = make_sales_invoice(dn.name)
|
si_doclist = make_sales_invoice(dn.name)
|
||||||
|
|
||||||
si = frappe.bean(si_doclist)
|
si = frappe.get_doc(si_doclist)
|
||||||
si.posting_date = dn.posting_date
|
si.posting_date = dn.posting_date
|
||||||
si.debit_to = "_Test Customer - _TC"
|
si.debit_to = "_Test Customer - _TC"
|
||||||
for d in si.get("entries"):
|
for d in si.get("entries"):
|
||||||
@ -342,7 +342,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
si.submit()
|
si.submit()
|
||||||
|
|
||||||
# insert and submit stock entry for sales return
|
# insert and submit stock entry for sales return
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.purpose = "Sales Return"
|
se.purpose = "Sales Return"
|
||||||
se.delivery_note_no = dn.name
|
se.delivery_note_no = dn.name
|
||||||
se.posting_date = "2013-03-10"
|
se.posting_date = "2013-03-10"
|
||||||
@ -410,7 +410,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
actual_qty_0 = self._get_actual_qty()
|
actual_qty_0 = self._get_actual_qty()
|
||||||
|
|
||||||
so = frappe.bean(copy=sales_order_test_records[0])
|
so = frappe.get_doc(copy=sales_order_test_records[0])
|
||||||
so.doclist[1].item_code = item_code
|
so.doclist[1].item_code = item_code
|
||||||
so.doclist[1].qty = 5.0
|
so.doclist[1].qty = 5.0
|
||||||
so.insert()
|
so.insert()
|
||||||
@ -418,7 +418,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
dn_doclist = make_delivery_note(so.name)
|
dn_doclist = make_delivery_note(so.name)
|
||||||
|
|
||||||
dn = frappe.bean(dn_doclist)
|
dn = frappe.get_doc(dn_doclist)
|
||||||
dn.status = "Draft"
|
dn.status = "Draft"
|
||||||
dn.posting_date = so.delivery_date
|
dn.posting_date = so.delivery_date
|
||||||
dn.insert()
|
dn.insert()
|
||||||
@ -430,7 +430,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
si_doclist = make_sales_invoice(so.name)
|
si_doclist = make_sales_invoice(so.name)
|
||||||
|
|
||||||
si = frappe.bean(si_doclist)
|
si = frappe.get_doc(si_doclist)
|
||||||
si.posting_date = dn.posting_date
|
si.posting_date = dn.posting_date
|
||||||
si.debit_to = "_Test Customer - _TC"
|
si.debit_to = "_Test Customer - _TC"
|
||||||
for d in si.get("entries"):
|
for d in si.get("entries"):
|
||||||
@ -440,7 +440,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
si.submit()
|
si.submit()
|
||||||
|
|
||||||
# insert and submit stock entry for sales return
|
# insert and submit stock entry for sales return
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.purpose = "Sales Return"
|
se.purpose = "Sales Return"
|
||||||
se.delivery_note_no = dn.name
|
se.delivery_note_no = dn.name
|
||||||
se.posting_date = "2013-03-10"
|
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
|
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
|
||||||
|
|
||||||
# submit purchase receipt
|
# submit purchase receipt
|
||||||
pr = frappe.bean(copy=purchase_receipt_test_records[0])
|
pr = frappe.get_doc(copy=purchase_receipt_test_records[0])
|
||||||
pr.insert()
|
pr.insert()
|
||||||
pr.submit()
|
pr.submit()
|
||||||
|
|
||||||
@ -476,7 +476,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
pi_doclist = make_purchase_invoice(pr.name)
|
pi_doclist = make_purchase_invoice(pr.name)
|
||||||
|
|
||||||
pi = frappe.bean(pi_doclist)
|
pi = frappe.get_doc(pi_doclist)
|
||||||
pi.posting_date = pr.posting_date
|
pi.posting_date = pr.posting_date
|
||||||
pi.credit_to = "_Test Supplier - _TC"
|
pi.credit_to = "_Test Supplier - _TC"
|
||||||
for d in pi.get("entries"):
|
for d in pi.get("entries"):
|
||||||
@ -492,7 +492,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
pi.submit()
|
pi.submit()
|
||||||
|
|
||||||
# submit purchase return
|
# submit purchase return
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.purpose = "Purchase Return"
|
se.purpose = "Purchase Return"
|
||||||
se.purchase_receipt_no = pr.name
|
se.purchase_receipt_no = pr.name
|
||||||
se.posting_date = "2013-03-01"
|
se.posting_date = "2013-03-01"
|
||||||
@ -518,7 +518,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
prev_se, pr_docname = self.test_purchase_receipt_return()
|
prev_se, pr_docname = self.test_purchase_receipt_return()
|
||||||
|
|
||||||
# submit purchase return - return another 6 qtys so that exception is raised
|
# submit purchase return - return another 6 qtys so that exception is raised
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.purpose = "Purchase Return"
|
se.purpose = "Purchase Return"
|
||||||
se.purchase_receipt_no = pr_docname
|
se.purchase_receipt_no = pr_docname
|
||||||
se.posting_date = "2013-03-01"
|
se.posting_date = "2013-03-01"
|
||||||
@ -559,7 +559,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
make_purchase_receipt, make_purchase_invoice
|
make_purchase_receipt, make_purchase_invoice
|
||||||
|
|
||||||
# submit purchase receipt
|
# submit purchase receipt
|
||||||
po = frappe.bean(copy=purchase_order_test_records[0])
|
po = frappe.get_doc(copy=purchase_order_test_records[0])
|
||||||
po.is_subcontracted = None
|
po.is_subcontracted = None
|
||||||
po.doclist[1].item_code = "_Test Item"
|
po.doclist[1].item_code = "_Test Item"
|
||||||
po.doclist[1].rate = 50
|
po.doclist[1].rate = 50
|
||||||
@ -568,7 +568,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
pr_doclist = make_purchase_receipt(po.name)
|
pr_doclist = make_purchase_receipt(po.name)
|
||||||
|
|
||||||
pr = frappe.bean(pr_doclist)
|
pr = frappe.get_doc(pr_doclist)
|
||||||
pr.posting_date = po.transaction_date
|
pr.posting_date = po.transaction_date
|
||||||
pr.insert()
|
pr.insert()
|
||||||
pr.submit()
|
pr.submit()
|
||||||
@ -579,7 +579,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
pi_doclist = make_purchase_invoice(po.name)
|
pi_doclist = make_purchase_invoice(po.name)
|
||||||
|
|
||||||
pi = frappe.bean(pi_doclist)
|
pi = frappe.get_doc(pi_doclist)
|
||||||
pi.posting_date = pr.posting_date
|
pi.posting_date = pr.posting_date
|
||||||
pi.credit_to = "_Test Supplier - _TC"
|
pi.credit_to = "_Test Supplier - _TC"
|
||||||
for d in pi.get("entries"):
|
for d in pi.get("entries"):
|
||||||
@ -594,7 +594,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
pi.submit()
|
pi.submit()
|
||||||
|
|
||||||
# submit purchase return
|
# submit purchase return
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.purpose = "Purchase Return"
|
se.purpose = "Purchase Return"
|
||||||
se.purchase_receipt_no = pr.name
|
se.purchase_receipt_no = pr.name
|
||||||
se.posting_date = "2013-03-01"
|
se.posting_date = "2013-03-01"
|
||||||
@ -621,13 +621,13 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
frappe.db.set_default("company", "_Test Company")
|
frappe.db.set_default("company", "_Test Company")
|
||||||
|
|
||||||
def test_serial_no_not_reqd(self):
|
def test_serial_no_not_reqd(self):
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.doclist[1].serial_no = "ABCD"
|
se.doclist[1].serial_no = "ABCD"
|
||||||
se.insert()
|
se.insert()
|
||||||
self.assertRaises(SerialNoNotRequiredError, se.submit)
|
self.assertRaises(SerialNoNotRequiredError, se.submit)
|
||||||
|
|
||||||
def test_serial_no_reqd(self):
|
def test_serial_no_reqd(self):
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.doclist[1].item_code = "_Test Serialized Item"
|
se.doclist[1].item_code = "_Test Serialized Item"
|
||||||
se.doclist[1].qty = 2
|
se.doclist[1].qty = 2
|
||||||
se.doclist[1].transfer_qty = 2
|
se.doclist[1].transfer_qty = 2
|
||||||
@ -635,7 +635,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
self.assertRaises(SerialNoRequiredError, se.submit)
|
self.assertRaises(SerialNoRequiredError, se.submit)
|
||||||
|
|
||||||
def test_serial_no_qty_more(self):
|
def test_serial_no_qty_more(self):
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.doclist[1].item_code = "_Test Serialized Item"
|
se.doclist[1].item_code = "_Test Serialized Item"
|
||||||
se.doclist[1].qty = 2
|
se.doclist[1].qty = 2
|
||||||
se.doclist[1].serial_no = "ABCD\nEFGH\nXYZ"
|
se.doclist[1].serial_no = "ABCD\nEFGH\nXYZ"
|
||||||
@ -644,7 +644,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
self.assertRaises(SerialNoQtyError, se.submit)
|
self.assertRaises(SerialNoQtyError, se.submit)
|
||||||
|
|
||||||
def test_serial_no_qty_less(self):
|
def test_serial_no_qty_less(self):
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.doclist[1].item_code = "_Test Serialized Item"
|
se.doclist[1].item_code = "_Test Serialized Item"
|
||||||
se.doclist[1].qty = 2
|
se.doclist[1].qty = 2
|
||||||
se.doclist[1].serial_no = "ABCD"
|
se.doclist[1].serial_no = "ABCD"
|
||||||
@ -654,7 +654,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
def test_serial_no_transfer_in(self):
|
def test_serial_no_transfer_in(self):
|
||||||
self._clear_stock_account_balance()
|
self._clear_stock_account_balance()
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.doclist[1].item_code = "_Test Serialized Item"
|
se.doclist[1].item_code = "_Test Serialized Item"
|
||||||
se.doclist[1].qty = 2
|
se.doclist[1].qty = 2
|
||||||
se.doclist[1].serial_no = "ABCD\nEFGH"
|
se.doclist[1].serial_no = "ABCD\nEFGH"
|
||||||
@ -670,7 +670,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
def test_serial_no_not_exists(self):
|
def test_serial_no_not_exists(self):
|
||||||
self._clear_stock_account_balance()
|
self._clear_stock_account_balance()
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.purpose = "Material Issue"
|
se.purpose = "Material Issue"
|
||||||
se.doclist[1].item_code = "_Test Serialized Item"
|
se.doclist[1].item_code = "_Test Serialized Item"
|
||||||
se.doclist[1].qty = 2
|
se.doclist[1].qty = 2
|
||||||
@ -685,7 +685,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
self._clear_stock_account_balance()
|
self._clear_stock_account_balance()
|
||||||
self.test_serial_by_series()
|
self.test_serial_by_series()
|
||||||
|
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.doclist[1].item_code = "_Test Serialized Item With Series"
|
se.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||||
se.doclist[1].qty = 1
|
se.doclist[1].qty = 1
|
||||||
se.doclist[1].serial_no = "ABCD00001"
|
se.doclist[1].serial_no = "ABCD00001"
|
||||||
@ -708,7 +708,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
self._clear_stock_account_balance()
|
self._clear_stock_account_balance()
|
||||||
self.test_serial_by_series()
|
self.test_serial_by_series()
|
||||||
|
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.purpose = "Material Transfer"
|
se.purpose = "Material Transfer"
|
||||||
se.doclist[1].item_code = "_Test Serialized Item"
|
se.doclist[1].item_code = "_Test Serialized Item"
|
||||||
se.doclist[1].qty = 1
|
se.doclist[1].qty = 1
|
||||||
@ -724,7 +724,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
se = make_serialized_item()
|
se = make_serialized_item()
|
||||||
serial_no = get_serial_nos(se.doclist[1].serial_no)[0]
|
serial_no = get_serial_nos(se.doclist[1].serial_no)[0]
|
||||||
|
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.purpose = "Material Transfer"
|
se.purpose = "Material Transfer"
|
||||||
se.doclist[1].item_code = "_Test Serialized Item With Series"
|
se.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||||
se.doclist[1].qty = 1
|
se.doclist[1].qty = 1
|
||||||
@ -743,7 +743,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
self._clear_stock_account_balance()
|
self._clear_stock_account_balance()
|
||||||
make_serialized_item()
|
make_serialized_item()
|
||||||
|
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.purpose = "Material Transfer"
|
se.purpose = "Material Transfer"
|
||||||
se.doclist[1].item_code = "_Test Serialized Item With Series"
|
se.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||||
se.doclist[1].qty = 1
|
se.doclist[1].qty = 1
|
||||||
@ -765,12 +765,12 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
def test_warehouse_company_validation(self):
|
def test_warehouse_company_validation(self):
|
||||||
set_perpetual_inventory(0)
|
set_perpetual_inventory(0)
|
||||||
self._clear_stock_account_balance()
|
self._clear_stock_account_balance()
|
||||||
frappe.bean("User", "test2@example.com").get_controller()\
|
frappe.get_doc("User", "test2@example.com").get_controller()\
|
||||||
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
||||||
frappe.set_user("test2@example.com")
|
frappe.set_user("test2@example.com")
|
||||||
|
|
||||||
from erpnext.stock.utils import InvalidWarehouseCompany
|
from erpnext.stock.utils import InvalidWarehouseCompany
|
||||||
st1 = frappe.bean(copy=test_records[0])
|
st1 = frappe.get_doc(copy=test_records[0])
|
||||||
st1.doclist[1].t_warehouse="_Test Warehouse 2 - _TC1"
|
st1.doclist[1].t_warehouse="_Test Warehouse 2 - _TC1"
|
||||||
st1.insert()
|
st1.insert()
|
||||||
self.assertRaises(InvalidWarehouseCompany, st1.submit)
|
self.assertRaises(InvalidWarehouseCompany, st1.submit)
|
||||||
@ -783,19 +783,19 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
frappe.defaults.add_default("Warehouse", "_Test Warehouse 1 - _TC1", "test@example.com", "Restriction")
|
frappe.defaults.add_default("Warehouse", "_Test Warehouse 1 - _TC1", "test@example.com", "Restriction")
|
||||||
frappe.defaults.add_default("Warehouse", "_Test Warehouse 2 - _TC1", "test2@example.com", "Restriction")
|
frappe.defaults.add_default("Warehouse", "_Test Warehouse 2 - _TC1", "test2@example.com", "Restriction")
|
||||||
frappe.bean("User", "test@example.com").get_controller()\
|
frappe.get_doc("User", "test@example.com").get_controller()\
|
||||||
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
||||||
frappe.bean("User", "test2@example.com").get_controller()\
|
frappe.get_doc("User", "test2@example.com").get_controller()\
|
||||||
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
.add_roles("Sales User", "Sales Manager", "Material User", "Material Manager")
|
||||||
|
|
||||||
frappe.set_user("test@example.com")
|
frappe.set_user("test@example.com")
|
||||||
st1 = frappe.bean(copy=test_records[0])
|
st1 = frappe.get_doc(copy=test_records[0])
|
||||||
st1.company = "_Test Company 1"
|
st1.company = "_Test Company 1"
|
||||||
st1.doclist[1].t_warehouse="_Test Warehouse 2 - _TC1"
|
st1.doclist[1].t_warehouse="_Test Warehouse 2 - _TC1"
|
||||||
self.assertRaises(BeanPermissionError, st1.insert)
|
self.assertRaises(BeanPermissionError, st1.insert)
|
||||||
|
|
||||||
frappe.set_user("test2@example.com")
|
frappe.set_user("test2@example.com")
|
||||||
st1 = frappe.bean(copy=test_records[0])
|
st1 = frappe.get_doc(copy=test_records[0])
|
||||||
st1.company = "_Test Company 1"
|
st1.company = "_Test Company 1"
|
||||||
st1.doclist[1].t_warehouse="_Test Warehouse 2 - _TC1"
|
st1.doclist[1].t_warehouse="_Test Warehouse 2 - _TC1"
|
||||||
st1.insert()
|
st1.insert()
|
||||||
@ -811,18 +811,18 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
# test freeze_stocks_upto
|
# test freeze_stocks_upto
|
||||||
date_newer_than_test_records = add_days(getdate(test_records[0][0]['posting_date']), 5)
|
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)
|
frappe.db.set_value("Stock Settings", None, "stock_frozen_upto", date_newer_than_test_records)
|
||||||
se = frappe.bean(copy=test_records[0]).insert()
|
se = frappe.get_doc(copy=test_records[0]).insert()
|
||||||
self.assertRaises (StockFreezeError, se.submit)
|
self.assertRaises (StockFreezeError, se.submit)
|
||||||
frappe.db.set_value("Stock Settings", None, "stock_frozen_upto", '')
|
frappe.db.set_value("Stock Settings", None, "stock_frozen_upto", '')
|
||||||
|
|
||||||
# test freeze_stocks_upto_days
|
# test freeze_stocks_upto_days
|
||||||
frappe.db.set_value("Stock Settings", None, "stock_frozen_upto_days", 7)
|
frappe.db.set_value("Stock Settings", None, "stock_frozen_upto_days", 7)
|
||||||
se = frappe.bean(copy=test_records[0]).insert()
|
se = frappe.get_doc(copy=test_records[0]).insert()
|
||||||
self.assertRaises (StockFreezeError, se.submit)
|
self.assertRaises (StockFreezeError, se.submit)
|
||||||
frappe.db.set_value("Stock Settings", None, "stock_frozen_upto_days", 0)
|
frappe.db.set_value("Stock Settings", None, "stock_frozen_upto_days", 0)
|
||||||
|
|
||||||
def make_serialized_item():
|
def make_serialized_item():
|
||||||
se = frappe.bean(copy=test_records[0])
|
se = frappe.get_doc(copy=test_records[0])
|
||||||
se.doclist[1].item_code = "_Test Serialized Item With Series"
|
se.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||||
se.doclist[1].qty = 2
|
se.doclist[1].qty = 2
|
||||||
se.doclist[1].transfer_qty = 2
|
se.doclist[1].transfer_qty = 2
|
||||||
|
@ -42,7 +42,7 @@ class StockLedger(Document):
|
|||||||
|
|
||||||
def make_entry(self, args):
|
def make_entry(self, args):
|
||||||
args.update({"doctype": "Stock Ledger Entry"})
|
args.update({"doctype": "Stock Ledger Entry"})
|
||||||
sle = frappe.bean([args])
|
sle = frappe.get_doc([args])
|
||||||
sle.ignore_permissions = 1
|
sle.ignore_permissions = 1
|
||||||
sle.insert()
|
sle.insert()
|
||||||
return sle.name
|
return sle.name
|
||||||
|
@ -97,7 +97,7 @@ class StockReconciliation(StockController):
|
|||||||
# using try except to catch all validation msgs and display together
|
# using try except to catch all validation msgs and display together
|
||||||
|
|
||||||
try:
|
try:
|
||||||
item = frappe.doc("Item", item_code)
|
item = frappe.get_doc("Item", item_code)
|
||||||
|
|
||||||
# end of life and stock item
|
# end of life and stock item
|
||||||
validate_end_of_life(item_code, item.end_of_life, verbose=0)
|
validate_end_of_life(item_code, item.end_of_life, verbose=0)
|
||||||
|
@ -175,7 +175,7 @@ class TestStockReconciliation(unittest.TestCase):
|
|||||||
frappe.db.sql("delete from `tabGL Entry`")
|
frappe.db.sql("delete from `tabGL Entry`")
|
||||||
|
|
||||||
def submit_stock_reconciliation(self, qty, rate, posting_date, posting_time):
|
def submit_stock_reconciliation(self, qty, rate, posting_date, posting_time):
|
||||||
stock_reco = frappe.bean([{
|
stock_reco = frappe.get_doc([{
|
||||||
"doctype": "Stock Reconciliation",
|
"doctype": "Stock Reconciliation",
|
||||||
"posting_date": posting_date,
|
"posting_date": posting_date,
|
||||||
"posting_time": posting_time,
|
"posting_time": posting_time,
|
||||||
@ -221,11 +221,11 @@ class TestStockReconciliation(unittest.TestCase):
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
pr = frappe.bean(copy=stock_entry)
|
pr = frappe.get_doc(copy=stock_entry)
|
||||||
pr.insert()
|
pr.insert()
|
||||||
pr.submit()
|
pr.submit()
|
||||||
|
|
||||||
pr1 = frappe.bean(copy=stock_entry)
|
pr1 = frappe.get_doc(copy=stock_entry)
|
||||||
pr1.posting_date = "2012-12-15"
|
pr1.posting_date = "2012-12-15"
|
||||||
pr1.posting_time = "02:00"
|
pr1.posting_time = "02:00"
|
||||||
pr1.doclist[1].qty = 10
|
pr1.doclist[1].qty = 10
|
||||||
@ -234,7 +234,7 @@ class TestStockReconciliation(unittest.TestCase):
|
|||||||
pr1.insert()
|
pr1.insert()
|
||||||
pr1.submit()
|
pr1.submit()
|
||||||
|
|
||||||
pr2 = frappe.bean(copy=stock_entry)
|
pr2 = frappe.get_doc(copy=stock_entry)
|
||||||
pr2.posting_date = "2012-12-25"
|
pr2.posting_date = "2012-12-25"
|
||||||
pr2.posting_time = "03:00"
|
pr2.posting_time = "03:00"
|
||||||
pr2.purpose = "Material Issue"
|
pr2.purpose = "Material Issue"
|
||||||
@ -246,7 +246,7 @@ class TestStockReconciliation(unittest.TestCase):
|
|||||||
pr2.insert()
|
pr2.insert()
|
||||||
pr2.submit()
|
pr2.submit()
|
||||||
|
|
||||||
pr3 = frappe.bean(copy=stock_entry)
|
pr3 = frappe.get_doc(copy=stock_entry)
|
||||||
pr3.posting_date = "2012-12-31"
|
pr3.posting_date = "2012-12-31"
|
||||||
pr3.posting_time = "08:00"
|
pr3.posting_time = "08:00"
|
||||||
pr3.purpose = "Material Issue"
|
pr3.purpose = "Material Issue"
|
||||||
@ -259,7 +259,7 @@ class TestStockReconciliation(unittest.TestCase):
|
|||||||
pr3.submit()
|
pr3.submit()
|
||||||
|
|
||||||
|
|
||||||
pr4 = frappe.bean(copy=stock_entry)
|
pr4 = frappe.get_doc(copy=stock_entry)
|
||||||
pr4.posting_date = "2013-01-05"
|
pr4.posting_date = "2013-01-05"
|
||||||
pr4.fiscal_year = "_Test Fiscal Year 2013"
|
pr4.fiscal_year = "_Test Fiscal Year 2013"
|
||||||
pr4.posting_time = "07:00"
|
pr4.posting_time = "07:00"
|
||||||
|
@ -34,7 +34,7 @@ class StockUomReplaceUtility(Document):
|
|||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
def update_item_master(self):
|
def update_item_master(self):
|
||||||
item_bean = frappe.bean("Item", self.item_code)
|
item_bean = frappe.get_doc("Item", self.item_code)
|
||||||
item_bean.stock_uom = self.new_stock_uom
|
item_bean.stock_uom = self.new_stock_uom
|
||||||
item_bean.save()
|
item_bean.save()
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class Warehouse(Document):
|
|||||||
{"account_type": "Warehouse", "company": self.company,
|
{"account_type": "Warehouse", "company": self.company,
|
||||||
"master_name": self.name}, ["name", "parent_account"])
|
"master_name": self.name}, ["name", "parent_account"])
|
||||||
if warehouse_account and warehouse_account[1] != self.create_account_under:
|
if warehouse_account and warehouse_account[1] != self.create_account_under:
|
||||||
acc_bean = frappe.bean("Account", warehouse_account[0])
|
acc_bean = frappe.get_doc("Account", warehouse_account[0])
|
||||||
acc_bean.parent_account = self.create_account_under
|
acc_bean.parent_account = self.create_account_under
|
||||||
acc_bean.save()
|
acc_bean.save()
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ class Warehouse(Document):
|
|||||||
if self.get("__islocal") or not frappe.db.get_value(
|
if self.get("__islocal") or not frappe.db.get_value(
|
||||||
"Stock Ledger Entry", {"warehouse": self.name}):
|
"Stock Ledger Entry", {"warehouse": self.name}):
|
||||||
self.validate_parent_account()
|
self.validate_parent_account()
|
||||||
ac_bean = frappe.bean({
|
ac_bean = frappe.get_doc({
|
||||||
"doctype": "Account",
|
"doctype": "Account",
|
||||||
'account_name': self.warehouse_name,
|
'account_name': self.warehouse_name,
|
||||||
'parent_account': self.create_account_under,
|
'parent_account': self.create_account_under,
|
||||||
|
@ -47,7 +47,7 @@ def get_item_details(args):
|
|||||||
elif not args.item_code and args.serial_no:
|
elif not args.item_code and args.serial_no:
|
||||||
args.item_code = get_item_code(serial_no=args.serial_no)
|
args.item_code = get_item_code(serial_no=args.serial_no)
|
||||||
|
|
||||||
item_bean = frappe.bean("Item", args.item_code)
|
item_bean = frappe.get_doc("Item", args.item_code)
|
||||||
item = item_bean.doc
|
item = item_bean.doc
|
||||||
|
|
||||||
validate_item_details(args, item)
|
validate_item_details(args, item)
|
||||||
|
@ -49,7 +49,7 @@ def set_as_cancel(voucher_type, voucher_no):
|
|||||||
|
|
||||||
def make_entry(args):
|
def make_entry(args):
|
||||||
args.update({"doctype": "Stock Ledger Entry"})
|
args.update({"doctype": "Stock Ledger Entry"})
|
||||||
sle = frappe.bean([args])
|
sle = frappe.get_doc([args])
|
||||||
sle.ignore_permissions = 1
|
sle.ignore_permissions = 1
|
||||||
sle.insert()
|
sle.insert()
|
||||||
sle.submit()
|
sle.submit()
|
||||||
@ -137,7 +137,7 @@ def update_entries_after(args, verbose=1):
|
|||||||
# update bin
|
# update bin
|
||||||
if not frappe.db.exists({"doctype": "Bin", "item_code": args["item_code"],
|
if not frappe.db.exists({"doctype": "Bin", "item_code": args["item_code"],
|
||||||
"warehouse": args["warehouse"]}):
|
"warehouse": args["warehouse"]}):
|
||||||
bin_wrapper = frappe.bean([{
|
bin_wrapper = frappe.get_doc([{
|
||||||
"doctype": "Bin",
|
"doctype": "Bin",
|
||||||
"item_code": args["item_code"],
|
"item_code": args["item_code"],
|
||||||
"warehouse": args["warehouse"],
|
"warehouse": args["warehouse"],
|
||||||
|
@ -40,7 +40,7 @@ def get_latest_stock_balance():
|
|||||||
def get_bin(item_code, warehouse):
|
def get_bin(item_code, warehouse):
|
||||||
bin = frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse})
|
bin = frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse})
|
||||||
if not bin:
|
if not bin:
|
||||||
bin_wrapper = frappe.bean([{
|
bin_wrapper = frappe.get_doc([{
|
||||||
"doctype": "Bin",
|
"doctype": "Bin",
|
||||||
"item_code": item_code,
|
"item_code": item_code,
|
||||||
"warehouse": warehouse,
|
"warehouse": warehouse,
|
||||||
@ -246,7 +246,7 @@ def create_material_request(material_requests):
|
|||||||
}]
|
}]
|
||||||
|
|
||||||
for d in items:
|
for d in items:
|
||||||
item = frappe.doc("Item", d.item_code)
|
item = frappe.get_doc("Item", d.item_code)
|
||||||
mr.append({
|
mr.append({
|
||||||
"doctype": "Material Request Item",
|
"doctype": "Material Request Item",
|
||||||
"parenttype": "Material Request",
|
"parenttype": "Material Request",
|
||||||
@ -262,7 +262,7 @@ def create_material_request(material_requests):
|
|||||||
"brand": item.brand,
|
"brand": item.brand,
|
||||||
})
|
})
|
||||||
|
|
||||||
mr_bean = frappe.bean(mr)
|
mr_bean = frappe.get_doc(mr)
|
||||||
mr_bean.insert()
|
mr_bean.insert()
|
||||||
mr_bean.submit()
|
mr_bean.submit()
|
||||||
mr_list.append(mr_bean)
|
mr_list.append(mr_bean)
|
||||||
|
@ -58,7 +58,7 @@ class MaintenanceSchedule(TransactionBase):
|
|||||||
self.update_amc_date(serial_nos, d.end_date)
|
self.update_amc_date(serial_nos, d.end_date)
|
||||||
|
|
||||||
if d.sales_person not in email_map:
|
if d.sales_person not in email_map:
|
||||||
sp = frappe.bean("Sales Person", d.sales_person).make_controller()
|
sp = frappe.get_doc("Sales Person", d.sales_person).make_controller()
|
||||||
email_map[d.sales_person] = sp.get_email_id()
|
email_map[d.sales_person] = sp.get_email_id()
|
||||||
|
|
||||||
scheduled_date = frappe.db.sql("""select scheduled_date from
|
scheduled_date = frappe.db.sql("""select scheduled_date from
|
||||||
@ -69,7 +69,7 @@ class MaintenanceSchedule(TransactionBase):
|
|||||||
if email_map[d.sales_person]:
|
if email_map[d.sales_person]:
|
||||||
description = "Reference: %s, Item Code: %s and Customer: %s" % \
|
description = "Reference: %s, Item Code: %s and Customer: %s" % \
|
||||||
(self.name, d.item_code, self.customer)
|
(self.name, d.item_code, self.customer)
|
||||||
frappe.bean({
|
frappe.get_doc({
|
||||||
"doctype": "Event",
|
"doctype": "Event",
|
||||||
"owner": email_map[d.sales_person] or self.owner,
|
"owner": email_map[d.sales_person] or self.owner,
|
||||||
"subject": description,
|
"subject": description,
|
||||||
@ -203,7 +203,7 @@ class MaintenanceSchedule(TransactionBase):
|
|||||||
|
|
||||||
def update_amc_date(self, serial_nos, amc_expiry_date=None):
|
def update_amc_date(self, serial_nos, amc_expiry_date=None):
|
||||||
for serial_no in serial_nos:
|
for serial_no in serial_nos:
|
||||||
serial_no_bean = frappe.bean("Serial No", serial_no)
|
serial_no_bean = frappe.get_doc("Serial No", serial_no)
|
||||||
serial_no_bean.amc_expiry_date = amc_expiry_date
|
serial_no_bean.amc_expiry_date = amc_expiry_date
|
||||||
serial_no_bean.save()
|
serial_no_bean.save()
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ def create_lead(email_id):
|
|||||||
if frappe.db.get_value("Lead", {"email_id": email_id}):
|
if frappe.db.get_value("Lead", {"email_id": email_id}):
|
||||||
return
|
return
|
||||||
|
|
||||||
lead = frappe.bean({
|
lead = frappe.get_doc({
|
||||||
"doctype": "Lead",
|
"doctype": "Lead",
|
||||||
"email_id": email_id,
|
"email_id": email_id,
|
||||||
"lead_name": real_name or email_id,
|
"lead_name": real_name or email_id,
|
||||||
|
@ -5,7 +5,7 @@ import frappe, unittest
|
|||||||
|
|
||||||
class TestNewsletter(unittest.TestCase):
|
class TestNewsletter(unittest.TestCase):
|
||||||
def test_get_recipients_lead(self):
|
def test_get_recipients_lead(self):
|
||||||
w = frappe.bean(test_records[0])
|
w = frappe.get_doc(test_records[0])
|
||||||
w.insert()
|
w.insert()
|
||||||
self.assertTrue("test_lead@example.com" in w.controller.get_recipients())
|
self.assertTrue("test_lead@example.com" in w.controller.get_recipients())
|
||||||
frappe.db.sql("""delete from `tabBulk Email`""")
|
frappe.db.sql("""delete from `tabBulk Email`""")
|
||||||
@ -13,24 +13,24 @@ class TestNewsletter(unittest.TestCase):
|
|||||||
self.assertTrue(frappe.db.get_value("Bulk Email", {"recipient": "test_lead@example.com"}))
|
self.assertTrue(frappe.db.get_value("Bulk Email", {"recipient": "test_lead@example.com"}))
|
||||||
|
|
||||||
def test_get_recipients_lead_by_status(self):
|
def test_get_recipients_lead_by_status(self):
|
||||||
w = frappe.bean(test_records[0])
|
w = frappe.get_doc(test_records[0])
|
||||||
w.lead_status="Converted"
|
w.lead_status="Converted"
|
||||||
w.insert()
|
w.insert()
|
||||||
self.assertTrue("test_lead3@example.com" in w.controller.get_recipients())
|
self.assertTrue("test_lead3@example.com" in w.controller.get_recipients())
|
||||||
|
|
||||||
def test_get_recipients_contact_customer(self):
|
def test_get_recipients_contact_customer(self):
|
||||||
w = frappe.bean(test_records[1])
|
w = frappe.get_doc(test_records[1])
|
||||||
w.insert()
|
w.insert()
|
||||||
self.assertTrue("test_contact_customer@example.com" in w.controller.get_recipients())
|
self.assertTrue("test_contact_customer@example.com" in w.controller.get_recipients())
|
||||||
|
|
||||||
def test_get_recipients_contact_supplier(self):
|
def test_get_recipients_contact_supplier(self):
|
||||||
w = frappe.bean(test_records[1])
|
w = frappe.get_doc(test_records[1])
|
||||||
w.contact_type="Supplier"
|
w.contact_type="Supplier"
|
||||||
w.insert()
|
w.insert()
|
||||||
self.assertTrue("test_contact_supplier@example.com" in w.controller.get_recipients())
|
self.assertTrue("test_contact_supplier@example.com" in w.controller.get_recipients())
|
||||||
|
|
||||||
def test_get_recipients_custom(self):
|
def test_get_recipients_custom(self):
|
||||||
w = frappe.bean(test_records[2])
|
w = frappe.get_doc(test_records[2])
|
||||||
w.insert()
|
w.insert()
|
||||||
self.assertTrue("test_custom2@example.com" in w.controller.get_recipients())
|
self.assertTrue("test_custom2@example.com" in w.controller.get_recipients())
|
||||||
self.assertTrue(frappe.db.get("Lead",
|
self.assertTrue(frappe.db.get("Lead",
|
||||||
|
@ -10,7 +10,7 @@ from frappe.core.doctype.communication.communication import _make
|
|||||||
|
|
||||||
class SupportMailbox(POP3Mailbox):
|
class SupportMailbox(POP3Mailbox):
|
||||||
def setup(self, args=None):
|
def setup(self, args=None):
|
||||||
self.email_settings = frappe.doc("Support Email Settings", "Support Email Settings")
|
self.email_settings = frappe.get_doc("Support Email Settings", "Support Email Settings")
|
||||||
self.settings = args or frappe._dict({
|
self.settings = args or frappe._dict({
|
||||||
"use_ssl": self.email_settings.use_ssl,
|
"use_ssl": self.email_settings.use_ssl,
|
||||||
"host": self.email_settings.mail_server,
|
"host": self.email_settings.mail_server,
|
||||||
@ -58,12 +58,12 @@ def get_support_mails():
|
|||||||
|
|
||||||
def add_support_communication(subject, content, sender, docname=None, mail=None):
|
def add_support_communication(subject, content, sender, docname=None, mail=None):
|
||||||
if docname:
|
if docname:
|
||||||
ticket = frappe.bean("Support Ticket", docname)
|
ticket = frappe.get_doc("Support Ticket", docname)
|
||||||
ticket.status = 'Open'
|
ticket.status = 'Open'
|
||||||
ticket.ignore_permissions = True
|
ticket.ignore_permissions = True
|
||||||
ticket.save()
|
ticket.save()
|
||||||
else:
|
else:
|
||||||
ticket = frappe.bean([decode_dict({
|
ticket = frappe.get_doc([decode_dict({
|
||||||
"doctype":"Support Ticket",
|
"doctype":"Support Ticket",
|
||||||
"description": content,
|
"description": content,
|
||||||
"subject": subject,
|
"subject": subject,
|
||||||
|
@ -57,7 +57,7 @@ class SupportTicket(TransactionBase):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def set_status(name, status):
|
def set_status(name, status):
|
||||||
st = frappe.bean("Support Ticket", name)
|
st = frappe.get_doc("Support Ticket", name)
|
||||||
st.status = status
|
st.status = status
|
||||||
st.save()
|
st.save()
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class Contact(StatusUpdater):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_contact_details(contact):
|
def get_contact_details(contact):
|
||||||
contact = frappe.doc("Contact", contact)
|
contact = frappe.get_doc("Contact", contact)
|
||||||
out = {
|
out = {
|
||||||
"contact_person": contact.get("name"),
|
"contact_person": contact.get("name"),
|
||||||
"contact_display": " ".join(filter(None,
|
"contact_display": " ".join(filter(None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user