fix: document creation via onboarding slide (#20644)
* fix: defaults not set in doc created via Onboarding Slide
* fix: default company not set in Supplier
diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py
index 62a04f3..df143ee 100644
--- a/erpnext/buying/doctype/supplier/supplier.py
+++ b/erpnext/buying/doctype/supplier/supplier.py
@@ -58,7 +58,9 @@
frappe.db.set(self, "supplier_name", newdn)
def create_onboarding_docs(self, args):
- defaults = frappe.defaults.get_defaults()
+ company = frappe.defaults.get_defaults().get('company') or \
+ frappe.db.get_single_value('Global Defaults', 'default_company')
+
for i in range(1, args.get('max_count')):
supplier = args.get('supplier_name_' + str(i))
if supplier:
@@ -67,7 +69,7 @@
'doctype': self.doctype,
'supplier_name': supplier,
'supplier_group': _('Local'),
- 'company': defaults.get('company')
+ 'company': company
}).insert()
if args.get('supplier_email_' + str(i)):
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index 7f2fe60..9261289 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -213,6 +213,9 @@
def create_onboarding_docs(self, args):
defaults = frappe.defaults.get_defaults()
+ company = defaults.get('company') or \
+ frappe.db.get_single_value('Global Defaults', 'default_company')
+
for i in range(1, args.get('max_count')):
customer = args.get('customer_name_' + str(i))
if customer:
@@ -223,7 +226,7 @@
'customer_type': 'Company',
'customer_group': _('Commercial'),
'territory': defaults.get('country'),
- 'company': defaults.get('company')
+ 'company': company
}).insert()
if args.get('customer_email_' + str(i)):
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index d036a0a..a2a913a 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -877,14 +877,16 @@
frappe.msgprint(msg=_("You have to enable auto re-order in Stock Settings to maintain re-order levels."), title=_("Enable Auto Re-Order"), indicator="orange")
def create_onboarding_docs(self, args):
- defaults = frappe.defaults.get_defaults()
+ company = frappe.defaults.get_defaults().get('company') or \
+ frappe.db.get_single_value('Global Defaults', 'default_company')
+
for i in range(1, args.get('max_count')):
item = args.get('item_' + str(i))
if item:
default_warehouse = ''
default_warehouse = frappe.db.get_value('Warehouse', filters={
'warehouse_name': _('Finished Goods'),
- 'company': defaults.get('company_name')
+ 'company': company
})
try:
@@ -901,7 +903,7 @@
'stock_uom': _(args.get('item_uom_' + str(i))),
'item_defaults': [{
'default_warehouse': default_warehouse,
- 'company': defaults.get('company_name')
+ 'company': company
}]
}).insert()
@@ -909,7 +911,7 @@
pass
else:
if args.get('item_price_' + str(i)):
- item_price = flt(args.get('tem_price_' + str(i)))
+ item_price = flt(args.get('item_price_' + str(i)))
price_list_name = frappe.db.get_value('Price List', {'selling': 1})
make_item_price(item, price_list_name, item_price)