Patch for reverting manufacturers table from item
This commit is contained in:
parent
b6a8920489
commit
c98f37f91c
@ -390,3 +390,4 @@ erpnext.patches.v8_0.enable_booking_asset_depreciation_automatically
|
|||||||
erpnext.patches.v8_0.set_project_copied_from
|
erpnext.patches.v8_0.set_project_copied_from
|
||||||
erpnext.patches.v8_0.update_status_as_paid_for_completed_expense_claim
|
erpnext.patches.v8_0.update_status_as_paid_for_completed_expense_claim
|
||||||
erpnext.patches.v7_2.stock_uom_in_selling
|
erpnext.patches.v7_2.stock_uom_in_selling
|
||||||
|
erpnext.patches.v8_0.revert_manufacturers_table_from_item
|
@ -1,24 +0,0 @@
|
|||||||
# Copyright (c) 2017, Frappe and Contributors
|
|
||||||
# License: GNU General Public License v3. See license.txt
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import frappe
|
|
||||||
|
|
||||||
def execute():
|
|
||||||
|
|
||||||
# reading from json and writing it to mariadb
|
|
||||||
# reload_doc needed here with information because new table introduced
|
|
||||||
frappe.reload_doc('stock', 'doctype', 'item_manufacturer')
|
|
||||||
# reload_doctype is a simpler concept of reload_doc
|
|
||||||
frappe.reload_doctype('Item')
|
|
||||||
|
|
||||||
item_manufacturers = frappe.get_all("Item", fields=["name", "manufacturer", "manufacturer_part_no"])
|
|
||||||
for item in item_manufacturers:
|
|
||||||
if item.manufacturer or item.manufacturer_part_no:
|
|
||||||
item_doc = frappe.get_doc("Item", item.name)
|
|
||||||
item_doc.append("manufacturers", {
|
|
||||||
"manufacturer": item.manufacturer,
|
|
||||||
"manufacturer_part_no": item.manufacturer_part_no
|
|
||||||
})
|
|
||||||
|
|
||||||
item_doc.get("manufacturers")[0].db_update()
|
|
22
erpnext/patches/v8_0/revert_manufacturers_table_from_item.py
Normal file
22
erpnext/patches/v8_0/revert_manufacturers_table_from_item.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
if frappe.db.exists("DocType", "Item Manufacturer"):
|
||||||
|
frappe.reload_doctype("Item")
|
||||||
|
item_manufacturers = frappe.db.sql("""
|
||||||
|
select parent, manufacturer, manufacturer_part_no
|
||||||
|
from `tabItem Manufacturer`
|
||||||
|
""", as_dict=1)
|
||||||
|
|
||||||
|
for im in item_manufacturers:
|
||||||
|
frappe.db.sql("""
|
||||||
|
update tabItem
|
||||||
|
set manufacturer=%s, manufacturer_part_no=%s
|
||||||
|
where name=%s
|
||||||
|
""", (im.manufacturer, im.manufacturer_part_no, im.parent))
|
||||||
|
|
||||||
|
frappe.delete_doc("DocType", "Item Manufacturer")
|
Loading…
x
Reference in New Issue
Block a user