From 1f20c99ecfb51675d7182588001bb3c1d581f415 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Tue, 14 Apr 2020 19:40:25 +0530 Subject: [PATCH] fix: tests depending on global default company --- .../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, 72 insertions(+), 64 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 2692465051..df2cc29a16 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -1058,6 +1058,7 @@ 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 3d96f233b4..a0784e6719 100644 --- a/erpnext/accounts/doctype/subscription/test_subscription.py +++ b/erpnext/accounts/doctype/subscription/test_subscription.py @@ -101,6 +101,7 @@ 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' @@ -116,8 +117,10 @@ 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}) @@ -141,8 +144,10 @@ 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 @@ -164,8 +169,11 @@ 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 @@ -187,8 +195,11 @@ 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}) @@ -200,8 +211,11 @@ 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 @@ -229,6 +243,7 @@ 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') @@ -257,6 +272,7 @@ 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}) @@ -266,8 +282,10 @@ 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 @@ -301,8 +319,11 @@ 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 @@ -321,8 +342,11 @@ 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 @@ -345,8 +369,10 @@ 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 @@ -378,8 +404,11 @@ 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 @@ -416,8 +445,11 @@ 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 @@ -450,6 +482,7 @@ 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') @@ -462,6 +495,8 @@ 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 @@ -475,8 +510,11 @@ 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 @@ -490,10 +528,12 @@ 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}) @@ -509,8 +549,10 @@ 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 @@ -538,3 +580,4 @@ 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 a56440de3d..d2a70375c2 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -78,6 +78,7 @@ 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) @@ -595,7 +596,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 bebf0ccec5..0c840ecbd8 100644 --- a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py +++ b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py @@ -36,16 +36,18 @@ 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.get("items")[0].cost_center = "_Test Cost Center - _TC" + po.company = "_Test Procurement Company" + po.get("items")[0].cost_center = "_Test Cost Center - _TPC" 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 - _TC", + "cost_center": "_Test Cost Center - _TPC", "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 d02308d8f2..93d1b321b4 100644 --- a/erpnext/controllers/tests/test_mapper.py +++ b/erpnext/controllers/tests/test_mapper.py @@ -43,6 +43,7 @@ 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(), @@ -59,6 +60,7 @@ 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 33d90076c4..fc852b19a1 100644 --- a/erpnext/crm/doctype/opportunity/test_opportunity.py +++ b/erpnext/crm/doctype/opportunity/test_opportunity.py @@ -30,6 +30,7 @@ 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 29e8fa4fec..75184d989a 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') + company = frappe.db.get_single_value('Global Defaults', 'default_company') or '_Test 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 e15324c55b..7a7936a0f8 100644 --- a/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py +++ b/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py @@ -84,7 +84,8 @@ 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.is_group = 0, + service_unit.company = "_Test Company" 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 1615ab30f1..1181192cbe 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,7 +104,8 @@ def mark_attendance(employee, date=today(), status='Present'): "doctype": "Attendance", "employee": employee.name, "attendance_date": date, - "status": status + "status": status, + "company": "_Test Company" }) attendance.save() attendance.submit() diff --git a/erpnext/hr/doctype/department/test_department.py b/erpnext/hr/doctype/department/test_department.py index 2eeca26e30..a6e8aae625 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 + 'company': frappe.defaults.get_defaults().company or 'Wind Power LLC' }).insert() return doc diff --git a/erpnext/hr/doctype/employee/test_employee.py b/erpnext/hr/doctype/employee/test_employee.py index d3410de2eb..eff382d973 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): "doctype": "Employee", "naming_series": "EMP-", "first_name": user, - "company": company or erpnext.get_default_company(), + "company": company or erpnext.get_default_company() or 'Wind Power LLC', "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 9c87bbd1f3..d53f6a706d 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(), + company = erpnext.get_default_company() or 'Wind Power LLC', 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 6e97f0513d..e7ee108142 100644 --- a/erpnext/hr/doctype/expense_claim/test_expense_claim.py +++ b/erpnext/hr/doctype/expense_claim/test_expense_claim.py @@ -94,6 +94,7 @@ 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 8886596450..1da107bfe7 100644 --- a/erpnext/hr/doctype/job_offer/test_job_offer.py +++ b/erpnext/hr/doctype/job_offer/test_job_offer.py @@ -55,7 +55,8 @@ 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" + "status": args.status or "Accepted", + "company": "_Test Company" }) return job_offer @@ -68,6 +69,7 @@ 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 ecccac7d41..cd73b94719 100644 --- a/erpnext/hr/doctype/salary_slip/test_salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/test_salary_slip.py @@ -359,7 +359,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() + company = erpnext.get_default_company() or 'Wind Power LLC' 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 6ca6dfd2c0..e465d04f4d 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(), + "company": company or erpnext.get_default_company() or "_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"]), "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 57123e304f..5ddb99b8ea 100644 --- a/erpnext/hr/doctype/training_event/test_training_event.py +++ b/erpnext/hr/doctype/training_event/test_training_event.py @@ -32,7 +32,8 @@ def create_training_program(training_program): frappe.get_doc({ "doctype": "Training Program", "training_program": training_program, - "description": training_program + "description": training_program, + "company": "Wind Power LLC" }).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 c15fada525..a0c69c3518 100644 --- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py @@ -192,6 +192,7 @@ 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() @@ -585,32 +586,6 @@ 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 eeea6da7a4..da2c97cb8c 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(), + "company": erpnext.get_default_company() or 'Wind Power LLC', "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 9d41b45686..a45fb304d1 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -432,30 +432,6 @@ 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 ab061076e5..7b06ef96ce 100644 --- a/erpnext/stock/doctype/serial_no/test_serial_no.py +++ b/erpnext/stock/doctype/serial_no/test_serial_no.py @@ -24,6 +24,7 @@ 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"