2019-03-11 07:32:16 +00:00
|
|
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
import frappe
|
|
|
|
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
|
|
|
|
|
|
|
|
def execute():
|
2019-03-15 08:28:14 +00:00
|
|
|
create_stock_entry_types()
|
2019-03-13 12:53:18 +00:00
|
|
|
|
2019-03-15 08:28:14 +00:00
|
|
|
company = frappe.db.get_value("Company", {'country': 'India'}, 'name')
|
|
|
|
if company:
|
|
|
|
add_gst_hsn_code_field()
|
2019-03-13 12:53:18 +00:00
|
|
|
|
|
|
|
def create_stock_entry_types():
|
2019-03-15 08:28:14 +00:00
|
|
|
frappe.reload_doc('stock', 'doctype', 'stock_entry_type')
|
|
|
|
frappe.reload_doc('stock', 'doctype', 'stock_entry')
|
2019-03-13 12:53:18 +00:00
|
|
|
|
2019-03-15 08:28:14 +00:00
|
|
|
for purpose in ["Material Issue", "Material Receipt", "Material Transfer",
|
|
|
|
"Material Transfer for Manufacture", "Material Consumption for Manufacture", "Manufacture",
|
2019-03-26 07:09:28 +00:00
|
|
|
"Repack", "Send to Subcontractor", "Send to Warehouse", "Receive at Warehouse"]:
|
2019-03-14 10:49:08 +00:00
|
|
|
|
2019-03-15 08:28:14 +00:00
|
|
|
ste_type = frappe.get_doc({
|
|
|
|
'doctype': 'Stock Entry Type',
|
|
|
|
'name': purpose,
|
|
|
|
'purpose': purpose
|
|
|
|
})
|
2019-03-13 12:53:18 +00:00
|
|
|
|
2019-03-15 08:28:14 +00:00
|
|
|
try:
|
|
|
|
ste_type.insert()
|
|
|
|
except frappe.DuplicateEntryError:
|
|
|
|
pass
|
2019-03-11 07:32:16 +00:00
|
|
|
|
2019-03-26 07:09:28 +00:00
|
|
|
frappe.db.sql(" UPDATE `tabStock Entry` set purpose = 'Send to Subcontractor' where purpose = 'Subcontract'")
|
2019-03-15 08:28:14 +00:00
|
|
|
frappe.db.sql(" UPDATE `tabStock Entry` set stock_entry_type = purpose ")
|
2019-03-14 10:49:08 +00:00
|
|
|
|
2019-03-13 12:53:18 +00:00
|
|
|
def add_gst_hsn_code_field():
|
2019-03-15 08:28:14 +00:00
|
|
|
custom_fields = {
|
|
|
|
'Stock Entry Detail': [dict(fieldname='gst_hsn_code', label='HSN/SAC',
|
|
|
|
fieldtype='Data', fetch_from='item_code.gst_hsn_code',
|
|
|
|
insert_after='description', allow_on_submit=1, print_hide=0)]
|
|
|
|
}
|
|
|
|
|
|
|
|
create_custom_fields(custom_fields, ignore_validate = frappe.flags.in_patch, update=True)
|
|
|
|
|
|
|
|
frappe.db.sql(""" update `tabStock Entry Detail`, `tabItem`
|
|
|
|
SET
|
|
|
|
`tabStock Entry Detail`.gst_hsn_code = `tabItem`.gst_hsn_code
|
|
|
|
Where
|
|
|
|
`tabItem`.name = `tabStock Entry Detail`.item_code and `tabItem`.gst_hsn_code is not null
|
|
|
|
""")
|