brotherton-erpnext/erpnext/patches/v12_0/make_item_manufacturer.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
857 B
Python
Raw Normal View History

# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
import frappe
def execute():
frappe.reload_doc("stock", "doctype", "item_manufacturer")
item_manufacturer = []
for d in frappe.db.sql(
""" SELECT name, manufacturer, manufacturer_part_no, creation, owner
FROM `tabItem` WHERE manufacturer is not null and manufacturer != ''""",
as_dict=1,
):
item_manufacturer.append(
2022-03-28 13:22:46 +00:00
(
frappe.generate_hash("", 10),
d.name,
d.manufacturer,
d.manufacturer_part_no,
d.creation,
d.owner,
)
2022-03-28 13:22:46 +00:00
)
if item_manufacturer:
frappe.db.sql(
2022-03-28 13:22:46 +00:00
"""
INSERT INTO `tabItem Manufacturer`
(`name`, `item_code`, `manufacturer`, `manufacturer_part_no`, `creation`, `owner`)
VALUES {}""".format(
", ".join(["%s"] * len(item_manufacturer))
2022-03-28 13:22:46 +00:00
),
tuple(item_manufacturer),
)