From f04b19aa2e8c50920b26b412fc61d8b579879fdb Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 11 Jul 2019 18:29:24 +0530 Subject: [PATCH] fix: Company might not have any warehouses when on_update hook for QBM is being executed This used to throw while renaming a Company that is either used with QuickBooks Migrator or is set as a Default Company in Global Defaults. --- .../doctype/quickbooks_migrator/quickbooks_migrator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/erpnext_integrations/doctype/quickbooks_migrator/quickbooks_migrator.py b/erpnext/erpnext_integrations/doctype/quickbooks_migrator/quickbooks_migrator.py index 85fe4f2303..96a533ee10 100644 --- a/erpnext/erpnext_integrations/doctype/quickbooks_migrator/quickbooks_migrator.py +++ b/erpnext/erpnext_integrations/doctype/quickbooks_migrator/quickbooks_migrator.py @@ -47,7 +47,9 @@ class QuickBooksMigrator(Document): if self.company: # We need a Cost Center corresponding to the selected erpnext Company self.default_cost_center = frappe.db.get_value('Company', self.company, 'cost_center') - self.default_warehouse = frappe.get_all('Warehouse', filters={"company": self.company, "is_group": 0})[0]["name"] + company_warehouses = frappe.get_all('Warehouse', filters={"company": self.company, "is_group": 0}) + if company_warehouses: + self.default_warehouse = company_warehouses[0].name if self.authorization_endpoint: self.authorization_url = self.oauth.authorization_url(self.authorization_endpoint)[0]