brotherton-erpnext/erpnext/patches/v10_0/update_warehouse_address_details.py
Vishal Dhayagude 35b665cb26 [new] Create multiple warehouse address and fetch address to stock entry (#13109)
* [new] Create multiple warehouse address and fetch address to stock entry

* [fix] Deleted unwanted field and added patch to link warehouse details to Address

* [fix] Codacy fixed

* [fix] Modified patch for warehouse address

* [fix] Modified patch for warehouse address

* [fix] Patch updated and removed contact details from stock entry

* [fix] Patch Updated
2018-03-05 11:10:01 +05:30

37 lines
1.2 KiB
Python

# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
warehouse = frappe.db.sql("""select name, email_id, phone_no, mobile_no, address_line_1,
address_line_2, city, state, pin from `tabWarehouse` where ifnull(address_line_1, '') != ''
or ifnull(mobile_no, '') != ''
or ifnull(email_id, '') != '' """, as_dict=1)
for d in warehouse:
try:
address = frappe.new_doc('Address')
address.name = d.name
address.address_title = d.name
address.address_line1 = d.address_line_1
address.city = d.city
address.state = d.state
address.pincode = d.pin
address.db_insert()
address.append('links',{'link_doctype':'Warehouse','link_name':d.name})
address.links[0].db_insert()
if d.name and (d.email_id or d.mobile_no or d.phone_no):
contact = frappe.new_doc('Contact')
contact.name = d.name
contact.first_name = d.name
contact.mobile_no = d.mobile_no
contact.email_id = d.email_id
contact.phone = d.phone_no
contact.db_insert()
contact.append('links',{'link_doctype':'Warehouse','link_name':d.name})
contact.links[0].db_insert()
except frappe.DuplicateEntryError:
pass