From 36f7710356a2fa55db8c5401b4db48bb098b2a28 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 30 May 2020 11:38:04 +0530 Subject: [PATCH] Revert "fix: tests depending on global default company" This reverts commit 1f20c99ecfb51675d7182588001bb3c1d581f415. --- .../sales_invoice/test_sales_invoice.py | 1 - .../doctype/subscription/test_subscription.py | 43 ------------------- erpnext/assets/doctype/asset/test_asset.py | 3 +- .../test_procurement_tracker.py | 6 +-- erpnext/controllers/tests/test_mapper.py | 2 - .../doctype/opportunity/test_opportunity.py | 1 - .../plaid_settings/test_plaid_settings.py | 2 +- .../inpatient_record/test_inpatient_record.py | 3 +- .../test_compensatory_leave_request.py | 3 +- .../hr/doctype/department/test_department.py | 2 +- erpnext/hr/doctype/employee/test_employee.py | 2 +- ...test_employee_tax_exemption_declaration.py | 2 +- .../expense_claim/test_expense_claim.py | 1 - .../hr/doctype/job_offer/test_job_offer.py | 4 +- .../doctype/salary_slip/test_salary_slip.py | 2 +- .../salary_structure/test_salary_structure.py | 2 +- .../training_event/test_training_event.py | 3 +- .../delivery_note/test_delivery_note.py | 27 +++++++++++- .../delivery_trip/test_delivery_trip.py | 2 +- .../purchase_receipt/test_purchase_receipt.py | 24 +++++++++++ .../stock/doctype/serial_no/test_serial_no.py | 1 - 21 files changed, 64 insertions(+), 72 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index fc53f8818a..a2f9040670 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -1065,7 +1065,6 @@ class TestSalesInvoice(unittest.TestCase): serial_no = frappe.get_doc({ "doctype": "Serial No", "item_code": "_Test Serialized Item With Series", - "company": "Wind Power LLC", "serial_no": make_autoname("SR", "Serial No") }) serial_no.save() diff --git a/erpnext/accounts/doctype/subscription/test_subscription.py b/erpnext/accounts/doctype/subscription/test_subscription.py index a0784e6719..3d96f233b4 100644 --- a/erpnext/accounts/doctype/subscription/test_subscription.py +++ b/erpnext/accounts/doctype/subscription/test_subscription.py @@ -101,7 +101,6 @@ class TestSubscription(unittest.TestCase): subscription.delete() 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.customer = '_Test Customer' 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.status, 'Past Due Date') subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) 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.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) @@ -144,10 +141,8 @@ class TestSubscription(unittest.TestCase): self.assertEqual(len(subscription.invoices), 1) subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) 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') default_grace_period_action = settings.cancel_after_grace settings.cancel_after_grace = 1 @@ -169,11 +164,8 @@ class TestSubscription(unittest.TestCase): settings.cancel_after_grace = default_grace_period_action settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) 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') default_grace_period_action = settings.cancel_after_grace settings.cancel_after_grace = 0 @@ -195,11 +187,8 @@ class TestSubscription(unittest.TestCase): settings.cancel_after_grace = default_grace_period_action settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) 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.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) @@ -211,11 +200,8 @@ class TestSubscription(unittest.TestCase): self.assertEqual(subscription.status, 'Active') subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) 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') grace_period = settings.grace_period settings.grace_period = 1000 @@ -243,7 +229,6 @@ class TestSubscription(unittest.TestCase): settings.grace_period = grace_period settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_remains_active_during_invoice_period(self): subscription = frappe.new_doc('Subscription') @@ -272,7 +257,6 @@ class TestSubscription(unittest.TestCase): subscription.delete() def test_subscription_cancelation(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) @@ -282,10 +266,8 @@ class TestSubscription(unittest.TestCase): self.assertEqual(subscription.status, 'Cancelled') subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_cancellation_invoices(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") settings = frappe.get_single('Subscription Settings') to_prorate = settings.prorate settings.prorate = 1 @@ -319,11 +301,8 @@ class TestSubscription(unittest.TestCase): subscription.delete() settings.prorate = to_prorate settings.save() - frappe.db.set_value("Global Defaults", None, "default_company", None) 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') to_prorate = settings.prorate settings.prorate = 0 @@ -342,11 +321,8 @@ class TestSubscription(unittest.TestCase): settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) 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') to_prorate = settings.prorate settings.prorate = 1 @@ -369,10 +345,8 @@ class TestSubscription(unittest.TestCase): settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subcription_cancellation_and_process(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") settings = frappe.get_single('Subscription Settings') default_grace_period_action = settings.cancel_after_grace settings.cancel_after_grace = 1 @@ -404,11 +378,8 @@ class TestSubscription(unittest.TestCase): settings.cancel_after_grace = default_grace_period_action settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_restart_and_process(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") - settings = frappe.get_single('Subscription Settings') default_grace_period_action = settings.cancel_after_grace settings.grace_period = 0 @@ -445,11 +416,8 @@ class TestSubscription(unittest.TestCase): settings.cancel_after_grace = default_grace_period_action settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) 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') default_grace_period_action = settings.cancel_after_grace settings.cancel_after_grace = 0 @@ -482,7 +450,6 @@ class TestSubscription(unittest.TestCase): settings.cancel_after_grace = default_grace_period_action settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_restart_active_subscription(self): subscription = frappe.new_doc('Subscription') @@ -495,8 +462,6 @@ class TestSubscription(unittest.TestCase): subscription.delete() def test_subscription_invoice_discount_percentage(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") - subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.additional_discount_percentage = 10 @@ -510,11 +475,8 @@ class TestSubscription(unittest.TestCase): self.assertEqual(invoice.apply_discount_on, 'Grand Total') subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_invoice_discount_amount(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") - subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.additional_discount_amount = 11 @@ -528,12 +490,10 @@ class TestSubscription(unittest.TestCase): self.assertEqual(invoice.apply_discount_on, 'Grand Total') subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_prepaid_subscriptions(self): # Create a non pre-billed subscription, processing should not create # invoices. - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) @@ -549,10 +509,8 @@ class TestSubscription(unittest.TestCase): subscription.process() self.assertEqual(len(subscription.invoices), 1) - frappe.db.set_value("Global Defaults", None, "default_company", None) 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') to_prorate = settings.prorate settings.prorate = 1 @@ -580,4 +538,3 @@ class TestSubscription(unittest.TestCase): settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) \ No newline at end of file diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py index 9490c8cbc7..aed78e7746 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -75,7 +75,6 @@ class TestAsset(unittest.TestCase): 'qty': 1, 'asset': asset.name }) - doc.company = 'Wind Power LLC' doc.set_missing_values() 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_category": "Computers", "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", "calculate_depreciation": 0, "gross_purchase_amount": 100000, diff --git a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py index 0c840ecbd8..bebf0ccec5 100644 --- a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py +++ b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py @@ -36,18 +36,16 @@ class TestProcurementTracker(unittest.TestCase): mr = make_material_request(company="_Test Procurement Company", warehouse=warehouse) po = make_purchase_order(mr.name) po.supplier = "_Test Supplier" - po.company = "_Test Procurement Company" - po.get("items")[0].cost_center = "_Test Cost Center - _TPC" + po.get("items")[0].cost_center = "_Test Cost Center - _TC" po.submit() pr = make_purchase_receipt(po.name) - pr.company = "_Test Procurement Company" pr.submit() frappe.db.commit() date_obj = datetime.date(datetime.now()) expected_data = { "material_request_date": date_obj, - "cost_center": "_Test Cost Center - _TPC", + "cost_center": "_Test Cost Center - _TC", "project": None, "requesting_site": "_Test Procurement Warehouse - _TPC", "requestor": "Administrator", diff --git a/erpnext/controllers/tests/test_mapper.py b/erpnext/controllers/tests/test_mapper.py index 08248be0e9..8839e002a4 100644 --- a/erpnext/controllers/tests/test_mapper.py +++ b/erpnext/controllers/tests/test_mapper.py @@ -43,7 +43,6 @@ class TestMapper(unittest.TestCase): qtn = frappe.get_doc({ "doctype": "Quotation", "quotation_to": "Customer", - "company": "_Test Company", "party_name": customer, "order_type": "Sales", "transaction_date" : nowdate(), @@ -60,7 +59,6 @@ class TestMapper(unittest.TestCase): "base_amount": 1000.0, "base_rate": 100.0, "description": "CPU", - "company": "_Test Company", "doctype": "Sales Order Item", "item_code": "_Test Item Home Desktop 100", "item_name": "CPU", diff --git a/erpnext/crm/doctype/opportunity/test_opportunity.py b/erpnext/crm/doctype/opportunity/test_opportunity.py index fc852b19a1..33d90076c4 100644 --- a/erpnext/crm/doctype/opportunity/test_opportunity.py +++ b/erpnext/crm/doctype/opportunity/test_opportunity.py @@ -30,7 +30,6 @@ class TestOpportunity(unittest.TestCase): new_lead_email_id = "new{}@example.com".format(random_string(5)) args = { "doctype": "Opportunity", - "company": "_Test Company", "contact_email": new_lead_email_id, "opportunity_type": "Sales", "with_items": 0, diff --git a/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py b/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py index 8be2510b11..1a063d6b6f 100644 --- a/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py +++ b/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py @@ -108,7 +108,7 @@ class TestPlaidSettings(unittest.TestCase): } 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: frappe.db.set_value("Company", company, "default_bank_account", get_default_bank_cash_account(company, "Cash").get("account")) diff --git a/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py b/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py index c4826c94c3..4c2d3f692a 100644 --- a/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py +++ b/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py @@ -83,8 +83,7 @@ def get_healthcare_service_unit(): service_unit.service_unit_type = get_service_unit_type() service_unit.inpatient_occupancy = 1 service_unit.occupancy_status = "Vacant" - service_unit.is_group = 0, - service_unit.company = "_Test Company" + service_unit.is_group = 0 service_unit_parent_name = frappe.db.exists({ "doctype": "Healthcare Service Unit", "healthcare_service_unit_name": "All Healthcare Service Units", diff --git a/erpnext/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py b/erpnext/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py index 1181192cbe..1615ab30f1 100644 --- a/erpnext/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py +++ b/erpnext/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py @@ -104,8 +104,7 @@ def mark_attendance(employee, date=today(), status='Present'): "doctype": "Attendance", "employee": employee.name, "attendance_date": date, - "status": status, - "company": "_Test Company" + "status": status }) attendance.save() attendance.submit() diff --git a/erpnext/hr/doctype/department/test_department.py b/erpnext/hr/doctype/department/test_department.py index a6e8aae625..2eeca26e30 100644 --- a/erpnext/hr/doctype/department/test_department.py +++ b/erpnext/hr/doctype/department/test_department.py @@ -16,7 +16,7 @@ def create_department(department_name, parent_department=None): 'is_group': 0, 'parent_department': parent_department, 'department_name': department_name, - 'company': frappe.defaults.get_defaults().company or 'Wind Power LLC' + 'company': frappe.defaults.get_defaults().company }).insert() return doc diff --git a/erpnext/hr/doctype/employee/test_employee.py b/erpnext/hr/doctype/employee/test_employee.py index b92b8e7e4e..f4b214adc3 100644 --- a/erpnext/hr/doctype/employee/test_employee.py +++ b/erpnext/hr/doctype/employee/test_employee.py @@ -60,7 +60,7 @@ def make_employee(user, company=None, **kwargs): "doctype": "Employee", "naming_series": "EMP-", "first_name": user, - "company": company or erpnext.get_default_company() or 'Wind Power LLC', + "company": company or erpnext.get_default_company(), "user_id": user, "date_of_birth": "1990-05-08", "date_of_joining": "2013-01-01", diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py index e22948c655..867c35b1b8 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py @@ -88,7 +88,7 @@ def create_payroll_period(): payroll_period = frappe.get_doc(dict( doctype = '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), end_date = date(date.today().year, 12, 31) )).insert() diff --git a/erpnext/hr/doctype/expense_claim/test_expense_claim.py b/erpnext/hr/doctype/expense_claim/test_expense_claim.py index e7ee108142..6e97f0513d 100644 --- a/erpnext/hr/doctype/expense_claim/test_expense_claim.py +++ b/erpnext/hr/doctype/expense_claim/test_expense_claim.py @@ -94,7 +94,6 @@ class TestExpenseClaim(unittest.TestCase): payable_account = get_payable_account(company_name) expense_claim = frappe.get_doc({ "doctype": "Expense Claim", - "company": "_Test Company", "employee": "_T-Employee-00001", "payable_account": payable_account, "approval_status": "Rejected", diff --git a/erpnext/hr/doctype/job_offer/test_job_offer.py b/erpnext/hr/doctype/job_offer/test_job_offer.py index 1da107bfe7..8886596450 100644 --- a/erpnext/hr/doctype/job_offer/test_job_offer.py +++ b/erpnext/hr/doctype/job_offer/test_job_offer.py @@ -55,8 +55,7 @@ def create_job_offer(**args): "job_applicant": args.job_applicant or job_applicant.name, "offer_date": args.offer_date or nowdate(), "designation": args.designation or "Researcher", - "status": args.status or "Accepted", - "company": "_Test Company" + "status": args.status or "Accepted" }) return job_offer @@ -69,7 +68,6 @@ def create_staffing_plan(**args): staffing_plan = frappe.get_doc({ "doctype": "Staffing Plan", "name": args.name or "Test", - "company": "_Test Company", "from_date": args.from_date or nowdate(), "to_date": args.to_date or add_days(nowdate(), 10), "staffing_details": args.staffing_details or [{ diff --git a/erpnext/hr/doctype/salary_slip/test_salary_slip.py b/erpnext/hr/doctype/salary_slip/test_salary_slip.py index d002e5408a..a61ce79d0f 100644 --- a/erpnext/hr/doctype/salary_slip/test_salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/test_salary_slip.py @@ -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) 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: company_list.append(company) diff --git a/erpnext/hr/doctype/salary_structure/test_salary_structure.py b/erpnext/hr/doctype/salary_structure/test_salary_structure.py index ba3a968af0..d350031df7 100644 --- a/erpnext/hr/doctype/salary_structure/test_salary_structure.py +++ b/erpnext/hr/doctype/salary_structure/test_salary_structure.py @@ -116,7 +116,7 @@ def make_salary_structure(salary_structure, payroll_frequency, employee=None, do details = { "doctype": "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"]), "deductions": make_deduction_salary_component(test_tax=test_tax, company_list=["_Test Company"]), "payroll_frequency": payroll_frequency, diff --git a/erpnext/hr/doctype/training_event/test_training_event.py b/erpnext/hr/doctype/training_event/test_training_event.py index 5ddb99b8ea..57123e304f 100644 --- a/erpnext/hr/doctype/training_event/test_training_event.py +++ b/erpnext/hr/doctype/training_event/test_training_event.py @@ -32,8 +32,7 @@ def create_training_program(training_program): frappe.get_doc({ "doctype": "Training Program", "training_program": training_program, - "description": training_program, - "company": "Wind Power LLC" + "description": training_program }).insert() def get_attendees(employee, employee2): diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py index 13bd02f416..2e38e8ff9e 100644 --- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py @@ -192,7 +192,6 @@ class TestDeliveryNote(unittest.TestCase): serial_no = frappe.get_doc({ "doctype": "Serial No", "item_code": "_Test Serialized Item With Series", - "company": "Wind Power LLC", "serial_no": make_autoname("SR", "Serial No") }) serial_no.save() @@ -566,6 +565,32 @@ class TestDeliveryNote(unittest.TestCase): for i, gle in enumerate(gl_entries): 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): from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_invoice diff --git a/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py b/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py index da2c97cb8c..eeea6da7a4 100644 --- a/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py +++ b/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py @@ -172,7 +172,7 @@ def create_delivery_trip(driver, address, contact=None): delivery_trip = frappe.get_doc({ "doctype": "Delivery Trip", - "company": erpnext.get_default_company() or 'Wind Power LLC', + "company": erpnext.get_default_company(), "departure_time": add_days(now_datetime(), 5), "driver": driver.name, "driver_address": address.name, diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index af25ba68ea..53f8b47f68 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -432,6 +432,30 @@ class TestPurchaseReceipt(unittest.TestCase): for i, gle in enumerate(gl_entries): 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): from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order, create_pr_against_po diff --git a/erpnext/stock/doctype/serial_no/test_serial_no.py b/erpnext/stock/doctype/serial_no/test_serial_no.py index 7b06ef96ce..ab061076e5 100644 --- a/erpnext/stock/doctype/serial_no/test_serial_no.py +++ b/erpnext/stock/doctype/serial_no/test_serial_no.py @@ -24,7 +24,6 @@ class TestSerialNo(unittest.TestCase): frappe.delete_doc_if_exists("Serial No", "_TCSER0001") sr = frappe.new_doc("Serial No") - sr.company = '_Test Company' sr.item_code = "_Test Serialized Item" sr.warehouse = "_Test Warehouse - _TC" sr.serial_no = "_TCSER0001"