Revert "fix: tests depending on global default company"

This reverts commit 1f20c99ecfb51675d7182588001bb3c1d581f415.
This commit is contained in:
Deepesh Garg 2020-05-30 11:38:04 +05:30
parent f8550790fa
commit 36f7710356
21 changed files with 64 additions and 72 deletions

View File

@ -1065,7 +1065,6 @@ class TestSalesInvoice(unittest.TestCase):
serial_no = frappe.get_doc({ serial_no = frappe.get_doc({
"doctype": "Serial No", "doctype": "Serial No",
"item_code": "_Test Serialized Item With Series", "item_code": "_Test Serialized Item With Series",
"company": "Wind Power LLC",
"serial_no": make_autoname("SR", "Serial No") "serial_no": make_autoname("SR", "Serial No")
}) })
serial_no.save() serial_no.save()

View File

@ -101,7 +101,6 @@ class TestSubscription(unittest.TestCase):
subscription.delete() subscription.delete()
def test_invoice_is_generated_at_end_of_billing_period(self): def test_invoice_is_generated_at_end_of_billing_period(self):
frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company")
subscription = frappe.new_doc('Subscription') subscription = frappe.new_doc('Subscription')
subscription.customer = '_Test Customer' subscription.customer = '_Test Customer'
subscription.start = '2018-01-01' subscription.start = '2018-01-01'
@ -117,10 +116,8 @@ class TestSubscription(unittest.TestCase):
self.assertEqual(subscription.current_invoice_start, '2018-01-01') self.assertEqual(subscription.current_invoice_start, '2018-01-01')
self.assertEqual(subscription.status, 'Past Due Date') self.assertEqual(subscription.status, 'Past Due Date')
subscription.delete() subscription.delete()
frappe.db.set_value("Global Defaults", None, "default_company", None)
def test_status_goes_back_to_active_after_invoice_is_paid(self): def test_status_goes_back_to_active_after_invoice_is_paid(self):
frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company")
subscription = frappe.new_doc('Subscription') subscription = frappe.new_doc('Subscription')
subscription.customer = '_Test Customer' subscription.customer = '_Test Customer'
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
@ -144,10 +141,8 @@ class TestSubscription(unittest.TestCase):
self.assertEqual(len(subscription.invoices), 1) self.assertEqual(len(subscription.invoices), 1)
subscription.delete() subscription.delete()
frappe.db.set_value("Global Defaults", None, "default_company", None)
def test_subscription_cancel_after_grace_period(self): def test_subscription_cancel_after_grace_period(self):
frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company")
settings = frappe.get_single('Subscription Settings') settings = frappe.get_single('Subscription Settings')
default_grace_period_action = settings.cancel_after_grace default_grace_period_action = settings.cancel_after_grace
settings.cancel_after_grace = 1 settings.cancel_after_grace = 1
@ -169,11 +164,8 @@ class TestSubscription(unittest.TestCase):
settings.cancel_after_grace = default_grace_period_action settings.cancel_after_grace = default_grace_period_action
settings.save() settings.save()
subscription.delete() subscription.delete()
frappe.db.set_value("Global Defaults", None, "default_company", None)
def test_subscription_unpaid_after_grace_period(self): def test_subscription_unpaid_after_grace_period(self):
frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company")
settings = frappe.get_single('Subscription Settings') settings = frappe.get_single('Subscription Settings')
default_grace_period_action = settings.cancel_after_grace default_grace_period_action = settings.cancel_after_grace
settings.cancel_after_grace = 0 settings.cancel_after_grace = 0
@ -195,11 +187,8 @@ class TestSubscription(unittest.TestCase):
settings.cancel_after_grace = default_grace_period_action settings.cancel_after_grace = default_grace_period_action
settings.save() settings.save()
subscription.delete() subscription.delete()
frappe.db.set_value("Global Defaults", None, "default_company", None)
def test_subscription_invoice_days_until_due(self): def test_subscription_invoice_days_until_due(self):
frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company")
subscription = frappe.new_doc('Subscription') subscription = frappe.new_doc('Subscription')
subscription.customer = '_Test Customer' subscription.customer = '_Test Customer'
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
@ -211,11 +200,8 @@ class TestSubscription(unittest.TestCase):
self.assertEqual(subscription.status, 'Active') self.assertEqual(subscription.status, 'Active')
subscription.delete() subscription.delete()
frappe.db.set_value("Global Defaults", None, "default_company", None)
def test_subscription_is_past_due_doesnt_change_within_grace_period(self): def test_subscription_is_past_due_doesnt_change_within_grace_period(self):
frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company")
settings = frappe.get_single('Subscription Settings') settings = frappe.get_single('Subscription Settings')
grace_period = settings.grace_period grace_period = settings.grace_period
settings.grace_period = 1000 settings.grace_period = 1000
@ -243,7 +229,6 @@ class TestSubscription(unittest.TestCase):
settings.grace_period = grace_period settings.grace_period = grace_period
settings.save() settings.save()
subscription.delete() subscription.delete()
frappe.db.set_value("Global Defaults", None, "default_company", None)
def test_subscription_remains_active_during_invoice_period(self): def test_subscription_remains_active_during_invoice_period(self):
subscription = frappe.new_doc('Subscription') subscription = frappe.new_doc('Subscription')
@ -272,7 +257,6 @@ class TestSubscription(unittest.TestCase):
subscription.delete() subscription.delete()
def test_subscription_cancelation(self): def test_subscription_cancelation(self):
frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company")
subscription = frappe.new_doc('Subscription') subscription = frappe.new_doc('Subscription')
subscription.customer = '_Test Customer' subscription.customer = '_Test Customer'
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
@ -282,10 +266,8 @@ class TestSubscription(unittest.TestCase):
self.assertEqual(subscription.status, 'Cancelled') self.assertEqual(subscription.status, 'Cancelled')
subscription.delete() subscription.delete()
frappe.db.set_value("Global Defaults", None, "default_company", None)
def test_subscription_cancellation_invoices(self): def test_subscription_cancellation_invoices(self):
frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company")
settings = frappe.get_single('Subscription Settings') settings = frappe.get_single('Subscription Settings')
to_prorate = settings.prorate to_prorate = settings.prorate
settings.prorate = 1 settings.prorate = 1
@ -319,11 +301,8 @@ class TestSubscription(unittest.TestCase):
subscription.delete() subscription.delete()
settings.prorate = to_prorate settings.prorate = to_prorate
settings.save() settings.save()
frappe.db.set_value("Global Defaults", None, "default_company", None)
def test_subscription_cancellation_invoices_with_prorata_false(self): def test_subscription_cancellation_invoices_with_prorata_false(self):
frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company")
settings = frappe.get_single('Subscription Settings') settings = frappe.get_single('Subscription Settings')
to_prorate = settings.prorate to_prorate = settings.prorate
settings.prorate = 0 settings.prorate = 0
@ -342,11 +321,8 @@ class TestSubscription(unittest.TestCase):
settings.save() settings.save()
subscription.delete() subscription.delete()
frappe.db.set_value("Global Defaults", None, "default_company", None)
def test_subscription_cancellation_invoices_with_prorata_true(self): def test_subscription_cancellation_invoices_with_prorata_true(self):
frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company")
settings = frappe.get_single('Subscription Settings') settings = frappe.get_single('Subscription Settings')
to_prorate = settings.prorate to_prorate = settings.prorate
settings.prorate = 1 settings.prorate = 1
@ -369,10 +345,8 @@ class TestSubscription(unittest.TestCase):
settings.save() settings.save()
subscription.delete() subscription.delete()
frappe.db.set_value("Global Defaults", None, "default_company", None)
def test_subcription_cancellation_and_process(self): def test_subcription_cancellation_and_process(self):
frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company")
settings = frappe.get_single('Subscription Settings') settings = frappe.get_single('Subscription Settings')
default_grace_period_action = settings.cancel_after_grace default_grace_period_action = settings.cancel_after_grace
settings.cancel_after_grace = 1 settings.cancel_after_grace = 1
@ -404,11 +378,8 @@ class TestSubscription(unittest.TestCase):
settings.cancel_after_grace = default_grace_period_action settings.cancel_after_grace = default_grace_period_action
settings.save() settings.save()
subscription.delete() subscription.delete()
frappe.db.set_value("Global Defaults", None, "default_company", None)
def test_subscription_restart_and_process(self): def test_subscription_restart_and_process(self):
frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company")
settings = frappe.get_single('Subscription Settings') settings = frappe.get_single('Subscription Settings')
default_grace_period_action = settings.cancel_after_grace default_grace_period_action = settings.cancel_after_grace
settings.grace_period = 0 settings.grace_period = 0
@ -445,11 +416,8 @@ class TestSubscription(unittest.TestCase):
settings.cancel_after_grace = default_grace_period_action settings.cancel_after_grace = default_grace_period_action
settings.save() settings.save()
subscription.delete() subscription.delete()
frappe.db.set_value("Global Defaults", None, "default_company", None)
def test_subscription_unpaid_back_to_active(self): def test_subscription_unpaid_back_to_active(self):
frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company")
settings = frappe.get_single('Subscription Settings') settings = frappe.get_single('Subscription Settings')
default_grace_period_action = settings.cancel_after_grace default_grace_period_action = settings.cancel_after_grace
settings.cancel_after_grace = 0 settings.cancel_after_grace = 0
@ -482,7 +450,6 @@ class TestSubscription(unittest.TestCase):
settings.cancel_after_grace = default_grace_period_action settings.cancel_after_grace = default_grace_period_action
settings.save() settings.save()
subscription.delete() subscription.delete()
frappe.db.set_value("Global Defaults", None, "default_company", None)
def test_restart_active_subscription(self): def test_restart_active_subscription(self):
subscription = frappe.new_doc('Subscription') subscription = frappe.new_doc('Subscription')
@ -495,8 +462,6 @@ class TestSubscription(unittest.TestCase):
subscription.delete() subscription.delete()
def test_subscription_invoice_discount_percentage(self): def test_subscription_invoice_discount_percentage(self):
frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company")
subscription = frappe.new_doc('Subscription') subscription = frappe.new_doc('Subscription')
subscription.customer = '_Test Customer' subscription.customer = '_Test Customer'
subscription.additional_discount_percentage = 10 subscription.additional_discount_percentage = 10
@ -510,11 +475,8 @@ class TestSubscription(unittest.TestCase):
self.assertEqual(invoice.apply_discount_on, 'Grand Total') self.assertEqual(invoice.apply_discount_on, 'Grand Total')
subscription.delete() subscription.delete()
frappe.db.set_value("Global Defaults", None, "default_company", None)
def test_subscription_invoice_discount_amount(self): def test_subscription_invoice_discount_amount(self):
frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company")
subscription = frappe.new_doc('Subscription') subscription = frappe.new_doc('Subscription')
subscription.customer = '_Test Customer' subscription.customer = '_Test Customer'
subscription.additional_discount_amount = 11 subscription.additional_discount_amount = 11
@ -528,12 +490,10 @@ class TestSubscription(unittest.TestCase):
self.assertEqual(invoice.apply_discount_on, 'Grand Total') self.assertEqual(invoice.apply_discount_on, 'Grand Total')
subscription.delete() subscription.delete()
frappe.db.set_value("Global Defaults", None, "default_company", None)
def test_prepaid_subscriptions(self): def test_prepaid_subscriptions(self):
# Create a non pre-billed subscription, processing should not create # Create a non pre-billed subscription, processing should not create
# invoices. # invoices.
frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company")
subscription = frappe.new_doc('Subscription') subscription = frappe.new_doc('Subscription')
subscription.customer = '_Test Customer' subscription.customer = '_Test Customer'
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
@ -549,10 +509,8 @@ class TestSubscription(unittest.TestCase):
subscription.process() subscription.process()
self.assertEqual(len(subscription.invoices), 1) self.assertEqual(len(subscription.invoices), 1)
frappe.db.set_value("Global Defaults", None, "default_company", None)
def test_prepaid_subscriptions_with_prorate_true(self): def test_prepaid_subscriptions_with_prorate_true(self):
frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company")
settings = frappe.get_single('Subscription Settings') settings = frappe.get_single('Subscription Settings')
to_prorate = settings.prorate to_prorate = settings.prorate
settings.prorate = 1 settings.prorate = 1
@ -580,4 +538,3 @@ class TestSubscription(unittest.TestCase):
settings.save() settings.save()
subscription.delete() subscription.delete()
frappe.db.set_value("Global Defaults", None, "default_company", None)

