Merge pull request #18159 from rohitwaghchaure/set_default_supplier_in_item_default_for_multi_company

fix: default supplier was not set from the patch in item defaults for multi company instance
This commit is contained in:
rohitwaghchaure
2019-07-05 11:21:34 +05:30
committed by GitHub
2 changed files with 27 additions and 1 deletions

View File

@@ -602,4 +602,5 @@ erpnext.patches.v11_1.delete_scheduling_tool
erpnext.patches.v11_1.update_bank_transaction_status
erpnext.patches.v11_1.renamed_delayed_item_report
erpnext.patches.v11_1.set_missing_opportunity_from
erpnext.patches.v11_1.set_quotation_status
erpnext.patches.v11_1.set_quotation_status
erpnext.patches.v11_1.update_default_supplier_in_item_defaults

View File

@@ -0,0 +1,25 @@
# Copyright (c) 2018, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
'''
default supplier was not set in the item defaults for multi company instance,
this patch will set the default supplier
'''
if not frappe.db.has_column('Item', 'default_supplier'):
return
frappe.reload_doc('stock', 'doctype', 'item_default')
frappe.reload_doc('stock', 'doctype', 'item')
companies = frappe.get_all("Company")
if len(companies) > 1:
frappe.db.sql(""" UPDATE `tabItem Default`, `tabItem`
SET `tabItem Default`.default_supplier = `tabItem`.default_supplier
WHERE
`tabItem Default`.parent = `tabItem`.name and `tabItem Default`.default_supplier is null
and `tabItem`.default_supplier is not null and `tabItem`.default_supplier != '' """)