2019-06-02 10:33:05 +00:00
|
|
|
# Copyright (c) 2017, Frappe and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
2021-09-02 11:14:59 +00:00
|
|
|
|
2019-06-02 10:33:05 +00:00
|
|
|
import frappe
|
|
|
|
|
2021-09-02 11:14:59 +00:00
|
|
|
|
2019-06-02 10:33:05 +00:00
|
|
|
def execute():
|
|
|
|
frappe.reload_doc("stock", "doctype", "item_manufacturer")
|
|
|
|
|
|
|
|
item_manufacturer = []
|
2022-03-28 13:22:46 +00:00
|
|
|
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(
|
|
|
|
(
|
|
|
|
frappe.generate_hash("", 10),
|
|
|
|
d.name,
|
|
|
|
d.manufacturer,
|
|
|
|
d.manufacturer_part_no,
|
|
|
|
d.creation,
|
|
|
|
d.owner,
|
|
|
|
)
|
|
|
|
)
|
2019-06-02 10:33:05 +00:00
|
|
|
|
|
|
|
if item_manufacturer:
|
2022-03-28 13:22:46 +00:00
|
|
|
frappe.db.sql(
|
|
|
|
"""
|
2019-06-02 10:33:05 +00:00
|
|
|
INSERT INTO `tabItem Manufacturer`
|
|
|
|
(`name`, `item_code`, `manufacturer`, `manufacturer_part_no`, `creation`, `owner`)
|
2022-03-28 13:22:46 +00:00
|
|
|
VALUES {}""".format(
|
|
|
|
", ".join(["%s"] * len(item_manufacturer))
|
|
|
|
),
|
|
|
|
tuple(item_manufacturer),
|
2019-06-02 10:33:05 +00:00
|
|
|
)
|