View File

@ -75,7 +75,6 @@ class TestAsset(unittest.TestCase):
'qty': 1, 'qty': 1,
'asset': asset.name 'asset': asset.name
}) })
doc.company = 'Wind Power LLC'
doc.set_missing_values() doc.set_missing_values()
self.assertEquals(doc.items[0].is_fixed_asset, 1) self.assertEquals(doc.items[0].is_fixed_asset, 1)
@ -667,7 +666,7 @@ def create_asset(**args):
"asset_name": args.asset_name or "Macbook Pro 1", "asset_name": args.asset_name or "Macbook Pro 1",
"asset_category": "Computers", "asset_category": "Computers",
"item_code": args.item_code or "Macbook Pro", "item_code": args.item_code or "Macbook Pro",
"company": args.company or "_Test Company", "company": args.company or"_Test Company",
"purchase_date": "2015-01-01", "purchase_date": "2015-01-01",
"calculate_depreciation": 0, "calculate_depreciation": 0,
"gross_purchase_amount": 100000, "gross_purchase_amount": 100000,

View File

@ -36,18 +36,16 @@ class TestProcurementTracker(unittest.TestCase):
mr = make_material_request(company="_Test Procurement Company", warehouse=warehouse) mr = make_material_request(company="_Test Procurement Company", warehouse=warehouse)
po = make_purchase_order(mr.name) po = make_purchase_order(mr.name)
po.supplier = "_Test Supplier" po.supplier = "_Test Supplier"
po.company = "_Test Procurement Company" po.get("items")[0].cost_center = "_Test Cost Center - _TC"
po.get("items")[0].cost_center = "_Test Cost Center - _TPC"
po.submit() po.submit()
pr = make_purchase_receipt(po.name) pr = make_purchase_receipt(po.name)
pr.company = "_Test Procurement Company"
pr.submit() pr.submit()
frappe.db.commit() frappe.db.commit()
date_obj = datetime.date(datetime.now()) date_obj = datetime.date(datetime.now())
expected_data = { expected_data = {
"material_request_date": date_obj, "material_request_date": date_obj,
"cost_center": "_Test Cost Center - _TPC", "cost_center": "_Test Cost Center - _TC",
"project": None, "project": None,
"requesting_site": "_Test Procurement Warehouse - _TPC", "requesting_site": "_Test Procurement Warehouse - _TPC",
"requestor": "Administrator", "requestor": "Administrator",

View File

@ -43,7 +43,6 @@ class TestMapper(unittest.TestCase):
qtn = frappe.get_doc({ qtn = frappe.get_doc({
"doctype": "Quotation", "doctype": "Quotation",
"quotation_to": "Customer", "quotation_to": "Customer",
"company": "_Test Company",
"party_name": customer, "party_name": customer,
"order_type": "Sales", "order_type": "Sales",
"transaction_date" : nowdate(), "transaction_date" : nowdate(),
@ -60,7 +59,6 @@ class TestMapper(unittest.TestCase):
"base_amount": 1000.0, "base_amount": 1000.0,
"base_rate": 100.0, "base_rate": 100.0,
"description": "CPU", "description": "CPU",
"company": "_Test Company",
"doctype": "Sales Order Item", "doctype": "Sales Order Item",
"item_code": "_Test Item Home Desktop 100", "item_code": "_Test Item Home Desktop 100",
"item_name": "CPU", "item_name": "CPU",

View File

@ -30,7 +30,6 @@ class TestOpportunity(unittest.TestCase):
new_lead_email_id = "new{}@example.com".format(random_string(5)) new_lead_email_id = "new{}@example.com".format(random_string(5))
args = { args = {
"doctype": "Opportunity", "doctype": "Opportunity",
"company": "_Test Company",
"contact_email": new_lead_email_id, "contact_email": new_lead_email_id,
"opportunity_type": "Sales", "opportunity_type": "Sales",
"with_items": 0, "with_items": 0,

View File

@ -108,7 +108,7 @@ class TestPlaidSettings(unittest.TestCase):
} }
bank = json.dumps(frappe.get_doc("Bank", "Citi").as_dict(), default=json_handler) bank = json.dumps(frappe.get_doc("Bank", "Citi").as_dict(), default=json_handler)
company = frappe.db.get_single_value('Global Defaults', 'default_company') or '_Test Company' company = frappe.db.get_single_value('Global Defaults', 'default_company')
if frappe.db.get_value("Company", company, "default_bank_account") is None: if frappe.db.get_value("Company", company, "default_bank_account") is None:
frappe.db.set_value("Company", company, "default_bank_account", get_default_bank_cash_account(company, "Cash").get("account")) frappe.db.set_value("Company", company, "default_bank_account", get_default_bank_cash_account(company, "Cash").get("account"))

View File

@ -83,8 +83,7 @@ def get_healthcare_service_unit():
service_unit.service_unit_type = get_service_unit_type() service_unit.service_unit_type = get_service_unit_type()
service_unit.inpatient_occupancy = 1 service_unit.inpatient_occupancy = 1
service_unit.occupancy_status = "Vacant" service_unit.occupancy_status = "Vacant"
service_unit.is_group = 0, service_unit.is_group = 0
service_unit.company = "_Test Company"
service_unit_parent_name = frappe.db.exists({ service_unit_parent_name = frappe.db.exists({
"doctype": "Healthcare Service Unit", "doctype": "Healthcare Service Unit",
"healthcare_service_unit_name": "All Healthcare Service Units", "healthcare_service_unit_name": "All Healthcare Service Units",

View File

@ -104,8 +104,7 @@ def mark_attendance(employee, date=today(), status='Present'):
"doctype": "Attendance", "doctype": "Attendance",
"employee": employee.name, "employee": employee.name,
"attendance_date": date, "attendance_date": date,
"status": status, "status": status
"company": "_Test Company"
}) })
attendance.save() attendance.save()
attendance.submit() attendance.submit()

View File

@ -16,7 +16,7 @@ def create_department(department_name, parent_department=None):
'is_group': 0, 'is_group': 0,
'parent_department': parent_department, 'parent_department': parent_department,
'department_name': department_name, 'department_name': department_name,
'company': frappe.defaults.get_defaults().company or 'Wind Power LLC' 'company': frappe.defaults.get_defaults().company
}).insert() }).insert()
return doc return doc

View File

@ -60,7 +60,7 @@ def make_employee(user, company=None, **kwargs):
"doctype": "Employee", "doctype": "Employee",
"naming_series": "EMP-", "naming_series": "EMP-",
"first_name": user, "first_name": user,
"company": company or erpnext.get_default_company() or 'Wind Power LLC', "company": company or erpnext.get_default_company(),
"user_id": user, "user_id": user,
"date_of_birth": "1990-05-08", "date_of_birth": "1990-05-08",
"date_of_joining": "2013-01-01", "date_of_joining": "2013-01-01",

View File

@ -88,7 +88,7 @@ def create_payroll_period():
payroll_period = frappe.get_doc(dict( payroll_period = frappe.get_doc(dict(
doctype = 'Payroll Period', doctype = 'Payroll Period',
name = "_Test Payroll Period", name = "_Test Payroll Period",
company = erpnext.get_default_company() or 'Wind Power LLC', company = erpnext.get_default_company(),
start_date = date(date.today().year, 1, 1), start_date = date(date.today().year, 1, 1),
end_date = date(date.today().year, 12, 31) end_date = date(date.today().year, 12, 31)
)).insert() )).insert()

View File

@ -94,7 +94,6 @@ class TestExpenseClaim(unittest.TestCase):
payable_account = get_payable_account(company_name) payable_account = get_payable_account(company_name)
expense_claim = frappe.get_doc({ expense_claim = frappe.get_doc({
"doctype": "Expense Claim", "doctype": "Expense Claim",
"company": "_Test Company",
"employee": "_T-Employee-00001", "employee": "_T-Employee-00001",
"payable_account": payable_account, "payable_account": payable_account,
"approval_status": "Rejected", "approval_status": "Rejected",

View File

@ -55,8 +55,7 @@ def create_job_offer(**args):
"job_applicant": args.job_applicant or job_applicant.name, "job_applicant": args.job_applicant or job_applicant.name,
"offer_date": args.offer_date or nowdate(), "offer_date": args.offer_date or nowdate(),
"designation": args.designation or "Researcher", "designation": args.designation or "Researcher",
"status": args.status or "Accepted", "status": args.status or "Accepted"
"company": "_Test Company"
}) })
return job_offer return job_offer
@ -69,7 +68,6 @@ def create_staffing_plan(**args):
staffing_plan = frappe.get_doc({ staffing_plan = frappe.get_doc({
"doctype": "Staffing Plan", "doctype": "Staffing Plan",
"name": args.name or "Test", "name": args.name or "Test",
"company": "_Test Company",
"from_date": args.from_date or nowdate(), "from_date": args.from_date or nowdate(),
"to_date": args.to_date or add_days(nowdate(), 10), "to_date": args.to_date or add_days(nowdate(), 10),
"staffing_details": args.staffing_details or [{ "staffing_details": args.staffing_details or [{

View File

@ -414,7 +414,7 @@ def make_salary_component(salary_components, test_tax, company_list=None):
get_salary_component_account(salary_component["salary_component"], company_list) get_salary_component_account(salary_component["salary_component"], company_list)
def get_salary_component_account(sal_comp, company_list=None): def get_salary_component_account(sal_comp, company_list=None):
company = erpnext.get_default_company() or 'Wind Power LLC' company = erpnext.get_default_company()
if company_list and company not in company_list: if company_list and company not in company_list:
company_list.append(company) company_list.append(company)

View File

@ -116,7 +116,7 @@ def make_salary_structure(salary_structure, payroll_frequency, employee=None, do
details = { details = {
"doctype": "Salary Structure", "doctype": "Salary Structure",
"name": salary_structure, "name": salary_structure,
"company": company or erpnext.get_default_company() or "_Test Company", "company": company or erpnext.get_default_company(),
"earnings": make_earning_salary_component(test_tax=test_tax, company_list=["_Test Company"]), "earnings": make_earning_salary_component(test_tax=test_tax, company_list=["_Test Company"]),
"deductions": make_deduction_salary_component(test_tax=test_tax, company_list=["_Test Company"]), "deductions": make_deduction_salary_component(test_tax=test_tax, company_list=["_Test Company"]),
"payroll_frequency": payroll_frequency, "payroll_frequency": payroll_frequency,

View File

@ -32,8 +32,7 @@ def create_training_program(training_program):
frappe.get_doc({ frappe.get_doc({
"doctype": "Training Program", "doctype": "Training Program",
"training_program": training_program, "training_program": training_program,
"description": training_program, "description": training_program
"company": "Wind Power LLC"
}).insert() }).insert()
def get_attendees(employee, employee2): def get_attendees(employee, employee2):

View File

@ -192,7 +192,6 @@ class TestDeliveryNote(unittest.TestCase):
serial_no = frappe.get_doc({ serial_no = frappe.get_doc({
"doctype": "Serial No", "doctype": "Serial No",
"item_code": "_Test Serialized Item With Series", "item_code": "_Test Serialized Item With Series",
"company": "Wind Power LLC",
"serial_no": make_autoname("SR", "Serial No") "serial_no": make_autoname("SR", "Serial No")
}) })
serial_no.save() serial_no.save()
@ -566,6 +565,32 @@ class TestDeliveryNote(unittest.TestCase):
for i, gle in enumerate(gl_entries): for i, gle in enumerate(gl_entries):
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
def test_delivery_note_without_cost_center(self):
cost_center = "Main - TCP1"
company = frappe.db.get_value('Warehouse', 'Stores - TCP1', 'company')
set_valuation_method("_Test Item", "FIFO")
make_stock_entry(target="Stores - TCP1", qty=5, basic_rate=100)
stock_in_hand_account = get_inventory_account('_Test Company with perpetual inventory')
dn = create_delivery_note(company='_Test Company with perpetual inventory', warehouse='Stores - TCP1', cost_center = 'Main - TCP1', expense_account = "Cost of Goods Sold - TCP1")
gl_entries = get_gl_entries("Delivery Note", dn.name)
self.assertTrue(gl_entries)
expected_values = {
"Cost of Goods Sold - TCP1": {
"cost_center": cost_center
},
stock_in_hand_account: {
"cost_center": None
}
}
for i, gle in enumerate(gl_entries):
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
def test_make_sales_invoice_from_dn_for_returned_qty(self): def test_make_sales_invoice_from_dn_for_returned_qty(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
from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_invoice from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_invoice

View File

@ -172,7 +172,7 @@ def create_delivery_trip(driver, address, contact=None):
delivery_trip = frappe.get_doc({ delivery_trip = frappe.get_doc({
"doctype": "Delivery Trip", "doctype": "Delivery Trip",
"company": erpnext.get_default_company() or 'Wind Power LLC', "company": erpnext.get_default_company(),
"departure_time": add_days(now_datetime(), 5), "departure_time": add_days(now_datetime(), 5),
"driver": driver.name, "driver": driver.name,
"driver_address": address.name, "driver_address": address.name,

View File

@ -432,6 +432,30 @@ class TestPurchaseReceipt(unittest.TestCase):
for i, gle in enumerate(gl_entries): for i, gle in enumerate(gl_entries):
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
def test_purchase_receipt_without_cost_center(self):
if not frappe.db.exists('Location', 'Test Location'):
frappe.get_doc({
'doctype': 'Location',
'location_name': 'Test Location'
}).insert()
pr = make_purchase_receipt(company="_Test Company with perpetual inventory", warehouse = "Stores - TCP1", supplier_warehouse = "Work in Progress - TCP1")
stock_in_hand_account = get_inventory_account(pr.company, pr.get("items")[0].warehouse)
gl_entries = get_gl_entries("Purchase Receipt", pr.name)
self.assertTrue(gl_entries)
expected_values = {
"Stock Received But Not Billed - TCP1": {
"cost_center": None
},
stock_in_hand_account: {
"cost_center": None
}
}
for i, gle in enumerate(gl_entries):
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
def test_make_purchase_invoice_from_pr_for_returned_qty(self): def test_make_purchase_invoice_from_pr_for_returned_qty(self):
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order, create_pr_against_po from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order, create_pr_against_po

View File

@ -24,7 +24,6 @@ class TestSerialNo(unittest.TestCase):
frappe.delete_doc_if_exists("Serial No", "_TCSER0001") frappe.delete_doc_if_exists("Serial No", "_TCSER0001")
sr = frappe.new_doc("Serial No") sr = frappe.new_doc("Serial No")
sr.company = '_Test Company'
sr.item_code = "_Test Serialized Item" sr.item_code = "_Test Serialized Item"
sr.warehouse = "_Test Warehouse - _TC" sr.warehouse = "_Test Warehouse - _TC"
sr.serial_no = "_TCSER0001" sr.serial_no = "_TCSER0001"