mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 12:49:10 +00:00
style: format code with black
This commit is contained in:
@@ -8,8 +8,8 @@ from erpnext.setup.install import create_default_cash_flow_mapper_templates
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('accounts', 'doctype', frappe.scrub('Cash Flow Mapping'))
|
||||
frappe.reload_doc('accounts', 'doctype', frappe.scrub('Cash Flow Mapper'))
|
||||
frappe.reload_doc('accounts', 'doctype', frappe.scrub('Cash Flow Mapping Template Details'))
|
||||
frappe.reload_doc("accounts", "doctype", frappe.scrub("Cash Flow Mapping"))
|
||||
frappe.reload_doc("accounts", "doctype", frappe.scrub("Cash Flow Mapper"))
|
||||
frappe.reload_doc("accounts", "doctype", frappe.scrub("Cash Flow Mapping Template Details"))
|
||||
|
||||
create_default_cash_flow_mapper_templates()
|
||||
create_default_cash_flow_mapper_templates()
|
||||
|
||||
@@ -8,6 +8,6 @@ from erpnext.setup.doctype.company.company import install_country_fixtures
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('regional', 'report', 'fichier_des_ecritures_comptables_[fec]')
|
||||
for d in frappe.get_all('Company', filters = {'country': 'France'}):
|
||||
frappe.reload_doc("regional", "report", "fichier_des_ecritures_comptables_[fec]")
|
||||
for d in frappe.get_all("Company", filters={"country": "France"}):
|
||||
install_country_fixtures(d.name)
|
||||
|
||||
@@ -7,26 +7,30 @@ import frappe
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc("stock", "doctype", "item_barcode")
|
||||
if frappe.get_all("Item Barcode", limit=1): return
|
||||
if "barcode" not in frappe.db.get_table_columns("Item"): return
|
||||
if frappe.get_all("Item Barcode", limit=1):
|
||||
return
|
||||
if "barcode" not in frappe.db.get_table_columns("Item"):
|
||||
return
|
||||
|
||||
items_barcode = frappe.db.sql("select name, barcode from tabItem where barcode is not null", as_dict=True)
|
||||
items_barcode = frappe.db.sql(
|
||||
"select name, barcode from tabItem where barcode is not null", as_dict=True
|
||||
)
|
||||
frappe.reload_doc("stock", "doctype", "item")
|
||||
|
||||
|
||||
|
||||
for item in items_barcode:
|
||||
barcode = item.barcode.strip()
|
||||
|
||||
if barcode and '<' not in barcode:
|
||||
if barcode and "<" not in barcode:
|
||||
try:
|
||||
frappe.get_doc({
|
||||
'idx': 0,
|
||||
'doctype': 'Item Barcode',
|
||||
'barcode': barcode,
|
||||
'parenttype': 'Item',
|
||||
'parent': item.name,
|
||||
'parentfield': 'barcodes'
|
||||
}).insert()
|
||||
frappe.get_doc(
|
||||
{
|
||||
"idx": 0,
|
||||
"doctype": "Item Barcode",
|
||||
"barcode": barcode,
|
||||
"parenttype": "Item",
|
||||
"parent": item.name,
|
||||
"parentfield": "barcodes",
|
||||
}
|
||||
).insert()
|
||||
except (frappe.DuplicateEntryError, frappe.UniqueValidationError):
|
||||
continue
|
||||
|
||||
@@ -6,13 +6,13 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
if not frappe.db.table_exists('Daily Work Summary Group'):
|
||||
if not frappe.db.table_exists("Daily Work Summary Group"):
|
||||
frappe.reload_doc("hr", "doctype", "daily_work_summary_group")
|
||||
frappe.reload_doc("hr", "doctype", "daily_work_summary_group_user")
|
||||
|
||||
# check if Daily Work Summary Settings Company table exists
|
||||
try:
|
||||
frappe.db.sql('DESC `tabDaily Work Summary Settings Company`')
|
||||
frappe.db.sql("DESC `tabDaily Work Summary Settings Company`")
|
||||
except Exception:
|
||||
return
|
||||
|
||||
@@ -20,19 +20,24 @@ def execute():
|
||||
previous_setting = get_previous_setting()
|
||||
if previous_setting["companies"]:
|
||||
for d in previous_setting["companies"]:
|
||||
users = frappe.get_list("Employee", dict(
|
||||
company=d.company, user_id=("!=", " ")), "user_id as user")
|
||||
if(len(users)):
|
||||
users = frappe.get_list(
|
||||
"Employee", dict(company=d.company, user_id=("!=", " ")), "user_id as user"
|
||||
)
|
||||
if len(users):
|
||||
# create new group entry for each company entry
|
||||
new_group = frappe.get_doc(dict(doctype="Daily Work Summary Group",
|
||||
name="Daily Work Summary for " + d.company,
|
||||
users=users,
|
||||
send_emails_at=d.send_emails_at,
|
||||
subject=previous_setting["subject"],
|
||||
message=previous_setting["message"]))
|
||||
new_group = frappe.get_doc(
|
||||
dict(
|
||||
doctype="Daily Work Summary Group",
|
||||
name="Daily Work Summary for " + d.company,
|
||||
users=users,
|
||||
send_emails_at=d.send_emails_at,
|
||||
subject=previous_setting["subject"],
|
||||
message=previous_setting["message"],
|
||||
)
|
||||
)
|
||||
new_group.flags.ignore_permissions = True
|
||||
new_group.flags.ignore_validate = True
|
||||
new_group.insert(ignore_if_duplicate = True)
|
||||
new_group.insert(ignore_if_duplicate=True)
|
||||
|
||||
frappe.delete_doc("DocType", "Daily Work Summary Settings")
|
||||
frappe.delete_doc("DocType", "Daily Work Summary Settings Company")
|
||||
@@ -41,11 +46,13 @@ def execute():
|
||||
def get_previous_setting():
|
||||
obj = {}
|
||||
setting_data = frappe.db.sql(
|
||||
"select field, value from tabSingles where doctype='Daily Work Summary Settings'")
|
||||
"select field, value from tabSingles where doctype='Daily Work Summary Settings'"
|
||||
)
|
||||
for field, value in setting_data:
|
||||
obj[field] = value
|
||||
obj["companies"] = get_setting_companies()
|
||||
return obj
|
||||
|
||||
|
||||
def get_setting_companies():
|
||||
return frappe.db.sql("select * from `tabDaily Work Summary Settings Company`", as_dict=True)
|
||||
|
||||
@@ -10,5 +10,5 @@ def execute():
|
||||
rename_field("Pricing Rule", "price", "rate")
|
||||
|
||||
except Exception as e:
|
||||
if e.args[0]!=1054:
|
||||
if e.args[0] != 1054:
|
||||
raise
|
||||
|
||||
@@ -5,8 +5,10 @@ def execute():
|
||||
frappe.reload_doctype("Pricing Rule")
|
||||
|
||||
currency = frappe.db.get_default("currency")
|
||||
for doc in frappe.get_all('Pricing Rule', fields = ["company", "name"]):
|
||||
for doc in frappe.get_all("Pricing Rule", fields=["company", "name"]):
|
||||
if doc.company:
|
||||
currency = frappe.get_cached_value('Company', doc.company, "default_currency")
|
||||
currency = frappe.get_cached_value("Company", doc.company, "default_currency")
|
||||
|
||||
frappe.db.sql("""update `tabPricing Rule` set currency = %s where name = %s""",(currency, doc.name))
|
||||
frappe.db.sql(
|
||||
"""update `tabPricing Rule` set currency = %s where name = %s""", (currency, doc.name)
|
||||
)
|
||||
|
||||
@@ -2,37 +2,38 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
'''
|
||||
"""
|
||||
Enable translatable in these fields
|
||||
- Customer Name
|
||||
- Supplier Name
|
||||
- Contact Name
|
||||
- Item Name/ Description
|
||||
- Address
|
||||
'''
|
||||
"""
|
||||
|
||||
frappe.reload_doc('core', 'doctype', 'docfield')
|
||||
frappe.reload_doc('custom', 'doctype', 'custom_field')
|
||||
frappe.reload_doc("core", "doctype", "docfield")
|
||||
frappe.reload_doc("custom", "doctype", "custom_field")
|
||||
|
||||
enable_for_fields = [
|
||||
['Customer', 'customer_name'],
|
||||
['Supplier', 'supplier_name'],
|
||||
['Contact', 'first_name'],
|
||||
['Contact', 'last_name'],
|
||||
['Item', 'item_name'],
|
||||
['Item', 'description'],
|
||||
['Address', 'address_line1'],
|
||||
['Address', 'address_line2'],
|
||||
["Customer", "customer_name"],
|
||||
["Supplier", "supplier_name"],
|
||||
["Contact", "first_name"],
|
||||
["Contact", "last_name"],
|
||||
["Item", "item_name"],
|
||||
["Item", "description"],
|
||||
["Address", "address_line1"],
|
||||
["Address", "address_line2"],
|
||||
]
|
||||
|
||||
|
||||
for f in enable_for_fields:
|
||||
frappe.get_doc({
|
||||
'doctype': 'Property Setter',
|
||||
'doc_type': f[0],
|
||||
'doctype_or_field': 'DocField',
|
||||
'field_name': f[1],
|
||||
'property': 'translatable',
|
||||
'propery_type': 'Check',
|
||||
'value': 1
|
||||
}).db_insert()
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Property Setter",
|
||||
"doc_type": f[0],
|
||||
"doctype_or_field": "DocField",
|
||||
"field_name": f[1],
|
||||
"property": "translatable",
|
||||
"propery_type": "Check",
|
||||
"value": 1,
|
||||
}
|
||||
).db_insert()
|
||||
|
||||
@@ -3,41 +3,57 @@ from frappe.model.utils.rename_field import rename_field
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('automation', 'doctype', 'auto_repeat')
|
||||
frappe.reload_doc("automation", "doctype", "auto_repeat")
|
||||
|
||||
doctypes_to_rename = {
|
||||
'accounts': ['Journal Entry', 'Payment Entry', 'Purchase Invoice', 'Sales Invoice'],
|
||||
'buying': ['Purchase Order', 'Supplier Quotation'],
|
||||
'selling': ['Quotation', 'Sales Order'],
|
||||
'stock': ['Delivery Note', 'Purchase Receipt']
|
||||
"accounts": ["Journal Entry", "Payment Entry", "Purchase Invoice", "Sales Invoice"],
|
||||
"buying": ["Purchase Order", "Supplier Quotation"],
|
||||
"selling": ["Quotation", "Sales Order"],
|
||||
"stock": ["Delivery Note", "Purchase Receipt"],
|
||||
}
|
||||
|
||||
for module, doctypes in doctypes_to_rename.items():
|
||||
for doctype in doctypes:
|
||||
frappe.reload_doc(module, 'doctype', frappe.scrub(doctype))
|
||||
frappe.reload_doc(module, "doctype", frappe.scrub(doctype))
|
||||
|
||||
if frappe.db.has_column(doctype, 'subscription'):
|
||||
rename_field(doctype, 'subscription', 'auto_repeat')
|
||||
if frappe.db.has_column(doctype, "subscription"):
|
||||
rename_field(doctype, "subscription", "auto_repeat")
|
||||
|
||||
subscriptions = frappe.db.sql('select * from `tabSubscription`', as_dict=1)
|
||||
subscriptions = frappe.db.sql("select * from `tabSubscription`", as_dict=1)
|
||||
|
||||
for doc in subscriptions:
|
||||
doc['doctype'] = 'Auto Repeat'
|
||||
doc["doctype"] = "Auto Repeat"
|
||||
auto_repeat = frappe.get_doc(doc)
|
||||
auto_repeat.db_insert()
|
||||
|
||||
frappe.db.sql('delete from `tabSubscription`')
|
||||
frappe.db.sql("delete from `tabSubscription`")
|
||||
frappe.db.commit()
|
||||
drop_columns_from_subscription()
|
||||
|
||||
|
||||
def drop_columns_from_subscription():
|
||||
fields_to_drop = {'Subscription': []}
|
||||
for field in ['naming_series', 'reference_doctype', 'reference_document', 'start_date',
|
||||
'end_date', 'submit_on_creation', 'disabled', 'frequency', 'repeat_on_day',
|
||||
'next_schedule_date', 'notify_by_email', 'subject', 'recipients', 'print_format',
|
||||
'message', 'status', 'amended_from']:
|
||||
fields_to_drop = {"Subscription": []}
|
||||
for field in [
|
||||
"naming_series",
|
||||
"reference_doctype",
|
||||
"reference_document",
|
||||
"start_date",
|
||||
"end_date",
|
||||
"submit_on_creation",
|
||||
"disabled",
|
||||
"frequency",
|
||||
"repeat_on_day",
|
||||
"next_schedule_date",
|
||||
"notify_by_email",
|
||||
"subject",
|
||||
"recipients",
|
||||
"print_format",
|
||||
"message",
|
||||
"status",
|
||||
"amended_from",
|
||||
]:
|
||||
|
||||
if field in frappe.db.get_table_columns("Subscription"):
|
||||
fields_to_drop['Subscription'].append(field)
|
||||
fields_to_drop["Subscription"].append(field)
|
||||
|
||||
frappe.model.delete_fields(fields_to_drop, delete=1)
|
||||
|
||||
@@ -10,15 +10,19 @@ def execute():
|
||||
|
||||
if not frappe.db.exists("Email Template", _("Dispatch Notification")):
|
||||
base_path = frappe.get_app_path("erpnext", "stock", "doctype")
|
||||
response = frappe.read_file(os.path.join(base_path, "delivery_trip/dispatch_notification_template.html"))
|
||||
response = frappe.read_file(
|
||||
os.path.join(base_path, "delivery_trip/dispatch_notification_template.html")
|
||||
)
|
||||
|
||||
frappe.get_doc({
|
||||
"doctype": "Email Template",
|
||||
"name": _("Dispatch Notification"),
|
||||
"response": response,
|
||||
"subject": _("Your order is out for delivery!"),
|
||||
"owner": frappe.session.user,
|
||||
}).insert(ignore_permissions=True)
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Email Template",
|
||||
"name": _("Dispatch Notification"),
|
||||
"response": response,
|
||||
"subject": _("Your order is out for delivery!"),
|
||||
"owner": frappe.session.user,
|
||||
}
|
||||
).insert(ignore_permissions=True)
|
||||
|
||||
delivery_settings = frappe.get_doc("Delivery Settings")
|
||||
delivery_settings.dispatch_template = _("Dispatch Notification")
|
||||
|
||||
@@ -7,25 +7,32 @@ from frappe import _
|
||||
def execute():
|
||||
frappe.reload_doc("email", "doctype", "email_template")
|
||||
|
||||
if not frappe.db.exists("Email Template", _('Leave Approval Notification')):
|
||||
if not frappe.db.exists("Email Template", _("Leave Approval Notification")):
|
||||
base_path = frappe.get_app_path("erpnext", "hr", "doctype")
|
||||
response = frappe.read_file(os.path.join(base_path, "leave_application/leave_application_email_template.html"))
|
||||
frappe.get_doc({
|
||||
'doctype': 'Email Template',
|
||||
'name': _("Leave Approval Notification"),
|
||||
'response': response,
|
||||
'subject': _("Leave Approval Notification"),
|
||||
'owner': frappe.session.user,
|
||||
}).insert(ignore_permissions=True)
|
||||
response = frappe.read_file(
|
||||
os.path.join(base_path, "leave_application/leave_application_email_template.html")
|
||||
)
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Email Template",
|
||||
"name": _("Leave Approval Notification"),
|
||||
"response": response,
|
||||
"subject": _("Leave Approval Notification"),
|
||||
"owner": frappe.session.user,
|
||||
}
|
||||
).insert(ignore_permissions=True)
|
||||
|
||||
|
||||
if not frappe.db.exists("Email Template", _('Leave Status Notification')):
|
||||
if not frappe.db.exists("Email Template", _("Leave Status Notification")):
|
||||
base_path = frappe.get_app_path("erpnext", "hr", "doctype")
|
||||
response = frappe.read_file(os.path.join(base_path, "leave_application/leave_application_email_template.html"))
|
||||
frappe.get_doc({
|
||||
'doctype': 'Email Template',
|
||||
'name': _("Leave Status Notification"),
|
||||
'response': response,
|
||||
'subject': _("Leave Status Notification"),
|
||||
'owner': frappe.session.user,
|
||||
}).insert(ignore_permissions=True)
|
||||
response = frappe.read_file(
|
||||
os.path.join(base_path, "leave_application/leave_application_email_template.html")
|
||||
)
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Email Template",
|
||||
"name": _("Leave Status Notification"),
|
||||
"response": response,
|
||||
"subject": _("Leave Status Notification"),
|
||||
"owner": frappe.session.user,
|
||||
}
|
||||
).insert(ignore_permissions=True)
|
||||
|
||||
@@ -8,4 +8,9 @@ def execute():
|
||||
|
||||
for company in companies:
|
||||
if company.default_payable_account is not None:
|
||||
frappe.db.set_value("Company", company.name, "default_expense_claim_payable_account", company.default_payable_account)
|
||||
frappe.db.set_value(
|
||||
"Company",
|
||||
company.name,
|
||||
"default_expense_claim_payable_account",
|
||||
company.default_payable_account,
|
||||
)
|
||||
|
||||
@@ -7,6 +7,16 @@ import frappe
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc("assets", "doctype", "Location")
|
||||
for dt in ("Account", "Cost Center", "File", "Employee", "Location", "Task", "Customer Group", "Sales Person", "Territory"):
|
||||
for dt in (
|
||||
"Account",
|
||||
"Cost Center",
|
||||
"File",
|
||||
"Employee",
|
||||
"Location",
|
||||
"Task",
|
||||
"Customer Group",
|
||||
"Sales Person",
|
||||
"Territory",
|
||||
):
|
||||
frappe.reload_doctype(dt)
|
||||
frappe.get_doc("DocType", dt).run_module_method("on_doctype_update")
|
||||
|
||||
@@ -6,31 +6,36 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
'''
|
||||
"""
|
||||
|
||||
Fields to move from item group to item defaults child table
|
||||
[ default_cost_center, default_expense_account, default_income_account ]
|
||||
|
||||
'''
|
||||
"""
|
||||
|
||||
frappe.reload_doc('stock', 'doctype', 'item_default')
|
||||
frappe.reload_doc('setup', 'doctype', 'item_group')
|
||||
frappe.reload_doc("stock", "doctype", "item_default")
|
||||
frappe.reload_doc("setup", "doctype", "item_group")
|
||||
|
||||
companies = frappe.get_all("Company")
|
||||
item_groups = frappe.db.sql("""select name, default_income_account, default_expense_account,\
|
||||
default_cost_center from `tabItem Group`""", as_dict=True)
|
||||
item_groups = frappe.db.sql(
|
||||
"""select name, default_income_account, default_expense_account,\
|
||||
default_cost_center from `tabItem Group`""",
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
if len(companies) == 1:
|
||||
for item_group in item_groups:
|
||||
doc = frappe.get_doc("Item Group", item_group.get("name"))
|
||||
item_group_defaults = []
|
||||
item_group_defaults.append({
|
||||
"company": companies[0].name,
|
||||
"income_account": item_group.get("default_income_account"),
|
||||
"expense_account": item_group.get("default_expense_account"),
|
||||
"buying_cost_center": item_group.get("default_cost_center"),
|
||||
"selling_cost_center": item_group.get("default_cost_center")
|
||||
})
|
||||
item_group_defaults.append(
|
||||
{
|
||||
"company": companies[0].name,
|
||||
"income_account": item_group.get("default_income_account"),
|
||||
"expense_account": item_group.get("default_expense_account"),
|
||||
"buying_cost_center": item_group.get("default_cost_center"),
|
||||
"selling_cost_center": item_group.get("default_cost_center"),
|
||||
}
|
||||
)
|
||||
doc.extend("item_group_defaults", item_group_defaults)
|
||||
for child_doc in doc.item_group_defaults:
|
||||
child_doc.db_insert()
|
||||
@@ -38,10 +43,11 @@ def execute():
|
||||
item_group_dict = {
|
||||
"default_expense_account": ["expense_account"],
|
||||
"default_income_account": ["income_account"],
|
||||
"default_cost_center": ["buying_cost_center", "selling_cost_center"]
|
||||
"default_cost_center": ["buying_cost_center", "selling_cost_center"],
|
||||
}
|
||||
for item_group in item_groups:
|
||||
item_group_defaults = []
|
||||
|
||||
def insert_into_item_defaults(doc_field_name, doc_field_value, company):
|
||||
for d in item_group_defaults:
|
||||
if d.get("company") == company:
|
||||
@@ -50,18 +56,16 @@ def execute():
|
||||
d[doc_field_name[1]] = doc_field_value
|
||||
return
|
||||
|
||||
item_group_defaults.append({
|
||||
"company": company,
|
||||
doc_field_name[0]: doc_field_value
|
||||
})
|
||||
item_group_defaults.append({"company": company, doc_field_name[0]: doc_field_value})
|
||||
|
||||
if(len(doc_field_name) > 1):
|
||||
item_group_defaults[len(item_group_defaults)-1][doc_field_name[1]] = doc_field_value
|
||||
if len(doc_field_name) > 1:
|
||||
item_group_defaults[len(item_group_defaults) - 1][doc_field_name[1]] = doc_field_value
|
||||
|
||||
for d in [
|
||||
["default_expense_account", "Account"], ["default_income_account", "Account"],
|
||||
["default_cost_center", "Cost Center"]
|
||||
]:
|
||||
["default_expense_account", "Account"],
|
||||
["default_income_account", "Account"],
|
||||
["default_cost_center", "Cost Center"],
|
||||
]:
|
||||
if item_group.get(d[0]):
|
||||
company = frappe.get_value(d[1], item_group.get(d[0]), "company", cache=True)
|
||||
doc_field_name = item_group_dict.get(d[0])
|
||||
|
||||
@@ -4,8 +4,8 @@ from erpnext.setup.setup_wizard.operations.install_fixtures import add_market_se
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('crm', 'doctype', 'market_segment')
|
||||
frappe.reload_doc("crm", "doctype", "market_segment")
|
||||
|
||||
frappe.local.lang = frappe.db.get_default("lang") or 'en'
|
||||
frappe.local.lang = frappe.db.get_default("lang") or "en"
|
||||
|
||||
add_market_segments()
|
||||
|
||||
@@ -4,7 +4,7 @@ from erpnext.regional.india.setup import add_permissions
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
company = frappe.get_all("Company", filters={"country": "India"})
|
||||
if not company:
|
||||
return
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ from erpnext.setup.setup_wizard.operations.install_fixtures import add_sale_stag
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('crm', 'doctype', 'sales_stage')
|
||||
frappe.reload_doc("crm", "doctype", "sales_stage")
|
||||
|
||||
frappe.local.lang = frappe.db.get_default("lang") or 'en'
|
||||
frappe.local.lang = frappe.db.get_default("lang") or "en"
|
||||
|
||||
add_sale_stages()
|
||||
|
||||
@@ -2,5 +2,5 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('setup', 'doctype', 'currency_exchange')
|
||||
frappe.reload_doc("setup", "doctype", "currency_exchange")
|
||||
frappe.db.sql("""update `tabCurrency Exchange` set for_buying = 1, for_selling = 1""")
|
||||
|
||||
@@ -4,11 +4,11 @@ from frappe.utils.nestedset import rebuild_tree
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.local.lang = frappe.db.get_default("lang") or 'en'
|
||||
frappe.local.lang = frappe.db.get_default("lang") or "en"
|
||||
|
||||
for doctype in ['department', 'leave_period', 'staffing_plan', 'job_opening']:
|
||||
for doctype in ["department", "leave_period", "staffing_plan", "job_opening"]:
|
||||
frappe.reload_doc("hr", "doctype", doctype)
|
||||
frappe.reload_doc("Payroll", "doctype", 'payroll_entry')
|
||||
frappe.reload_doc("Payroll", "doctype", "payroll_entry")
|
||||
|
||||
companies = frappe.db.get_all("Company", fields=["name", "abbr"])
|
||||
departments = frappe.db.get_all("Department")
|
||||
@@ -35,7 +35,7 @@ def execute():
|
||||
# append list of new department for each company
|
||||
comp_dict[company.name][department.name] = copy_doc.name
|
||||
|
||||
rebuild_tree('Department', 'parent_department')
|
||||
rebuild_tree("Department", "parent_department")
|
||||
doctypes = ["Asset", "Employee", "Payroll Entry", "Staffing Plan", "Job Opening"]
|
||||
|
||||
for d in doctypes:
|
||||
@@ -43,7 +43,8 @@ def execute():
|
||||
|
||||
update_instructors(comp_dict)
|
||||
|
||||
frappe.local.lang = 'en'
|
||||
frappe.local.lang = "en"
|
||||
|
||||
|
||||
def update_records(doctype, comp_dict):
|
||||
when_then = []
|
||||
@@ -51,20 +52,27 @@ def update_records(doctype, comp_dict):
|
||||
records = comp_dict[company]
|
||||
|
||||
for department in records:
|
||||
when_then.append('''
|
||||
when_then.append(
|
||||
"""
|
||||
WHEN company = "%s" and department = "%s"
|
||||
THEN "%s"
|
||||
'''%(company, department, records[department]))
|
||||
"""
|
||||
% (company, department, records[department])
|
||||
)
|
||||
|
||||
if not when_then:
|
||||
return
|
||||
|
||||
frappe.db.sql("""
|
||||
frappe.db.sql(
|
||||
"""
|
||||
update
|
||||
`tab%s`
|
||||
set
|
||||
department = CASE %s END
|
||||
"""%(doctype, " ".join(when_then)))
|
||||
"""
|
||||
% (doctype, " ".join(when_then))
|
||||
)
|
||||
|
||||
|
||||
def update_instructors(comp_dict):
|
||||
when_then = []
|
||||
@@ -74,17 +82,23 @@ def update_instructors(comp_dict):
|
||||
records = comp_dict[employee.company] if employee.company else []
|
||||
|
||||
for department in records:
|
||||
when_then.append('''
|
||||
when_then.append(
|
||||
"""
|
||||
WHEN employee = "%s" and department = "%s"
|
||||
THEN "%s"
|
||||
'''%(employee.name, department, records[department]))
|
||||
"""
|
||||
% (employee.name, department, records[department])
|
||||
)
|
||||
|
||||
if not when_then:
|
||||
return
|
||||
|
||||
frappe.db.sql("""
|
||||
frappe.db.sql(
|
||||
"""
|
||||
update
|
||||
`tabInstructor`
|
||||
set
|
||||
department = CASE %s END
|
||||
"""%(" ".join(when_then)))
|
||||
"""
|
||||
% (" ".join(when_then))
|
||||
)
|
||||
|
||||
@@ -13,48 +13,62 @@ from erpnext.payroll.doctype.salary_structure_assignment.salary_structure_assign
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('Payroll', 'doctype', 'Salary Structure')
|
||||
frappe.reload_doc("Payroll", "doctype", "Salary Structure")
|
||||
frappe.reload_doc("Payroll", "doctype", "Salary Structure Assignment")
|
||||
frappe.db.sql("""
|
||||
frappe.db.sql(
|
||||
"""
|
||||
delete from `tabSalary Structure Assignment`
|
||||
where salary_structure in (select name from `tabSalary Structure` where is_active='No' or docstatus!=1)
|
||||
""")
|
||||
if frappe.db.table_exists('Salary Structure Employee'):
|
||||
ss_details = frappe.db.sql("""
|
||||
"""
|
||||
)
|
||||
if frappe.db.table_exists("Salary Structure Employee"):
|
||||
ss_details = frappe.db.sql(
|
||||
"""
|
||||
select sse.employee, sse.employee_name, sse.from_date, sse.to_date,
|
||||
sse.base, sse.variable, sse.parent as salary_structure, ss.company
|
||||
from `tabSalary Structure Employee` sse, `tabSalary Structure` ss
|
||||
where ss.name = sse.parent AND ss.is_active='Yes'
|
||||
AND sse.employee in (select name from `tabEmployee` where ifNull(status, '') != 'Left')""", as_dict=1)
|
||||
AND sse.employee in (select name from `tabEmployee` where ifNull(status, '') != 'Left')""",
|
||||
as_dict=1,
|
||||
)
|
||||
else:
|
||||
cols = ""
|
||||
if "base" in frappe.db.get_table_columns("Salary Structure"):
|
||||
cols = ", base, variable"
|
||||
|
||||
ss_details = frappe.db.sql("""
|
||||
ss_details = frappe.db.sql(
|
||||
"""
|
||||
select name as salary_structure, employee, employee_name, from_date, to_date, company {0}
|
||||
from `tabSalary Structure`
|
||||
where is_active='Yes'
|
||||
AND employee in (select name from `tabEmployee` where ifNull(status, '') != 'Left')
|
||||
""".format(cols), as_dict=1)
|
||||
""".format(
|
||||
cols
|
||||
),
|
||||
as_dict=1,
|
||||
)
|
||||
|
||||
all_companies = frappe.db.get_all("Company", fields=["name", "default_currency"])
|
||||
for d in all_companies:
|
||||
company = d.name
|
||||
company_currency = d.default_currency
|
||||
|
||||
frappe.db.sql("""update `tabSalary Structure` set currency = %s where company=%s""", (company_currency, company))
|
||||
frappe.db.sql(
|
||||
"""update `tabSalary Structure` set currency = %s where company=%s""",
|
||||
(company_currency, company),
|
||||
)
|
||||
|
||||
for d in ss_details:
|
||||
try:
|
||||
joining_date, relieving_date = frappe.db.get_value("Employee", d.employee,
|
||||
["date_of_joining", "relieving_date"])
|
||||
joining_date, relieving_date = frappe.db.get_value(
|
||||
"Employee", d.employee, ["date_of_joining", "relieving_date"]
|
||||
)
|
||||
from_date = d.from_date
|
||||
if joining_date and getdate(from_date) < joining_date:
|
||||
from_date = joining_date
|
||||
elif relieving_date and getdate(from_date) > relieving_date:
|
||||
continue
|
||||
company_currency = frappe.db.get_value('Company', d.company, 'default_currency')
|
||||
company_currency = frappe.db.get_value("Company", d.company, "default_currency")
|
||||
|
||||
s = frappe.new_doc("Salary Structure Assignment")
|
||||
s.employee = d.employee
|
||||
|
||||
@@ -3,5 +3,5 @@ import frappe
|
||||
|
||||
def execute():
|
||||
if frappe.db.exists("DocType", "Leave Type"):
|
||||
if 'max_days_allowed' in frappe.db.get_table_columns("Leave Type"):
|
||||
if "max_days_allowed" in frappe.db.get_table_columns("Leave Type"):
|
||||
frappe.db.sql("alter table `tabLeave Type` drop column max_days_allowed")
|
||||
|
||||
@@ -4,8 +4,8 @@ from erpnext.regional.india.setup import make_custom_fields
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
if not company:
|
||||
return
|
||||
company = frappe.get_all("Company", filters={"country": "India"})
|
||||
if not company:
|
||||
return
|
||||
|
||||
make_custom_fields()
|
||||
make_custom_fields()
|
||||
|
||||
@@ -2,11 +2,11 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doctype('Employee')
|
||||
frappe.db.sql('update tabEmployee set first_name = employee_name')
|
||||
frappe.reload_doctype("Employee")
|
||||
frappe.db.sql("update tabEmployee set first_name = employee_name")
|
||||
|
||||
# update holiday list
|
||||
frappe.reload_doctype('Holiday List')
|
||||
for holiday_list in frappe.get_all('Holiday List'):
|
||||
holiday_list = frappe.get_doc('Holiday List', holiday_list.name)
|
||||
holiday_list.db_set('total_holidays', len(holiday_list.holidays), update_modified = False)
|
||||
frappe.reload_doctype("Holiday List")
|
||||
for holiday_list in frappe.get_all("Holiday List"):
|
||||
holiday_list = frappe.get_doc("Holiday List", holiday_list.name)
|
||||
holiday_list.db_set("total_holidays", len(holiday_list.holidays), update_modified=False)
|
||||
|
||||
@@ -4,7 +4,7 @@ from erpnext.regional.india.setup import make_custom_fields
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
company = frappe.get_all("Company", filters={"country": "India"})
|
||||
if not company:
|
||||
return
|
||||
frappe.reload_doc("Payroll", "doctype", "Employee Tax Exemption Declaration")
|
||||
@@ -28,38 +28,64 @@ def execute():
|
||||
frappe.reload_doc("accounts", "doctype", "purchase_taxes_and_charges_template")
|
||||
|
||||
# set is_inter_state in Taxes And Charges Templates
|
||||
if frappe.db.has_column("Sales Taxes and Charges Template", "is_inter_state") and\
|
||||
frappe.db.has_column("Purchase Taxes and Charges Template", "is_inter_state"):
|
||||
if frappe.db.has_column(
|
||||
"Sales Taxes and Charges Template", "is_inter_state"
|
||||
) and frappe.db.has_column("Purchase Taxes and Charges Template", "is_inter_state"):
|
||||
|
||||
igst_accounts = set(frappe.db.sql_list('''SELECT igst_account from `tabGST Account` WHERE parent = "GST Settings"'''))
|
||||
cgst_accounts = set(frappe.db.sql_list('''SELECT cgst_account FROM `tabGST Account` WHERE parenttype = "GST Settings"'''))
|
||||
igst_accounts = set(
|
||||
frappe.db.sql_list(
|
||||
'''SELECT igst_account from `tabGST Account` WHERE parent = "GST Settings"'''
|
||||
)
|
||||
)
|
||||
cgst_accounts = set(
|
||||
frappe.db.sql_list(
|
||||
'''SELECT cgst_account FROM `tabGST Account` WHERE parenttype = "GST Settings"'''
|
||||
)
|
||||
)
|
||||
|
||||
when_then_sales = get_formatted_data("Sales Taxes and Charges", igst_accounts, cgst_accounts)
|
||||
when_then_purchase = get_formatted_data("Purchase Taxes and Charges", igst_accounts, cgst_accounts)
|
||||
when_then_purchase = get_formatted_data(
|
||||
"Purchase Taxes and Charges", igst_accounts, cgst_accounts
|
||||
)
|
||||
|
||||
if when_then_sales:
|
||||
frappe.db.sql('''update `tabSales Taxes and Charges Template`
|
||||
frappe.db.sql(
|
||||
"""update `tabSales Taxes and Charges Template`
|
||||
set is_inter_state = Case {when_then} Else 0 End
|
||||
'''.format(when_then=" ".join(when_then_sales)))
|
||||
""".format(
|
||||
when_then=" ".join(when_then_sales)
|
||||
)
|
||||
)
|
||||
|
||||
if when_then_purchase:
|
||||
frappe.db.sql('''update `tabPurchase Taxes and Charges Template`
|
||||
frappe.db.sql(
|
||||
"""update `tabPurchase Taxes and Charges Template`
|
||||
set is_inter_state = Case {when_then} Else 0 End
|
||||
'''.format(when_then=" ".join(when_then_purchase)))
|
||||
""".format(
|
||||
when_then=" ".join(when_then_purchase)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def get_formatted_data(doctype, igst_accounts, cgst_accounts):
|
||||
# fetch all the rows data from child table
|
||||
all_details = frappe.db.sql('''
|
||||
all_details = frappe.db.sql(
|
||||
'''
|
||||
select parent, account_head from `tab{doctype}`
|
||||
where parenttype="{doctype} Template"'''.format(doctype=doctype), as_dict=True)
|
||||
where parenttype="{doctype} Template"'''.format(
|
||||
doctype=doctype
|
||||
),
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
# group the data in the form "parent: [list of accounts]""
|
||||
group_detail = {}
|
||||
for i in all_details:
|
||||
if not i['parent'] in group_detail: group_detail[i['parent']] = []
|
||||
if not i["parent"] in group_detail:
|
||||
group_detail[i["parent"]] = []
|
||||
for j in all_details:
|
||||
if i['parent']==j['parent']:
|
||||
group_detail[i['parent']].append(j['account_head'])
|
||||
if i["parent"] == j["parent"]:
|
||||
group_detail[i["parent"]].append(j["account_head"])
|
||||
|
||||
# form when_then condition based on - if list of accounts for a document
|
||||
# matches any account in igst_accounts list and not matches any in cgst_accounts list
|
||||
@@ -67,6 +93,6 @@ def get_formatted_data(doctype, igst_accounts, cgst_accounts):
|
||||
for i in group_detail:
|
||||
temp = set(group_detail[i])
|
||||
if not temp.isdisjoint(igst_accounts) and temp.isdisjoint(cgst_accounts):
|
||||
when_then.append('''When name='{name}' Then 1'''.format(name=i))
|
||||
when_then.append("""When name='{name}' Then 1""".format(name=i))
|
||||
|
||||
return when_then
|
||||
|
||||
@@ -6,40 +6,50 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('assets', 'doctype', 'asset_finance_book')
|
||||
frappe.reload_doc('assets', 'doctype', 'depreciation_schedule')
|
||||
frappe.reload_doc('assets', 'doctype', 'asset_category')
|
||||
frappe.reload_doc('assets', 'doctype', 'asset')
|
||||
frappe.reload_doc('assets', 'doctype', 'asset_movement')
|
||||
frappe.reload_doc('assets', 'doctype', 'asset_category_account')
|
||||
frappe.reload_doc("assets", "doctype", "asset_finance_book")
|
||||
frappe.reload_doc("assets", "doctype", "depreciation_schedule")
|
||||
frappe.reload_doc("assets", "doctype", "asset_category")
|
||||
frappe.reload_doc("assets", "doctype", "asset")
|
||||
frappe.reload_doc("assets", "doctype", "asset_movement")
|
||||
frappe.reload_doc("assets", "doctype", "asset_category_account")
|
||||
|
||||
if frappe.db.has_column("Asset", "warehouse"):
|
||||
frappe.db.sql(""" update `tabAsset` ast, `tabWarehouse` wh
|
||||
set ast.location = wh.warehouse_name where ast.warehouse = wh.name""")
|
||||
frappe.db.sql(
|
||||
""" update `tabAsset` ast, `tabWarehouse` wh
|
||||
set ast.location = wh.warehouse_name where ast.warehouse = wh.name"""
|
||||
)
|
||||
|
||||
for d in frappe.get_all('Asset'):
|
||||
doc = frappe.get_doc('Asset', d.name)
|
||||
for d in frappe.get_all("Asset"):
|
||||
doc = frappe.get_doc("Asset", d.name)
|
||||
if doc.calculate_depreciation:
|
||||
fb = doc.append('finance_books', {
|
||||
'depreciation_method': doc.depreciation_method,
|
||||
'total_number_of_depreciations': doc.total_number_of_depreciations,
|
||||
'frequency_of_depreciation': doc.frequency_of_depreciation,
|
||||
'depreciation_start_date': doc.next_depreciation_date,
|
||||
'expected_value_after_useful_life': doc.expected_value_after_useful_life,
|
||||
'value_after_depreciation': doc.value_after_depreciation
|
||||
})
|
||||
fb = doc.append(
|
||||
"finance_books",
|
||||
{
|
||||
"depreciation_method": doc.depreciation_method,
|
||||
"total_number_of_depreciations": doc.total_number_of_depreciations,
|
||||
"frequency_of_depreciation": doc.frequency_of_depreciation,
|
||||
"depreciation_start_date": doc.next_depreciation_date,
|
||||
"expected_value_after_useful_life": doc.expected_value_after_useful_life,
|
||||
"value_after_depreciation": doc.value_after_depreciation,
|
||||
},
|
||||
)
|
||||
|
||||
fb.db_update()
|
||||
|
||||
frappe.db.sql(""" update `tabDepreciation Schedule` ds, `tabAsset` ast
|
||||
set ds.depreciation_method = ast.depreciation_method, ds.finance_book_id = 1 where ds.parent = ast.name """)
|
||||
frappe.db.sql(
|
||||
""" update `tabDepreciation Schedule` ds, `tabAsset` ast
|
||||
set ds.depreciation_method = ast.depreciation_method, ds.finance_book_id = 1 where ds.parent = ast.name """
|
||||
)
|
||||
|
||||
for category in frappe.get_all('Asset Category'):
|
||||
for category in frappe.get_all("Asset Category"):
|
||||
asset_category_doc = frappe.get_doc("Asset Category", category)
|
||||
row = asset_category_doc.append('finance_books', {
|
||||
'depreciation_method': asset_category_doc.depreciation_method,
|
||||
'total_number_of_depreciations': asset_category_doc.total_number_of_depreciations,
|
||||
'frequency_of_depreciation': asset_category_doc.frequency_of_depreciation
|
||||
})
|
||||
row = asset_category_doc.append(
|
||||
"finance_books",
|
||||
{
|
||||
"depreciation_method": asset_category_doc.depreciation_method,
|
||||
"total_number_of_depreciations": asset_category_doc.total_number_of_depreciations,
|
||||
"frequency_of_depreciation": asset_category_doc.frequency_of_depreciation,
|
||||
},
|
||||
)
|
||||
|
||||
row.db_update()
|
||||
|
||||
@@ -9,11 +9,11 @@ from erpnext.regional.italy.setup import make_custom_fields, setup_report
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'Italy'})
|
||||
company = frappe.get_all("Company", filters={"country": "Italy"})
|
||||
if not company:
|
||||
return
|
||||
|
||||
frappe.reload_doc('regional', 'report', 'electronic_invoice_register')
|
||||
frappe.reload_doc("regional", "report", "electronic_invoice_register")
|
||||
make_custom_fields()
|
||||
setup_report()
|
||||
|
||||
@@ -25,15 +25,21 @@ def execute():
|
||||
if condition:
|
||||
condition = "state_code = (case state {0} end),".format(condition)
|
||||
|
||||
frappe.db.sql("""
|
||||
frappe.db.sql(
|
||||
"""
|
||||
UPDATE tabAddress set {condition} country_code = UPPER(ifnull((select code
|
||||
from `tabCountry` where name = `tabAddress`.country), ''))
|
||||
where country_code is null and state_code is null
|
||||
""".format(condition=condition))
|
||||
""".format(
|
||||
condition=condition
|
||||
)
|
||||
)
|
||||
|
||||
frappe.db.sql("""
|
||||
frappe.db.sql(
|
||||
"""
|
||||
UPDATE `tabSales Invoice Item` si, `tabSales Order` so
|
||||
set si.customer_po_no = so.po_no, si.customer_po_date = so.po_date
|
||||
WHERE
|
||||
si.sales_order = so.name and so.po_no is not null
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -8,21 +8,26 @@ from erpnext.manufacturing.doctype.work_order.work_order import create_job_card
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('manufacturing', 'doctype', 'work_order')
|
||||
frappe.reload_doc('manufacturing', 'doctype', 'work_order_item')
|
||||
frappe.reload_doc('manufacturing', 'doctype', 'job_card')
|
||||
frappe.reload_doc('manufacturing', 'doctype', 'job_card_item')
|
||||
frappe.reload_doc("manufacturing", "doctype", "work_order")
|
||||
frappe.reload_doc("manufacturing", "doctype", "work_order_item")
|
||||
frappe.reload_doc("manufacturing", "doctype", "job_card")
|
||||
frappe.reload_doc("manufacturing", "doctype", "job_card_item")
|
||||
|
||||
fieldname = frappe.db.get_value('DocField', {'fieldname': 'work_order', 'parent': 'Timesheet'}, 'fieldname')
|
||||
fieldname = frappe.db.get_value(
|
||||
"DocField", {"fieldname": "work_order", "parent": "Timesheet"}, "fieldname"
|
||||
)
|
||||
if not fieldname:
|
||||
fieldname = frappe.db.get_value('DocField', {'fieldname': 'production_order', 'parent': 'Timesheet'}, 'fieldname')
|
||||
if not fieldname: return
|
||||
fieldname = frappe.db.get_value(
|
||||
"DocField", {"fieldname": "production_order", "parent": "Timesheet"}, "fieldname"
|
||||
)
|
||||
if not fieldname:
|
||||
return
|
||||
|
||||
for d in frappe.get_all('Timesheet',
|
||||
filters={fieldname: ['!=', ""], 'docstatus': 0},
|
||||
fields=[fieldname, 'name']):
|
||||
for d in frappe.get_all(
|
||||
"Timesheet", filters={fieldname: ["!=", ""], "docstatus": 0}, fields=[fieldname, "name"]
|
||||
):
|
||||
if d[fieldname]:
|
||||
doc = frappe.get_doc('Work Order', d[fieldname])
|
||||
doc = frappe.get_doc("Work Order", d[fieldname])
|
||||
for row in doc.operations:
|
||||
create_job_card(doc, row, auto_create=True)
|
||||
frappe.delete_doc('Timesheet', d.name)
|
||||
frappe.delete_doc("Timesheet", d.name)
|
||||
|
||||
@@ -7,14 +7,16 @@ from frappe.utils.nestedset import rebuild_tree
|
||||
|
||||
|
||||
def execute():
|
||||
if not frappe.db.get_value('Asset', {'docstatus': ('<', 2) }, 'name'): return
|
||||
frappe.reload_doc('assets', 'doctype', 'location')
|
||||
frappe.reload_doc('stock', 'doctype', 'warehouse')
|
||||
if not frappe.db.get_value("Asset", {"docstatus": ("<", 2)}, "name"):
|
||||
return
|
||||
frappe.reload_doc("assets", "doctype", "location")
|
||||
frappe.reload_doc("stock", "doctype", "warehouse")
|
||||
|
||||
for d in frappe.get_all('Warehouse',
|
||||
fields = ['warehouse_name', 'is_group', 'parent_warehouse'], order_by="lft asc"):
|
||||
for d in frappe.get_all(
|
||||
"Warehouse", fields=["warehouse_name", "is_group", "parent_warehouse"], order_by="lft asc"
|
||||
):
|
||||
try:
|
||||
loc = frappe.new_doc('Location')
|
||||
loc = frappe.new_doc("Location")
|
||||
loc.location_name = d.warehouse_name
|
||||
loc.is_group = d.is_group
|
||||
loc.flags.ignore_mandatory = True
|
||||
@@ -27,5 +29,6 @@ def execute():
|
||||
|
||||
rebuild_tree("Location", "parent_location")
|
||||
|
||||
|
||||
def get_parent_warehouse_name(warehouse):
|
||||
return frappe.db.get_value('Warehouse', warehouse, 'warehouse_name')
|
||||
return frappe.db.get_value("Warehouse", warehouse, "warehouse_name")
|
||||
|
||||
@@ -6,21 +6,29 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('stock', 'doctype', 'quality_inspection_template')
|
||||
frappe.reload_doc('stock', 'doctype', 'item')
|
||||
frappe.reload_doc("stock", "doctype", "quality_inspection_template")
|
||||
frappe.reload_doc("stock", "doctype", "item")
|
||||
|
||||
for data in frappe.get_all('Item Quality Inspection Parameter',
|
||||
fields = ["distinct parent"], filters = {'parenttype': 'Item'}):
|
||||
for data in frappe.get_all(
|
||||
"Item Quality Inspection Parameter", fields=["distinct parent"], filters={"parenttype": "Item"}
|
||||
):
|
||||
qc_doc = frappe.new_doc("Quality Inspection Template")
|
||||
qc_doc.quality_inspection_template_name = 'QIT/%s' % data.parent
|
||||
qc_doc.quality_inspection_template_name = "QIT/%s" % data.parent
|
||||
qc_doc.flags.ignore_mandatory = True
|
||||
qc_doc.save(ignore_permissions=True)
|
||||
|
||||
frappe.db.set_value('Item', data.parent, "quality_inspection_template", qc_doc.name, update_modified=False)
|
||||
frappe.db.sql(""" update `tabItem Quality Inspection Parameter`
|
||||
frappe.db.set_value(
|
||||
"Item", data.parent, "quality_inspection_template", qc_doc.name, update_modified=False
|
||||
)
|
||||
frappe.db.sql(
|
||||
""" update `tabItem Quality Inspection Parameter`
|
||||
set parentfield = 'item_quality_inspection_parameter', parenttype = 'Quality Inspection Template',
|
||||
parent = %s where parenttype = 'Item' and parent = %s""", (qc_doc.name, data.parent))
|
||||
parent = %s where parenttype = 'Item' and parent = %s""",
|
||||
(qc_doc.name, data.parent),
|
||||
)
|
||||
|
||||
# update field in item variant settings
|
||||
frappe.db.sql(""" update `tabVariant Field` set field_name = 'quality_inspection_template'
|
||||
where field_name = 'quality_parameters'""")
|
||||
frappe.db.sql(
|
||||
""" update `tabVariant Field` set field_name = 'quality_inspection_template'
|
||||
where field_name = 'quality_parameters'"""
|
||||
)
|
||||
|
||||
@@ -8,51 +8,55 @@ from frappe.model.utils.rename_field import rename_field
|
||||
|
||||
def execute():
|
||||
# Rename and reload the Land Unit and Linked Land Unit doctypes
|
||||
if frappe.db.table_exists('Land Unit') and not frappe.db.table_exists('Location'):
|
||||
frappe.rename_doc('DocType', 'Land Unit', 'Location', force=True)
|
||||
if frappe.db.table_exists("Land Unit") and not frappe.db.table_exists("Location"):
|
||||
frappe.rename_doc("DocType", "Land Unit", "Location", force=True)
|
||||
|
||||
frappe.reload_doc('assets', 'doctype', 'location')
|
||||
frappe.reload_doc("assets", "doctype", "location")
|
||||
|
||||
if frappe.db.table_exists('Linked Land Unit') and not frappe.db.table_exists('Linked Location'):
|
||||
frappe.rename_doc('DocType', 'Linked Land Unit', 'Linked Location', force=True)
|
||||
if frappe.db.table_exists("Linked Land Unit") and not frappe.db.table_exists("Linked Location"):
|
||||
frappe.rename_doc("DocType", "Linked Land Unit", "Linked Location", force=True)
|
||||
|
||||
frappe.reload_doc('assets', 'doctype', 'linked_location')
|
||||
frappe.reload_doc("assets", "doctype", "linked_location")
|
||||
|
||||
if not frappe.db.table_exists('Crop Cycle'):
|
||||
frappe.reload_doc('agriculture', 'doctype', 'crop_cycle')
|
||||
if not frappe.db.table_exists("Crop Cycle"):
|
||||
frappe.reload_doc("agriculture", "doctype", "crop_cycle")
|
||||
|
||||
# Rename the fields in related doctypes
|
||||
if 'linked_land_unit' in frappe.db.get_table_columns('Crop Cycle'):
|
||||
rename_field('Crop Cycle', 'linked_land_unit', 'linked_location')
|
||||
if "linked_land_unit" in frappe.db.get_table_columns("Crop Cycle"):
|
||||
rename_field("Crop Cycle", "linked_land_unit", "linked_location")
|
||||
|
||||
if 'land_unit' in frappe.db.get_table_columns('Linked Location'):
|
||||
rename_field('Linked Location', 'land_unit', 'location')
|
||||
if "land_unit" in frappe.db.get_table_columns("Linked Location"):
|
||||
rename_field("Linked Location", "land_unit", "location")
|
||||
|
||||
if not frappe.db.exists("Location", "All Land Units"):
|
||||
frappe.get_doc({"doctype": "Location", "is_group": True, "location_name": "All Land Units"}).insert(ignore_permissions=True)
|
||||
frappe.get_doc(
|
||||
{"doctype": "Location", "is_group": True, "location_name": "All Land Units"}
|
||||
).insert(ignore_permissions=True)
|
||||
|
||||
if frappe.db.table_exists('Land Unit'):
|
||||
land_units = frappe.get_all('Land Unit', fields=['*'], order_by='lft')
|
||||
if frappe.db.table_exists("Land Unit"):
|
||||
land_units = frappe.get_all("Land Unit", fields=["*"], order_by="lft")
|
||||
|
||||
for land_unit in land_units:
|
||||
if not frappe.db.exists('Location', land_unit.get('land_unit_name')):
|
||||
frappe.get_doc({
|
||||
'doctype': 'Location',
|
||||
'location_name': land_unit.get('land_unit_name'),
|
||||
'parent_location': land_unit.get('parent_land_unit') or "All Land Units",
|
||||
'is_container': land_unit.get('is_container'),
|
||||
'is_group': land_unit.get('is_group'),
|
||||
'latitude': land_unit.get('latitude'),
|
||||
'longitude': land_unit.get('longitude'),
|
||||
'area': land_unit.get('area'),
|
||||
'location': land_unit.get('location'),
|
||||
'lft': land_unit.get('lft'),
|
||||
'rgt': land_unit.get('rgt')
|
||||
}).insert(ignore_permissions=True)
|
||||
if not frappe.db.exists("Location", land_unit.get("land_unit_name")):
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Location",
|
||||
"location_name": land_unit.get("land_unit_name"),
|
||||
"parent_location": land_unit.get("parent_land_unit") or "All Land Units",
|
||||
"is_container": land_unit.get("is_container"),
|
||||
"is_group": land_unit.get("is_group"),
|
||||
"latitude": land_unit.get("latitude"),
|
||||
"longitude": land_unit.get("longitude"),
|
||||
"area": land_unit.get("area"),
|
||||
"location": land_unit.get("location"),
|
||||
"lft": land_unit.get("lft"),
|
||||
"rgt": land_unit.get("rgt"),
|
||||
}
|
||||
).insert(ignore_permissions=True)
|
||||
|
||||
# Delete the Land Unit and Linked Land Unit doctypes
|
||||
if frappe.db.table_exists('Land Unit'):
|
||||
frappe.delete_doc('DocType', 'Land Unit', force=1)
|
||||
if frappe.db.table_exists("Land Unit"):
|
||||
frappe.delete_doc("DocType", "Land Unit", force=1)
|
||||
|
||||
if frappe.db.table_exists('Linked Land Unit'):
|
||||
frappe.delete_doc('DocType', 'Linked Land Unit', force=1)
|
||||
if frappe.db.table_exists("Linked Land Unit"):
|
||||
frappe.delete_doc("DocType", "Linked Land Unit", force=1)
|
||||
|
||||
@@ -6,22 +6,23 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
'''
|
||||
"""
|
||||
|
||||
Fields to move from the item to item defaults child table
|
||||
[ default_warehouse, buying_cost_center, expense_account, selling_cost_center, income_account ]
|
||||
|
||||
'''
|
||||
if not frappe.db.has_column('Item', 'default_warehouse'):
|
||||
"""
|
||||
if not frappe.db.has_column("Item", "default_warehouse"):
|
||||
return
|
||||
|
||||
frappe.reload_doc('stock', 'doctype', 'item_default')
|
||||
frappe.reload_doc('stock', 'doctype', 'item')
|
||||
frappe.reload_doc("stock", "doctype", "item_default")
|
||||
frappe.reload_doc("stock", "doctype", "item")
|
||||
|
||||
companies = frappe.get_all("Company")
|
||||
if len(companies) == 1 and not frappe.get_all("Item Default", limit=1):
|
||||
try:
|
||||
frappe.db.sql('''
|
||||
frappe.db.sql(
|
||||
"""
|
||||
INSERT INTO `tabItem Default`
|
||||
(name, parent, parenttype, parentfield, idx, company, default_warehouse,
|
||||
buying_cost_center, selling_cost_center, expense_account, income_account, default_supplier)
|
||||
@@ -30,22 +31,30 @@ def execute():
|
||||
'item_defaults' as parentfield, 1 as idx, %s as company, default_warehouse,
|
||||
buying_cost_center, selling_cost_center, expense_account, income_account, default_supplier
|
||||
FROM `tabItem`;
|
||||
''', companies[0].name)
|
||||
""",
|
||||
companies[0].name,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
item_details = frappe.db.sql(""" SELECT name, default_warehouse,
|
||||
item_details = frappe.db.sql(
|
||||
""" SELECT name, default_warehouse,
|
||||
buying_cost_center, expense_account, selling_cost_center, income_account
|
||||
FROM tabItem
|
||||
WHERE
|
||||
name not in (select distinct parent from `tabItem Default`) and ifnull(disabled, 0) = 0"""
|
||||
, as_dict=1)
|
||||
name not in (select distinct parent from `tabItem Default`) and ifnull(disabled, 0) = 0""",
|
||||
as_dict=1,
|
||||
)
|
||||
|
||||
items_default_data = {}
|
||||
for item_data in item_details:
|
||||
for d in [["default_warehouse", "Warehouse"], ["expense_account", "Account"],
|
||||
["income_account", "Account"], ["buying_cost_center", "Cost Center"],
|
||||
["selling_cost_center", "Cost Center"]]:
|
||||
for d in [
|
||||
["default_warehouse", "Warehouse"],
|
||||
["expense_account", "Account"],
|
||||
["income_account", "Account"],
|
||||
["buying_cost_center", "Cost Center"],
|
||||
["selling_cost_center", "Cost Center"],
|
||||
]:
|
||||
if item_data.get(d[0]):
|
||||
company = frappe.get_value(d[1], item_data.get(d[0]), "company", cache=True)
|
||||
|
||||
@@ -73,25 +82,32 @@ def execute():
|
||||
|
||||
for item_code, companywise_item_data in items_default_data.items():
|
||||
for company, item_default_data in companywise_item_data.items():
|
||||
to_insert_data.append((
|
||||
frappe.generate_hash("", 10),
|
||||
item_code,
|
||||
'Item',
|
||||
'item_defaults',
|
||||
company,
|
||||
item_default_data.get('default_warehouse'),
|
||||
item_default_data.get('expense_account'),
|
||||
item_default_data.get('income_account'),
|
||||
item_default_data.get('buying_cost_center'),
|
||||
item_default_data.get('selling_cost_center'),
|
||||
))
|
||||
to_insert_data.append(
|
||||
(
|
||||
frappe.generate_hash("", 10),
|
||||
item_code,
|
||||
"Item",
|
||||
"item_defaults",
|
||||
company,
|
||||
item_default_data.get("default_warehouse"),
|
||||
item_default_data.get("expense_account"),
|
||||
item_default_data.get("income_account"),
|
||||
item_default_data.get("buying_cost_center"),
|
||||
item_default_data.get("selling_cost_center"),
|
||||
)
|
||||
)
|
||||
|
||||
if to_insert_data:
|
||||
frappe.db.sql('''
|
||||
frappe.db.sql(
|
||||
"""
|
||||
INSERT INTO `tabItem Default`
|
||||
(
|
||||
`name`, `parent`, `parenttype`, `parentfield`, `company`, `default_warehouse`,
|
||||
`expense_account`, `income_account`, `buying_cost_center`, `selling_cost_center`
|
||||
)
|
||||
VALUES {}
|
||||
'''.format(', '.join(['%s'] * len(to_insert_data))), tuple(to_insert_data))
|
||||
""".format(
|
||||
", ".join(["%s"] * len(to_insert_data))
|
||||
),
|
||||
tuple(to_insert_data),
|
||||
)
|
||||
|
||||
@@ -7,20 +7,23 @@ def execute():
|
||||
frappe.reload_doc("hr", "doctype", "employee")
|
||||
frappe.reload_doc("hr", "doctype", "department")
|
||||
|
||||
if frappe.db.has_column('Department', 'leave_approver'):
|
||||
rename_field('Department', "leave_approver", "leave_approvers")
|
||||
if frappe.db.has_column("Department", "leave_approver"):
|
||||
rename_field("Department", "leave_approver", "leave_approvers")
|
||||
|
||||
if frappe.db.has_column('Department', 'expense_approver'):
|
||||
rename_field('Department', "expense_approver", "expense_approvers")
|
||||
if frappe.db.has_column("Department", "expense_approver"):
|
||||
rename_field("Department", "expense_approver", "expense_approvers")
|
||||
|
||||
if not frappe.db.table_exists("Employee Leave Approver"):
|
||||
return
|
||||
|
||||
approvers = frappe.db.sql("""select distinct app.leave_approver, emp.department from
|
||||
approvers = frappe.db.sql(
|
||||
"""select distinct app.leave_approver, emp.department from
|
||||
`tabEmployee Leave Approver` app, `tabEmployee` emp
|
||||
where app.parenttype = 'Employee'
|
||||
and emp.name = app.parent
|
||||
""", as_dict=True)
|
||||
""",
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
for record in approvers:
|
||||
if record.department:
|
||||
@@ -28,6 +31,4 @@ def execute():
|
||||
if not department:
|
||||
return
|
||||
if not len(department.leave_approvers):
|
||||
department.append("leave_approvers",{
|
||||
"approver": record.leave_approver
|
||||
}).db_insert()
|
||||
department.append("leave_approvers", {"approver": record.leave_approver}).db_insert()
|
||||
|
||||
@@ -4,4 +4,4 @@ from frappe.utils.nestedset import rebuild_tree
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc("setup", "doctype", "company")
|
||||
rebuild_tree('Company', 'parent_company')
|
||||
rebuild_tree("Company", "parent_company")
|
||||
|
||||
@@ -6,99 +6,102 @@ import frappe
|
||||
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
|
||||
|
||||
doctype_series_map = {
|
||||
'Activity Cost': 'PROJ-ACC-.#####',
|
||||
'Agriculture Task': 'AG-TASK-.#####',
|
||||
'Assessment Plan': 'EDU-ASP-.YYYY.-.#####',
|
||||
'Assessment Result': 'EDU-RES-.YYYY.-.#####',
|
||||
'Asset Movement': 'ACC-ASM-.YYYY.-.#####',
|
||||
'Attendance Request': 'HR-ARQ-.YY.-.MM.-.#####',
|
||||
'Authorization Rule': 'HR-ARU-.#####',
|
||||
'Bank Guarantee': 'ACC-BG-.YYYY.-.#####',
|
||||
'Bin': 'MAT-BIN-.YYYY.-.#####',
|
||||
'Certification Application': 'NPO-CAPP-.YYYY.-.#####',
|
||||
'Certified Consultant': 'NPO-CONS-.YYYY.-.#####',
|
||||
'Chat Room': 'CHAT-ROOM-.#####',
|
||||
'Compensatory Leave Request': 'HR-CMP-.YY.-.MM.-.#####',
|
||||
'Client Script': 'SYS-SCR-.#####',
|
||||
'Employee Benefit Application': 'HR-BEN-APP-.YY.-.MM.-.#####',
|
||||
'Employee Benefit Application Detail': '',
|
||||
'Employee Benefit Claim': 'HR-BEN-CLM-.YY.-.MM.-.#####',
|
||||
'Employee Incentive': 'HR-EINV-.YY.-.MM.-.#####',
|
||||
'Employee Onboarding': 'HR-EMP-ONB-.YYYY.-.#####',
|
||||
'Employee Onboarding Template': 'HR-EMP-ONT-.#####',
|
||||
'Employee Promotion': 'HR-EMP-PRO-.YYYY.-.#####',
|
||||
'Employee Separation': 'HR-EMP-SEP-.YYYY.-.#####',
|
||||
'Employee Separation Template': 'HR-EMP-STP-.#####',
|
||||
'Employee Tax Exemption Declaration': 'HR-TAX-DEC-.YYYY.-.#####',
|
||||
'Employee Tax Exemption Proof Submission': 'HR-TAX-PRF-.YYYY.-.#####',
|
||||
'Employee Transfer': 'HR-EMP-TRN-.YYYY.-.#####',
|
||||
'Event': 'EVENT-.YYYY.-.#####',
|
||||
'Exchange Rate Revaluation': 'ACC-ERR-.YYYY.-.#####',
|
||||
'GL Entry': 'ACC-GLE-.YYYY.-.#####',
|
||||
'Guardian': 'EDU-GRD-.YYYY.-.#####',
|
||||
'Hotel Room Reservation': 'HTL-RES-.YYYY.-.#####',
|
||||
'Item Price': '',
|
||||
'Job Applicant': 'HR-APP-.YYYY.-.#####',
|
||||
'Job Offer': 'HR-OFF-.YYYY.-.#####',
|
||||
'Leave Encashment': 'HR-ENC-.YYYY.-.#####',
|
||||
'Leave Period': 'HR-LPR-.YYYY.-.#####',
|
||||
'Leave Policy': 'HR-LPOL-.YYYY.-.#####',
|
||||
'Loan': 'ACC-LOAN-.YYYY.-.#####',
|
||||
'Loan Application': 'ACC-LOAP-.YYYY.-.#####',
|
||||
'Loyalty Point Entry': '',
|
||||
'Membership': 'NPO-MSH-.YYYY.-.#####',
|
||||
'Packing Slip': 'MAT-PAC-.YYYY.-.#####',
|
||||
'Patient Appointment': 'HLC-APP-.YYYY.-.#####',
|
||||
'Payment Terms Template Detail': '',
|
||||
'Payroll Entry': 'HR-PRUN-.YYYY.-.#####',
|
||||
'Period Closing Voucher': 'ACC-PCV-.YYYY.-.#####',
|
||||
'Plant Analysis': 'AG-PLA-.YYYY.-.#####',
|
||||
'POS Closing Entry': 'POS-CLO-.YYYY.-.#####',
|
||||
'Prepared Report': 'SYS-PREP-.YYYY.-.#####',
|
||||
'Program Enrollment': 'EDU-ENR-.YYYY.-.#####',
|
||||
'Quotation Item': '',
|
||||
'Restaurant Reservation': 'RES-RES-.YYYY.-.#####',
|
||||
'Retention Bonus': 'HR-RTB-.YYYY.-.#####',
|
||||
'Room': 'HTL-ROOM-.YYYY.-.#####',
|
||||
'Salary Structure Assignment': 'HR-SSA-.YY.-.MM.-.#####',
|
||||
'Sales Taxes and Charges': '',
|
||||
'Share Transfer': 'ACC-SHT-.YYYY.-.#####',
|
||||
'Shift Assignment': 'HR-SHA-.YY.-.MM.-.#####',
|
||||
'Shift Request': 'HR-SHR-.YY.-.MM.-.#####',
|
||||
'SMS Log': 'SYS-SMS-.#####',
|
||||
'Soil Analysis': 'AG-ANA-.YY.-.MM.-.#####',
|
||||
'Soil Texture': 'AG-TEX-.YYYY.-.#####',
|
||||
'Stock Ledger Entry': 'MAT-SLE-.YYYY.-.#####',
|
||||
'Student Leave Application': 'EDU-SLA-.YYYY.-.#####',
|
||||
'Student Log': 'EDU-SLOG-.YYYY.-.#####',
|
||||
'Subscription': 'ACC-SUB-.YYYY.-.#####',
|
||||
'Task': 'TASK-.YYYY.-.#####',
|
||||
'Tax Rule': 'ACC-TAX-RULE-.YYYY.-.#####',
|
||||
'Training Feedback': 'HR-TRF-.YYYY.-.#####',
|
||||
'Training Result': 'HR-TRR-.YYYY.-.#####',
|
||||
'Travel Request': 'HR-TRQ-.YYYY.-.#####',
|
||||
'UOM Conversion Factor': 'MAT-UOM-CNV-.#####',
|
||||
'Water Analysis': 'HR-WAT-.YYYY.-.#####',
|
||||
'Workflow Action': 'SYS-WACT-.#####',
|
||||
"Activity Cost": "PROJ-ACC-.#####",
|
||||
"Agriculture Task": "AG-TASK-.#####",
|
||||
"Assessment Plan": "EDU-ASP-.YYYY.-.#####",
|
||||
"Assessment Result": "EDU-RES-.YYYY.-.#####",
|
||||
"Asset Movement": "ACC-ASM-.YYYY.-.#####",
|
||||
"Attendance Request": "HR-ARQ-.YY.-.MM.-.#####",
|
||||
"Authorization Rule": "HR-ARU-.#####",
|
||||
"Bank Guarantee": "ACC-BG-.YYYY.-.#####",
|
||||
"Bin": "MAT-BIN-.YYYY.-.#####",
|
||||
"Certification Application": "NPO-CAPP-.YYYY.-.#####",
|
||||
"Certified Consultant": "NPO-CONS-.YYYY.-.#####",
|
||||
"Chat Room": "CHAT-ROOM-.#####",
|
||||
"Compensatory Leave Request": "HR-CMP-.YY.-.MM.-.#####",
|
||||
"Client Script": "SYS-SCR-.#####",
|
||||
"Employee Benefit Application": "HR-BEN-APP-.YY.-.MM.-.#####",
|
||||
"Employee Benefit Application Detail": "",
|
||||
"Employee Benefit Claim": "HR-BEN-CLM-.YY.-.MM.-.#####",
|
||||
"Employee Incentive": "HR-EINV-.YY.-.MM.-.#####",
|
||||
"Employee Onboarding": "HR-EMP-ONB-.YYYY.-.#####",
|
||||
"Employee Onboarding Template": "HR-EMP-ONT-.#####",
|
||||
"Employee Promotion": "HR-EMP-PRO-.YYYY.-.#####",
|
||||
"Employee Separation": "HR-EMP-SEP-.YYYY.-.#####",
|
||||
"Employee Separation Template": "HR-EMP-STP-.#####",
|
||||
"Employee Tax Exemption Declaration": "HR-TAX-DEC-.YYYY.-.#####",
|
||||
"Employee Tax Exemption Proof Submission": "HR-TAX-PRF-.YYYY.-.#####",
|
||||
"Employee Transfer": "HR-EMP-TRN-.YYYY.-.#####",
|
||||
"Event": "EVENT-.YYYY.-.#####",
|
||||
"Exchange Rate Revaluation": "ACC-ERR-.YYYY.-.#####",
|
||||
"GL Entry": "ACC-GLE-.YYYY.-.#####",
|
||||
"Guardian": "EDU-GRD-.YYYY.-.#####",
|
||||
"Hotel Room Reservation": "HTL-RES-.YYYY.-.#####",
|
||||
"Item Price": "",
|
||||
"Job Applicant": "HR-APP-.YYYY.-.#####",
|
||||
"Job Offer": "HR-OFF-.YYYY.-.#####",
|
||||
"Leave Encashment": "HR-ENC-.YYYY.-.#####",
|
||||
"Leave Period": "HR-LPR-.YYYY.-.#####",
|
||||
"Leave Policy": "HR-LPOL-.YYYY.-.#####",
|
||||
"Loan": "ACC-LOAN-.YYYY.-.#####",
|
||||
"Loan Application": "ACC-LOAP-.YYYY.-.#####",
|
||||
"Loyalty Point Entry": "",
|
||||
"Membership": "NPO-MSH-.YYYY.-.#####",
|
||||
"Packing Slip": "MAT-PAC-.YYYY.-.#####",
|
||||
"Patient Appointment": "HLC-APP-.YYYY.-.#####",
|
||||
"Payment Terms Template Detail": "",
|
||||
"Payroll Entry": "HR-PRUN-.YYYY.-.#####",
|
||||
"Period Closing Voucher": "ACC-PCV-.YYYY.-.#####",
|
||||
"Plant Analysis": "AG-PLA-.YYYY.-.#####",
|
||||
"POS Closing Entry": "POS-CLO-.YYYY.-.#####",
|
||||
"Prepared Report": "SYS-PREP-.YYYY.-.#####",
|
||||
"Program Enrollment": "EDU-ENR-.YYYY.-.#####",
|
||||
"Quotation Item": "",
|
||||
"Restaurant Reservation": "RES-RES-.YYYY.-.#####",
|
||||
"Retention Bonus": "HR-RTB-.YYYY.-.#####",
|
||||
"Room": "HTL-ROOM-.YYYY.-.#####",
|
||||
"Salary Structure Assignment": "HR-SSA-.YY.-.MM.-.#####",
|
||||
"Sales Taxes and Charges": "",
|
||||
"Share Transfer": "ACC-SHT-.YYYY.-.#####",
|
||||
"Shift Assignment": "HR-SHA-.YY.-.MM.-.#####",
|
||||
"Shift Request": "HR-SHR-.YY.-.MM.-.#####",
|
||||
"SMS Log": "SYS-SMS-.#####",
|
||||
"Soil Analysis": "AG-ANA-.YY.-.MM.-.#####",
|
||||
"Soil Texture": "AG-TEX-.YYYY.-.#####",
|
||||
"Stock Ledger Entry": "MAT-SLE-.YYYY.-.#####",
|
||||
"Student Leave Application": "EDU-SLA-.YYYY.-.#####",
|
||||
"Student Log": "EDU-SLOG-.YYYY.-.#####",
|
||||
"Subscription": "ACC-SUB-.YYYY.-.#####",
|
||||
"Task": "TASK-.YYYY.-.#####",
|
||||
"Tax Rule": "ACC-TAX-RULE-.YYYY.-.#####",
|
||||
"Training Feedback": "HR-TRF-.YYYY.-.#####",
|
||||
"Training Result": "HR-TRR-.YYYY.-.#####",
|
||||
"Travel Request": "HR-TRQ-.YYYY.-.#####",
|
||||
"UOM Conversion Factor": "MAT-UOM-CNV-.#####",
|
||||
"Water Analysis": "HR-WAT-.YYYY.-.#####",
|
||||
"Workflow Action": "SYS-WACT-.#####",
|
||||
}
|
||||
|
||||
|
||||
def execute():
|
||||
series_to_set = get_series()
|
||||
for doctype, opts in series_to_set.items():
|
||||
set_series(doctype, opts['value'])
|
||||
set_series(doctype, opts["value"])
|
||||
|
||||
|
||||
def set_series(doctype, value):
|
||||
doc = frappe.db.exists('Property Setter', {'doc_type': doctype, 'property': 'autoname'})
|
||||
doc = frappe.db.exists("Property Setter", {"doc_type": doctype, "property": "autoname"})
|
||||
if doc:
|
||||
frappe.db.set_value('Property Setter', doc, 'value', value)
|
||||
frappe.db.set_value("Property Setter", doc, "value", value)
|
||||
else:
|
||||
make_property_setter(doctype, '', 'autoname', value, '', for_doctype = True)
|
||||
make_property_setter(doctype, "", "autoname", value, "", for_doctype=True)
|
||||
|
||||
|
||||
def get_series():
|
||||
series_to_set = {}
|
||||
|
||||
for doctype in doctype_series_map:
|
||||
if not frappe.db.exists('DocType', doctype):
|
||||
if not frappe.db.exists("DocType", doctype):
|
||||
continue
|
||||
|
||||
if not frappe.db.a_row_exists(doctype):
|
||||
@@ -110,10 +113,11 @@ def get_series():
|
||||
|
||||
# set autoname property setter
|
||||
if series_to_preserve:
|
||||
series_to_set[doctype] = {'value': series_to_preserve}
|
||||
series_to_set[doctype] = {"value": series_to_preserve}
|
||||
|
||||
return series_to_set
|
||||
|
||||
|
||||
def get_series_to_preserve(doctype):
|
||||
series_to_preserve = frappe.db.get_value('DocType', doctype, 'autoname')
|
||||
series_to_preserve = frappe.db.get_value("DocType", doctype, "autoname")
|
||||
return series_to_preserve
|
||||
|
||||
@@ -6,82 +6,88 @@ import frappe
|
||||
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
|
||||
|
||||
doctype_series_map = {
|
||||
'Additional Salary': 'HR-ADS-.YY.-.MM.-',
|
||||
'Appraisal': 'HR-APR-.YY.-.MM.',
|
||||
'Asset': 'ACC-ASS-.YYYY.-',
|
||||
'Attendance': 'HR-ATT-.YYYY.-',
|
||||
'Auto Repeat': 'SYS-ARP-.YYYY.-',
|
||||
'Blanket Order': 'MFG-BLR-.YYYY.-',
|
||||
'C-Form': 'ACC-CF-.YYYY.-',
|
||||
'Campaign': 'SAL-CAM-.YYYY.-',
|
||||
'Course Schedule': 'EDU-CSH-.YYYY.-',
|
||||
'Customer': 'CUST-.YYYY.-',
|
||||
'Delivery Note': 'MAT-DN-.YYYY.-',
|
||||
'Delivery Trip': 'MAT-DT-.YYYY.-',
|
||||
'Driver': 'HR-DRI-.YYYY.-',
|
||||
'Employee': 'HR-EMP-',
|
||||
'Employee Advance': 'HR-EAD-.YYYY.-',
|
||||
'Expense Claim': 'HR-EXP-.YYYY.-',
|
||||
'Fee Schedule': 'EDU-FSH-.YYYY.-',
|
||||
'Fee Structure': 'EDU-FST-.YYYY.-',
|
||||
'Fees': 'EDU-FEE-.YYYY.-',
|
||||
'Installation Note': 'MAT-INS-.YYYY.-',
|
||||
'Instructor': 'EDU-INS-.YYYY.-',
|
||||
'Issue': 'ISS-.YYYY.-',
|
||||
'Journal Entry': 'ACC-JV-.YYYY.-',
|
||||
'Landed Cost Voucher': 'MAT-LCV-.YYYY.-',
|
||||
'Lead': 'CRM-LEAD-.YYYY.-',
|
||||
'Leave Allocation': 'HR-LAL-.YYYY.-',
|
||||
'Leave Application': 'HR-LAP-.YYYY.-',
|
||||
'Maintenance Schedule': 'MAT-MSH-.YYYY.-',
|
||||
'Maintenance Visit': 'MAT-MVS-.YYYY.-',
|
||||
'Material Request': 'MAT-MR-.YYYY.-',
|
||||
'Member': 'NPO-MEM-.YYYY.-',
|
||||
'Opportunity': 'CRM-OPP-.YYYY.-',
|
||||
'Packing Slip': 'MAT-PAC-.YYYY.-',
|
||||
'Payment Entry': 'ACC-PAY-.YYYY.-',
|
||||
'Payment Request': 'ACC-PRQ-.YYYY.-',
|
||||
'Production Plan': 'MFG-PP-.YYYY.-',
|
||||
'Project Update': 'PROJ-UPD-.YYYY.-',
|
||||
'Purchase Invoice': 'ACC-PINV-.YYYY.-',
|
||||
'Purchase Order': 'PUR-ORD-.YYYY.-',
|
||||
'Purchase Receipt': 'MAT-PRE-.YYYY.-',
|
||||
'Quality Inspection': 'MAT-QA-.YYYY.-',
|
||||
'Quotation': 'SAL-QTN-.YYYY.-',
|
||||
'Request for Quotation': 'PUR-RFQ-.YYYY.-',
|
||||
'Sales Invoice': 'ACC-SINV-.YYYY.-',
|
||||
'Sales Order': 'SAL-ORD-.YYYY.-',
|
||||
'Sample Collection': 'HLC-SC-.YYYY.-',
|
||||
'Shareholder': 'ACC-SH-.YYYY.-',
|
||||
'Stock Entry': 'MAT-STE-.YYYY.-',
|
||||
'Stock Reconciliation': 'MAT-RECO-.YYYY.-',
|
||||
'Student': 'EDU-STU-.YYYY.-',
|
||||
'Student Applicant': 'EDU-APP-.YYYY.-',
|
||||
'Supplier': 'SUP-.YYYY.-',
|
||||
'Supplier Quotation': 'PUR-SQTN-.YYYY.-',
|
||||
'Supplier Scorecard Period': 'PU-SSP-.YYYY.-',
|
||||
'Timesheet': 'TS-.YYYY.-',
|
||||
'Vehicle Log': 'HR-VLOG-.YYYY.-',
|
||||
'Warranty Claim': 'SER-WRN-.YYYY.-',
|
||||
'Work Order': 'MFG-WO-.YYYY.-'
|
||||
"Additional Salary": "HR-ADS-.YY.-.MM.-",
|
||||
"Appraisal": "HR-APR-.YY.-.MM.",
|
||||
"Asset": "ACC-ASS-.YYYY.-",
|
||||
"Attendance": "HR-ATT-.YYYY.-",
|
||||
"Auto Repeat": "SYS-ARP-.YYYY.-",
|
||||
"Blanket Order": "MFG-BLR-.YYYY.-",
|
||||
"C-Form": "ACC-CF-.YYYY.-",
|
||||
"Campaign": "SAL-CAM-.YYYY.-",
|
||||
"Course Schedule": "EDU-CSH-.YYYY.-",
|
||||
"Customer": "CUST-.YYYY.-",
|
||||
"Delivery Note": "MAT-DN-.YYYY.-",
|
||||
"Delivery Trip": "MAT-DT-.YYYY.-",
|
||||
"Driver": "HR-DRI-.YYYY.-",
|
||||
"Employee": "HR-EMP-",
|
||||
"Employee Advance": "HR-EAD-.YYYY.-",
|
||||
"Expense Claim": "HR-EXP-.YYYY.-",
|
||||
"Fee Schedule": "EDU-FSH-.YYYY.-",
|
||||
"Fee Structure": "EDU-FST-.YYYY.-",
|
||||
"Fees": "EDU-FEE-.YYYY.-",
|
||||
"Installation Note": "MAT-INS-.YYYY.-",
|
||||
"Instructor": "EDU-INS-.YYYY.-",
|
||||
"Issue": "ISS-.YYYY.-",
|
||||
"Journal Entry": "ACC-JV-.YYYY.-",
|
||||
"Landed Cost Voucher": "MAT-LCV-.YYYY.-",
|
||||
"Lead": "CRM-LEAD-.YYYY.-",
|
||||
"Leave Allocation": "HR-LAL-.YYYY.-",
|
||||
"Leave Application": "HR-LAP-.YYYY.-",
|
||||
"Maintenance Schedule": "MAT-MSH-.YYYY.-",
|
||||
"Maintenance Visit": "MAT-MVS-.YYYY.-",
|
||||
"Material Request": "MAT-MR-.YYYY.-",
|
||||
"Member": "NPO-MEM-.YYYY.-",
|
||||
"Opportunity": "CRM-OPP-.YYYY.-",
|
||||
"Packing Slip": "MAT-PAC-.YYYY.-",
|
||||
"Payment Entry": "ACC-PAY-.YYYY.-",
|
||||
"Payment Request": "ACC-PRQ-.YYYY.-",
|
||||
"Production Plan": "MFG-PP-.YYYY.-",
|
||||
"Project Update": "PROJ-UPD-.YYYY.-",
|
||||
"Purchase Invoice": "ACC-PINV-.YYYY.-",
|
||||
"Purchase Order": "PUR-ORD-.YYYY.-",
|
||||
"Purchase Receipt": "MAT-PRE-.YYYY.-",
|
||||
"Quality Inspection": "MAT-QA-.YYYY.-",
|
||||
"Quotation": "SAL-QTN-.YYYY.-",
|
||||
"Request for Quotation": "PUR-RFQ-.YYYY.-",
|
||||
"Sales Invoice": "ACC-SINV-.YYYY.-",
|
||||
"Sales Order": "SAL-ORD-.YYYY.-",
|
||||
"Sample Collection": "HLC-SC-.YYYY.-",
|
||||
"Shareholder": "ACC-SH-.YYYY.-",
|
||||
"Stock Entry": "MAT-STE-.YYYY.-",
|
||||
"Stock Reconciliation": "MAT-RECO-.YYYY.-",
|
||||
"Student": "EDU-STU-.YYYY.-",
|
||||
"Student Applicant": "EDU-APP-.YYYY.-",
|
||||
"Supplier": "SUP-.YYYY.-",
|
||||
"Supplier Quotation": "PUR-SQTN-.YYYY.-",
|
||||
"Supplier Scorecard Period": "PU-SSP-.YYYY.-",
|
||||
"Timesheet": "TS-.YYYY.-",
|
||||
"Vehicle Log": "HR-VLOG-.YYYY.-",
|
||||
"Warranty Claim": "SER-WRN-.YYYY.-",
|
||||
"Work Order": "MFG-WO-.YYYY.-",
|
||||
}
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.db.sql("""
|
||||
frappe.db.sql(
|
||||
"""
|
||||
update `tabProperty Setter`
|
||||
set name=concat(doc_type, '-', field_name, '-', property)
|
||||
where property='fetch_from'
|
||||
""")
|
||||
"""
|
||||
)
|
||||
series_to_set = get_series()
|
||||
for doctype, opts in series_to_set.items():
|
||||
set_series(doctype, opts["options"], opts["default"])
|
||||
|
||||
|
||||
def set_series(doctype, options, default):
|
||||
def _make_property_setter(property_name, value):
|
||||
property_setter = frappe.db.exists('Property Setter',
|
||||
{'doc_type': doctype, 'field_name': 'naming_series', 'property': property_name})
|
||||
property_setter = frappe.db.exists(
|
||||
"Property Setter",
|
||||
{"doc_type": doctype, "field_name": "naming_series", "property": property_name},
|
||||
)
|
||||
if property_setter:
|
||||
frappe.db.set_value('Property Setter', property_setter, 'value', value)
|
||||
frappe.db.set_value("Property Setter", property_setter, "value", value)
|
||||
else:
|
||||
make_property_setter(doctype, "naming_series", "options", value, "Text")
|
||||
|
||||
@@ -89,17 +95,18 @@ def set_series(doctype, options, default):
|
||||
if default:
|
||||
_make_property_setter("default", default)
|
||||
|
||||
|
||||
def get_series():
|
||||
series_to_set = {}
|
||||
|
||||
for doctype in doctype_series_map:
|
||||
if not frappe.db.exists('DocType', doctype):
|
||||
if not frappe.db.exists("DocType", doctype):
|
||||
continue
|
||||
if not frappe.db.a_row_exists(doctype):
|
||||
continue
|
||||
if not frappe.db.has_column(doctype, 'naming_series'):
|
||||
if not frappe.db.has_column(doctype, "naming_series"):
|
||||
continue
|
||||
if not frappe.get_meta(doctype).has_field('naming_series'):
|
||||
if not frappe.get_meta(doctype).has_field("naming_series"):
|
||||
continue
|
||||
series_to_preserve = list(filter(None, get_series_to_preserve(doctype)))
|
||||
default_series = get_default_series(doctype)
|
||||
@@ -117,12 +124,18 @@ def get_series():
|
||||
|
||||
return series_to_set
|
||||
|
||||
|
||||
def get_series_to_preserve(doctype):
|
||||
series_to_preserve = frappe.db.sql_list("""select distinct naming_series from `tab{doctype}` where ifnull(naming_series, '') != ''""".format(doctype=doctype))
|
||||
series_to_preserve = frappe.db.sql_list(
|
||||
"""select distinct naming_series from `tab{doctype}` where ifnull(naming_series, '') != ''""".format(
|
||||
doctype=doctype
|
||||
)
|
||||
)
|
||||
series_to_preserve.sort()
|
||||
return series_to_preserve
|
||||
|
||||
|
||||
def get_default_series(doctype):
|
||||
field = frappe.get_meta(doctype).get_field("naming_series")
|
||||
default_series = field.get('default', '') if field else ''
|
||||
default_series = field.get("default", "") if field else ""
|
||||
return default_series
|
||||
|
||||
@@ -2,7 +2,7 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
'''Remove barcodes field from "Copy Fields to Variants" table because barcodes must be unique'''
|
||||
"""Remove barcodes field from "Copy Fields to Variants" table because barcodes must be unique"""
|
||||
|
||||
settings = frappe.get_doc('Item Variant Settings')
|
||||
settings = frappe.get_doc("Item Variant Settings")
|
||||
settings.remove_invalid_fields_for_copy_fields_in_variants()
|
||||
|
||||
@@ -2,9 +2,10 @@ import frappe
|
||||
|
||||
# this patch should have been included with this PR https://github.com/frappe/erpnext/pull/14302
|
||||
|
||||
|
||||
def execute():
|
||||
if frappe.db.table_exists("Additional Salary Component"):
|
||||
if not frappe.db.table_exists("Additional Salary"):
|
||||
frappe.rename_doc("DocType", "Additional Salary Component", "Additional Salary")
|
||||
|
||||
frappe.delete_doc('DocType', "Additional Salary Component")
|
||||
frappe.delete_doc("DocType", "Additional Salary Component")
|
||||
|
||||
@@ -6,6 +6,8 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
if frappe.db.table_exists("Asset Adjustment") and not frappe.db.table_exists("Asset Value Adjustment"):
|
||||
frappe.rename_doc('DocType', 'Asset Adjustment', 'Asset Value Adjustment', force=True)
|
||||
frappe.reload_doc('assets', 'doctype', 'asset_value_adjustment')
|
||||
if frappe.db.table_exists("Asset Adjustment") and not frappe.db.table_exists(
|
||||
"Asset Value Adjustment"
|
||||
):
|
||||
frappe.rename_doc("DocType", "Asset Adjustment", "Asset Value Adjustment", force=True)
|
||||
frappe.reload_doc("assets", "doctype", "asset_value_adjustment")
|
||||
|
||||
@@ -7,28 +7,36 @@ from frappe.model.utils.rename_field import rename_field
|
||||
|
||||
|
||||
def execute():
|
||||
# updating column value to handle field change from Data to Currency
|
||||
changed_field = "base_scrap_material_cost"
|
||||
frappe.db.sql(f"update `tabBOM` set {changed_field} = '0' where trim(coalesce({changed_field}, ''))= ''")
|
||||
# updating column value to handle field change from Data to Currency
|
||||
changed_field = "base_scrap_material_cost"
|
||||
frappe.db.sql(
|
||||
f"update `tabBOM` set {changed_field} = '0' where trim(coalesce({changed_field}, ''))= ''"
|
||||
)
|
||||
|
||||
for doctype in ['BOM Explosion Item', 'BOM Item', 'Work Order Item', 'Item']:
|
||||
if frappe.db.has_column(doctype, 'allow_transfer_for_manufacture'):
|
||||
if doctype != 'Item':
|
||||
frappe.reload_doc('manufacturing', 'doctype', frappe.scrub(doctype))
|
||||
else:
|
||||
frappe.reload_doc('stock', 'doctype', frappe.scrub(doctype))
|
||||
for doctype in ["BOM Explosion Item", "BOM Item", "Work Order Item", "Item"]:
|
||||
if frappe.db.has_column(doctype, "allow_transfer_for_manufacture"):
|
||||
if doctype != "Item":
|
||||
frappe.reload_doc("manufacturing", "doctype", frappe.scrub(doctype))
|
||||
else:
|
||||
frappe.reload_doc("stock", "doctype", frappe.scrub(doctype))
|
||||
|
||||
rename_field(doctype, "allow_transfer_for_manufacture", "include_item_in_manufacturing")
|
||||
rename_field(doctype, "allow_transfer_for_manufacture", "include_item_in_manufacturing")
|
||||
|
||||
for doctype in ['BOM', 'Work Order']:
|
||||
frappe.reload_doc('manufacturing', 'doctype', frappe.scrub(doctype))
|
||||
for doctype in ["BOM", "Work Order"]:
|
||||
frappe.reload_doc("manufacturing", "doctype", frappe.scrub(doctype))
|
||||
|
||||
if frappe.db.has_column(doctype, 'transfer_material_against_job_card'):
|
||||
frappe.db.sql(""" UPDATE `tab%s`
|
||||
if frappe.db.has_column(doctype, "transfer_material_against_job_card"):
|
||||
frappe.db.sql(
|
||||
""" UPDATE `tab%s`
|
||||
SET transfer_material_against = CASE WHEN
|
||||
transfer_material_against_job_card = 1 then 'Job Card' Else 'Work Order' END
|
||||
WHERE docstatus < 2""" % (doctype))
|
||||
else:
|
||||
frappe.db.sql(""" UPDATE `tab%s`
|
||||
WHERE docstatus < 2"""
|
||||
% (doctype)
|
||||
)
|
||||
else:
|
||||
frappe.db.sql(
|
||||
""" UPDATE `tab%s`
|
||||
SET transfer_material_against = 'Work Order'
|
||||
WHERE docstatus < 2""" % (doctype))
|
||||
WHERE docstatus < 2"""
|
||||
% (doctype)
|
||||
)
|
||||
|
||||
@@ -3,7 +3,9 @@ import frappe
|
||||
|
||||
def execute():
|
||||
items = []
|
||||
items = frappe.db.sql("""select item_code from `tabItem` group by item_code having count(*) > 1""", as_dict=True)
|
||||
items = frappe.db.sql(
|
||||
"""select item_code from `tabItem` group by item_code having count(*) > 1""", as_dict=True
|
||||
)
|
||||
if items:
|
||||
for item in items:
|
||||
frappe.db.sql("""update `tabItem` set item_code=name where item_code = %s""", (item.item_code))
|
||||
|
||||
@@ -3,11 +3,13 @@ from frappe.model.utils.rename_field import rename_field
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.db.sql("""
|
||||
frappe.db.sql(
|
||||
"""
|
||||
UPDATE `tabLeave Type`
|
||||
SET max_days_allowed = '0'
|
||||
WHERE trim(coalesce(max_days_allowed, '')) = ''
|
||||
""")
|
||||
"""
|
||||
)
|
||||
frappe.db.sql_ddl("""ALTER table `tabLeave Type` modify max_days_allowed int(8) NOT NULL""")
|
||||
frappe.reload_doc("hr", "doctype", "leave_type")
|
||||
rename_field("Leave Type", "max_days_allowed", "max_continuous_days_allowed")
|
||||
|
||||
@@ -3,8 +3,8 @@ import frappe
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc("non_profit", "doctype", "member")
|
||||
old_named_members = frappe.get_all("Member", filters = {"name": ("not like", "MEM-%")})
|
||||
correctly_named_members = frappe.get_all("Member", filters = {"name": ("like", "MEM-%")})
|
||||
old_named_members = frappe.get_all("Member", filters={"name": ("not like", "MEM-%")})
|
||||
correctly_named_members = frappe.get_all("Member", filters={"name": ("like", "MEM-%")})
|
||||
current_index = len(correctly_named_members)
|
||||
|
||||
for member in old_named_members:
|
||||
|
||||
@@ -7,5 +7,9 @@ from frappe.model.utils.rename_field import rename_field
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('manufacturing', 'doctype', 'manufacturing_settings')
|
||||
rename_field('Manufacturing Settings', 'over_production_allowance_percentage', 'overproduction_percentage_for_sales_order')
|
||||
frappe.reload_doc("manufacturing", "doctype", "manufacturing_settings")
|
||||
rename_field(
|
||||
"Manufacturing Settings",
|
||||
"over_production_allowance_percentage",
|
||||
"overproduction_percentage_for_sales_order",
|
||||
)
|
||||
|
||||
@@ -7,22 +7,28 @@ from frappe.model.utils.rename_field import rename_field
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.rename_doc('DocType', 'Production Order', 'Work Order', force=True)
|
||||
frappe.reload_doc('manufacturing', 'doctype', 'work_order')
|
||||
frappe.rename_doc("DocType", "Production Order", "Work Order", force=True)
|
||||
frappe.reload_doc("manufacturing", "doctype", "work_order")
|
||||
|
||||
frappe.rename_doc('DocType', 'Production Order Item', 'Work Order Item', force=True)
|
||||
frappe.reload_doc('manufacturing', 'doctype', 'work_order_item')
|
||||
frappe.rename_doc("DocType", "Production Order Item", "Work Order Item", force=True)
|
||||
frappe.reload_doc("manufacturing", "doctype", "work_order_item")
|
||||
|
||||
frappe.rename_doc('DocType', 'Production Order Operation', 'Work Order Operation', force=True)
|
||||
frappe.reload_doc('manufacturing', 'doctype', 'work_order_operation')
|
||||
frappe.rename_doc("DocType", "Production Order Operation", "Work Order Operation", force=True)
|
||||
frappe.reload_doc("manufacturing", "doctype", "work_order_operation")
|
||||
|
||||
frappe.reload_doc('projects', 'doctype', 'timesheet')
|
||||
frappe.reload_doc('stock', 'doctype', 'stock_entry')
|
||||
frappe.reload_doc("projects", "doctype", "timesheet")
|
||||
frappe.reload_doc("stock", "doctype", "stock_entry")
|
||||
rename_field("Timesheet", "production_order", "work_order")
|
||||
rename_field("Stock Entry", "production_order", "work_order")
|
||||
|
||||
frappe.rename_doc("Report", "Production Orders in Progress", "Work Orders in Progress", force=True)
|
||||
frappe.rename_doc(
|
||||
"Report", "Production Orders in Progress", "Work Orders in Progress", force=True
|
||||
)
|
||||
frappe.rename_doc("Report", "Completed Production Orders", "Completed Work Orders", force=True)
|
||||
frappe.rename_doc("Report", "Open Production Orders", "Open Work Orders", force=True)
|
||||
frappe.rename_doc("Report", "Issued Items Against Production Order", "Issued Items Against Work Order", force=True)
|
||||
frappe.rename_doc("Report", "Production Order Stock Report", "Work Order Stock Report", force=True)
|
||||
frappe.rename_doc(
|
||||
"Report", "Issued Items Against Production Order", "Issued Items Against Work Order", force=True
|
||||
)
|
||||
frappe.rename_doc(
|
||||
"Report", "Production Order Stock Report", "Work Order Stock Report", force=True
|
||||
)
|
||||
|
||||
@@ -6,10 +6,10 @@ from frappe.utils.nestedset import rebuild_tree
|
||||
|
||||
def execute():
|
||||
if frappe.db.table_exists("Supplier Group"):
|
||||
frappe.reload_doc('setup', 'doctype', 'supplier_group')
|
||||
frappe.reload_doc("setup", "doctype", "supplier_group")
|
||||
elif frappe.db.table_exists("Supplier Type"):
|
||||
frappe.rename_doc("DocType", "Supplier Type", "Supplier Group", force=True)
|
||||
frappe.reload_doc('setup', 'doctype', 'supplier_group')
|
||||
frappe.reload_doc("setup", "doctype", "supplier_group")
|
||||
frappe.reload_doc("accounts", "doctype", "pricing_rule")
|
||||
frappe.reload_doc("accounts", "doctype", "tax_rule")
|
||||
frappe.reload_doc("buying", "doctype", "buying_settings")
|
||||
@@ -22,16 +22,23 @@ def execute():
|
||||
|
||||
build_tree()
|
||||
|
||||
def build_tree():
|
||||
frappe.db.sql("""update `tabSupplier Group` set parent_supplier_group = '{0}'
|
||||
where is_group = 0""".format(_('All Supplier Groups')))
|
||||
|
||||
if not frappe.db.exists("Supplier Group", _('All Supplier Groups')):
|
||||
frappe.get_doc({
|
||||
'doctype': 'Supplier Group',
|
||||
'supplier_group_name': _('All Supplier Groups'),
|
||||
'is_group': 1,
|
||||
'parent_supplier_group': ''
|
||||
}).insert(ignore_permissions=True)
|
||||
def build_tree():
|
||||
frappe.db.sql(
|
||||
"""update `tabSupplier Group` set parent_supplier_group = '{0}'
|
||||
where is_group = 0""".format(
|
||||
_("All Supplier Groups")
|
||||
)
|
||||
)
|
||||
|
||||
if not frappe.db.exists("Supplier Group", _("All Supplier Groups")):
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Supplier Group",
|
||||
"supplier_group_name": _("All Supplier Groups"),
|
||||
"is_group": 1,
|
||||
"parent_supplier_group": "",
|
||||
}
|
||||
).insert(ignore_permissions=True)
|
||||
|
||||
rebuild_tree("Supplier Group", "parent_supplier_group")
|
||||
|
||||
@@ -7,8 +7,8 @@ from frappe.model.utils.rename_field import rename_field
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('projects', 'doctype', 'project')
|
||||
frappe.reload_doc("projects", "doctype", "project")
|
||||
|
||||
if frappe.db.has_column('Project', 'from'):
|
||||
rename_field('Project', 'from', 'from_time')
|
||||
rename_field('Project', 'to', 'to_time')
|
||||
if frappe.db.has_column("Project", "from"):
|
||||
rename_field("Project", "from", "from_time")
|
||||
rename_field("Project", "to", "to_time")
|
||||
|
||||
@@ -2,22 +2,36 @@ import frappe
|
||||
|
||||
# Set department value based on employee value
|
||||
|
||||
|
||||
def execute():
|
||||
|
||||
doctypes_to_update = {
|
||||
'hr': ['Appraisal', 'Leave Allocation', 'Expense Claim', 'Salary Slip',
|
||||
'Attendance', 'Training Feedback', 'Training Result Employee','Leave Application',
|
||||
'Employee Advance', 'Training Event Employee', 'Payroll Employee Detail'],
|
||||
'education': ['Instructor'],
|
||||
'projects': ['Activity Cost', 'Timesheet'],
|
||||
'setup': ['Sales Person']
|
||||
"hr": [
|
||||
"Appraisal",
|
||||
"Leave Allocation",
|
||||
"Expense Claim",
|
||||
"Salary Slip",
|
||||
"Attendance",
|
||||
"Training Feedback",
|
||||
"Training Result Employee",
|
||||
"Leave Application",
|
||||
"Employee Advance",
|
||||
"Training Event Employee",
|
||||
"Payroll Employee Detail",
|
||||
],
|
||||
"education": ["Instructor"],
|
||||
"projects": ["Activity Cost", "Timesheet"],
|
||||
"setup": ["Sales Person"],
|
||||
}
|
||||
|
||||
for module, doctypes in doctypes_to_update.items():
|
||||
for doctype in doctypes:
|
||||
if frappe.db.table_exists(doctype):
|
||||
frappe.reload_doc(module, 'doctype', frappe.scrub(doctype))
|
||||
frappe.db.sql("""
|
||||
frappe.reload_doc(module, "doctype", frappe.scrub(doctype))
|
||||
frappe.db.sql(
|
||||
"""
|
||||
update `tab%s` dt
|
||||
set department=(select department from `tabEmployee` where name=dt.employee)
|
||||
""" % doctype)
|
||||
"""
|
||||
% doctype
|
||||
)
|
||||
|
||||
@@ -8,15 +8,24 @@ def execute():
|
||||
if not company:
|
||||
return
|
||||
|
||||
doctypes = ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice",
|
||||
"Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"]
|
||||
doctypes = [
|
||||
"Quotation",
|
||||
"Sales Order",
|
||||
"Delivery Note",
|
||||
"Sales Invoice",
|
||||
"Supplier Quotation",
|
||||
"Purchase Order",
|
||||
"Purchase Receipt",
|
||||
"Purchase Invoice",
|
||||
]
|
||||
|
||||
for dt in doctypes:
|
||||
date_field = "posting_date"
|
||||
if dt in ["Quotation", "Sales Order", "Supplier Quotation", "Purchase Order"]:
|
||||
date_field = "transaction_date"
|
||||
|
||||
transactions = frappe.db.sql("""
|
||||
transactions = frappe.db.sql(
|
||||
"""
|
||||
select dt.name, dt_item.name as child_name
|
||||
from `tab{dt}` dt, `tab{dt} Item` dt_item
|
||||
where dt.name = dt_item.parent
|
||||
@@ -25,18 +34,28 @@ def execute():
|
||||
and ifnull(dt_item.gst_hsn_code, '') = ''
|
||||
and ifnull(dt_item.item_code, '') != ''
|
||||
and dt.company in ({company})
|
||||
""".format(dt=dt, date_field=date_field, company=", ".join(['%s']*len(company))), tuple(company), as_dict=1)
|
||||
""".format(
|
||||
dt=dt, date_field=date_field, company=", ".join(["%s"] * len(company))
|
||||
),
|
||||
tuple(company),
|
||||
as_dict=1,
|
||||
)
|
||||
|
||||
if not transactions:
|
||||
continue
|
||||
|
||||
transaction_rows_name = [d.child_name for d in transactions]
|
||||
|
||||
frappe.db.sql("""
|
||||
frappe.db.sql(
|
||||
"""
|
||||
update `tab{dt} Item` dt_item
|
||||
set dt_item.gst_hsn_code = (select gst_hsn_code from tabItem where name=dt_item.item_code)
|
||||
where dt_item.name in ({rows_name})
|
||||
""".format(dt=dt, rows_name=", ".join(['%s']*len(transaction_rows_name))), tuple(transaction_rows_name))
|
||||
""".format(
|
||||
dt=dt, rows_name=", ".join(["%s"] * len(transaction_rows_name))
|
||||
),
|
||||
tuple(transaction_rows_name),
|
||||
)
|
||||
|
||||
parent = set([d.name for d in transactions])
|
||||
for t in list(parent):
|
||||
|
||||
@@ -2,15 +2,21 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('Payroll', 'doctype', 'salary_detail')
|
||||
frappe.reload_doc('Payroll', 'doctype', 'salary_component')
|
||||
frappe.reload_doc("Payroll", "doctype", "salary_detail")
|
||||
frappe.reload_doc("Payroll", "doctype", "salary_component")
|
||||
|
||||
frappe.db.sql("update `tabSalary Component` set is_tax_applicable=1 where type='Earning'")
|
||||
|
||||
frappe.db.sql("""update `tabSalary Component` set variable_based_on_taxable_salary=1
|
||||
where type='Deduction' and name in ('TDS', 'Tax Deducted at Source')""")
|
||||
frappe.db.sql(
|
||||
"""update `tabSalary Component` set variable_based_on_taxable_salary=1
|
||||
where type='Deduction' and name in ('TDS', 'Tax Deducted at Source')"""
|
||||
)
|
||||
|
||||
frappe.db.sql("""update `tabSalary Detail` set is_tax_applicable=1
|
||||
where parentfield='earnings' and statistical_component=0""")
|
||||
frappe.db.sql("""update `tabSalary Detail` set variable_based_on_taxable_salary=1
|
||||
where parentfield='deductions' and salary_component in ('TDS', 'Tax Deducted at Source')""")
|
||||
frappe.db.sql(
|
||||
"""update `tabSalary Detail` set is_tax_applicable=1
|
||||
where parentfield='earnings' and statistical_component=0"""
|
||||
)
|
||||
frappe.db.sql(
|
||||
"""update `tabSalary Detail` set variable_based_on_taxable_salary=1
|
||||
where parentfield='deductions' and salary_component in ('TDS', 'Tax Deducted at Source')"""
|
||||
)
|
||||
|
||||
@@ -3,17 +3,19 @@ from frappe.model.workflow import get_workflow_name
|
||||
|
||||
|
||||
def execute():
|
||||
for doctype in ['Expense Claim', 'Leave Application']:
|
||||
for doctype in ["Expense Claim", "Leave Application"]:
|
||||
|
||||
active_workflow = get_workflow_name(doctype)
|
||||
if not active_workflow: continue
|
||||
if not active_workflow:
|
||||
continue
|
||||
|
||||
workflow_states = frappe.get_all('Workflow Document State',
|
||||
filters=[['parent', '=', active_workflow]],
|
||||
fields=['*'])
|
||||
workflow_states = frappe.get_all(
|
||||
"Workflow Document State", filters=[["parent", "=", active_workflow]], fields=["*"]
|
||||
)
|
||||
|
||||
for state in workflow_states:
|
||||
if state.update_field: continue
|
||||
status_field = 'approval_status' if doctype=="Expense Claim" else 'status'
|
||||
frappe.set_value('Workflow Document State', state.name, 'update_field', status_field)
|
||||
frappe.set_value('Workflow Document State', state.name, 'update_value', state.state)
|
||||
if state.update_field:
|
||||
continue
|
||||
status_field = "approval_status" if doctype == "Expense Claim" else "status"
|
||||
frappe.set_value("Workflow Document State", state.name, "update_field", status_field)
|
||||
frappe.set_value("Workflow Document State", state.name, "update_value", state.state)
|
||||
|
||||
@@ -2,18 +2,24 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
user_permissions = frappe.db.sql("""select name, for_value from `tabUser Permission`
|
||||
where allow='Department'""", as_dict=1)
|
||||
for d in user_permissions:
|
||||
user_permission = frappe.get_doc("User Permission", d.name)
|
||||
for new_dept in frappe.db.sql("""select name from tabDepartment
|
||||
where ifnull(company, '') != '' and department_name=%s""", d.for_value):
|
||||
try:
|
||||
new_user_permission = frappe.copy_doc(user_permission)
|
||||
new_user_permission.for_value = new_dept[0]
|
||||
new_user_permission.save()
|
||||
except frappe.DuplicateEntryError:
|
||||
pass
|
||||
user_permissions = frappe.db.sql(
|
||||
"""select name, for_value from `tabUser Permission`
|
||||
where allow='Department'""",
|
||||
as_dict=1,
|
||||
)
|
||||
for d in user_permissions:
|
||||
user_permission = frappe.get_doc("User Permission", d.name)
|
||||
for new_dept in frappe.db.sql(
|
||||
"""select name from tabDepartment
|
||||
where ifnull(company, '') != '' and department_name=%s""",
|
||||
d.for_value,
|
||||
):
|
||||
try:
|
||||
new_user_permission = frappe.copy_doc(user_permission)
|
||||
new_user_permission.for_value = new_dept[0]
|
||||
new_user_permission.save()
|
||||
except frappe.DuplicateEntryError:
|
||||
pass
|
||||
|
||||
frappe.reload_doc("hr", "doctype", "department")
|
||||
frappe.db.sql("update tabDepartment set disabled=1 where ifnull(company, '') = ''")
|
||||
frappe.reload_doc("hr", "doctype", "department")
|
||||
frappe.db.sql("update tabDepartment set disabled=1 where ifnull(company, '') = ''")
|
||||
|
||||
@@ -4,20 +4,37 @@ from frappe.desk.form.linked_with import get_linked_doctypes
|
||||
# Skips user permission check for doctypes where department link field was recently added
|
||||
# https://github.com/frappe/erpnext/pull/14121
|
||||
|
||||
|
||||
def execute():
|
||||
doctypes_to_skip = []
|
||||
for doctype in ['Appraisal', 'Leave Allocation', 'Expense Claim', 'Instructor', 'Salary Slip',
|
||||
'Attendance', 'Training Feedback', 'Training Result Employee',
|
||||
'Leave Application', 'Employee Advance', 'Activity Cost', 'Training Event Employee',
|
||||
'Timesheet', 'Sales Person', 'Payroll Employee Detail']:
|
||||
if frappe.db.exists('Custom Field', { 'dt': doctype, 'fieldname': 'department'}): continue
|
||||
for doctype in [
|
||||
"Appraisal",
|
||||
"Leave Allocation",
|
||||
"Expense Claim",
|
||||
"Instructor",
|
||||
"Salary Slip",
|
||||
"Attendance",
|
||||
"Training Feedback",
|
||||
"Training Result Employee",
|
||||
"Leave Application",
|
||||
"Employee Advance",
|
||||
"Activity Cost",
|
||||
"Training Event Employee",
|
||||
"Timesheet",
|
||||
"Sales Person",
|
||||
"Payroll Employee Detail",
|
||||
]:
|
||||
if frappe.db.exists("Custom Field", {"dt": doctype, "fieldname": "department"}):
|
||||
continue
|
||||
doctypes_to_skip.append(doctype)
|
||||
|
||||
frappe.reload_doctype('User Permission')
|
||||
frappe.reload_doctype("User Permission")
|
||||
|
||||
user_permissions = frappe.get_all("User Permission",
|
||||
filters=[['allow', '=', 'Department'], ['applicable_for', 'in', [None] + doctypes_to_skip]],
|
||||
fields=['name', 'applicable_for'])
|
||||
user_permissions = frappe.get_all(
|
||||
"User Permission",
|
||||
filters=[["allow", "=", "Department"], ["applicable_for", "in", [None] + doctypes_to_skip]],
|
||||
fields=["name", "applicable_for"],
|
||||
)
|
||||
|
||||
user_permissions_to_delete = []
|
||||
new_user_permissions_list = []
|
||||
@@ -37,24 +54,32 @@ def execute():
|
||||
for doctype in applicable_for_doctypes:
|
||||
if doctype:
|
||||
# Maintain sequence (name, user, allow, for_value, applicable_for, apply_to_all_doctypes)
|
||||
new_user_permissions_list.append((
|
||||
frappe.generate_hash("", 10),
|
||||
user_permission.user,
|
||||
user_permission.allow,
|
||||
user_permission.for_value,
|
||||
doctype,
|
||||
0
|
||||
))
|
||||
new_user_permissions_list.append(
|
||||
(
|
||||
frappe.generate_hash("", 10),
|
||||
user_permission.user,
|
||||
user_permission.allow,
|
||||
user_permission.for_value,
|
||||
doctype,
|
||||
0,
|
||||
)
|
||||
)
|
||||
|
||||
if new_user_permissions_list:
|
||||
frappe.db.sql('''
|
||||
frappe.db.sql(
|
||||
"""
|
||||
INSERT INTO `tabUser Permission`
|
||||
(`name`, `user`, `allow`, `for_value`, `applicable_for`, `apply_to_all_doctypes`)
|
||||
VALUES {}'''.format(', '.join(['%s'] * len(new_user_permissions_list))), # nosec
|
||||
tuple(new_user_permissions_list)
|
||||
VALUES {}""".format(
|
||||
", ".join(["%s"] * len(new_user_permissions_list))
|
||||
), # nosec
|
||||
tuple(new_user_permissions_list),
|
||||
)
|
||||
|
||||
if user_permissions_to_delete:
|
||||
frappe.db.sql('DELETE FROM `tabUser Permission` WHERE `name` IN ({})'.format( # nosec
|
||||
','.join(['%s'] * len(user_permissions_to_delete))
|
||||
), tuple(user_permissions_to_delete))
|
||||
frappe.db.sql(
|
||||
"DELETE FROM `tabUser Permission` WHERE `name` IN ({})".format( # nosec
|
||||
",".join(["%s"] * len(user_permissions_to_delete))
|
||||
),
|
||||
tuple(user_permissions_to_delete),
|
||||
)
|
||||
|
||||
@@ -14,8 +14,8 @@ def execute():
|
||||
# delete conversion data and insert again
|
||||
frappe.db.sql("delete from `tabUOM Conversion Factor`")
|
||||
try:
|
||||
frappe.delete_doc('UOM', 'Hundredweight')
|
||||
frappe.delete_doc('UOM', 'Pound Cubic Yard')
|
||||
frappe.delete_doc("UOM", "Hundredweight")
|
||||
frappe.delete_doc("UOM", "Pound Cubic Yard")
|
||||
except frappe.LinkExistsError:
|
||||
pass
|
||||
|
||||
|
||||
@@ -6,9 +6,15 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('setup', 'doctype', 'party_type')
|
||||
party_types = {'Customer': 'Receivable', 'Supplier': 'Payable',
|
||||
'Employee': 'Payable', 'Member': 'Receivable', 'Shareholder': 'Payable', 'Student': 'Receivable'}
|
||||
frappe.reload_doc("setup", "doctype", "party_type")
|
||||
party_types = {
|
||||
"Customer": "Receivable",
|
||||
"Supplier": "Payable",
|
||||
"Employee": "Payable",
|
||||
"Member": "Receivable",
|
||||
"Shareholder": "Payable",
|
||||
"Student": "Receivable",
|
||||
}
|
||||
|
||||
for party_type, account_type in party_types.items():
|
||||
frappe.db.set_value('Party Type', party_type, 'account_type', account_type)
|
||||
frappe.db.set_value("Party Type", party_type, "account_type", account_type)
|
||||
|
||||
@@ -6,16 +6,22 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('stock', 'doctype', 'item')
|
||||
frappe.db.sql(""" update `tabItem` set include_item_in_manufacturing = 1
|
||||
where ifnull(is_stock_item, 0) = 1""")
|
||||
frappe.reload_doc("stock", "doctype", "item")
|
||||
frappe.db.sql(
|
||||
""" update `tabItem` set include_item_in_manufacturing = 1
|
||||
where ifnull(is_stock_item, 0) = 1"""
|
||||
)
|
||||
|
||||
for doctype in ['BOM Item', 'Work Order Item', 'BOM Explosion Item']:
|
||||
frappe.reload_doc('manufacturing', 'doctype', frappe.scrub(doctype))
|
||||
for doctype in ["BOM Item", "Work Order Item", "BOM Explosion Item"]:
|
||||
frappe.reload_doc("manufacturing", "doctype", frappe.scrub(doctype))
|
||||
|
||||
frappe.db.sql(""" update `tab{0}` child, tabItem item
|
||||
frappe.db.sql(
|
||||
""" update `tab{0}` child, tabItem item
|
||||
set
|
||||
child.include_item_in_manufacturing = 1
|
||||
where
|
||||
child.item_code = item.name and ifnull(item.is_stock_item, 0) = 1
|
||||
""".format(doctype))
|
||||
""".format(
|
||||
doctype
|
||||
)
|
||||
)
|
||||
|
||||
@@ -6,15 +6,19 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('buying', 'doctype', 'buying_settings')
|
||||
frappe.db.set_value('Buying Settings', None, 'backflush_raw_materials_of_subcontract_based_on', 'BOM')
|
||||
frappe.reload_doc("buying", "doctype", "buying_settings")
|
||||
frappe.db.set_value(
|
||||
"Buying Settings", None, "backflush_raw_materials_of_subcontract_based_on", "BOM"
|
||||
)
|
||||
|
||||
frappe.reload_doc('stock', 'doctype', 'stock_entry_detail')
|
||||
frappe.db.sql(""" update `tabStock Entry Detail` as sed,
|
||||
frappe.reload_doc("stock", "doctype", "stock_entry_detail")
|
||||
frappe.db.sql(
|
||||
""" update `tabStock Entry Detail` as sed,
|
||||
`tabStock Entry` as se, `tabPurchase Order Item Supplied` as pois
|
||||
set
|
||||
sed.subcontracted_item = pois.main_item_code
|
||||
where
|
||||
se.purpose = 'Send to Subcontractor' and sed.parent = se.name
|
||||
and pois.rm_item_code = sed.item_code and se.docstatus = 1
|
||||
and pois.parenttype = 'Purchase Order'""")
|
||||
and pois.parenttype = 'Purchase Order'"""
|
||||
)
|
||||
|
||||
@@ -6,11 +6,13 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('stock', 'doctype', 'item_price')
|
||||
frappe.reload_doc("stock", "doctype", "item_price")
|
||||
|
||||
frappe.db.sql(""" update `tabItem Price`, `tabItem`
|
||||
frappe.db.sql(
|
||||
""" update `tabItem Price`, `tabItem`
|
||||
set
|
||||
`tabItem Price`.brand = `tabItem`.brand
|
||||
where
|
||||
`tabItem Price`.item_code = `tabItem`.name
|
||||
and `tabItem`.brand is not null and `tabItem`.brand != ''""")
|
||||
and `tabItem`.brand is not null and `tabItem`.brand != ''"""
|
||||
)
|
||||
|
||||
@@ -6,18 +6,14 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('setup', 'doctype', 'global_defaults', force=True)
|
||||
frappe.reload_doc('stock', 'doctype', 'delivery_trip')
|
||||
frappe.reload_doc('stock', 'doctype', 'delivery_stop', force=True)
|
||||
frappe.reload_doc("setup", "doctype", "global_defaults", force=True)
|
||||
frappe.reload_doc("stock", "doctype", "delivery_trip")
|
||||
frappe.reload_doc("stock", "doctype", "delivery_stop", force=True)
|
||||
|
||||
for trip in frappe.get_all("Delivery Trip"):
|
||||
trip_doc = frappe.get_doc("Delivery Trip", trip.name)
|
||||
|
||||
status = {
|
||||
0: "Draft",
|
||||
1: "Scheduled",
|
||||
2: "Cancelled"
|
||||
}[trip_doc.docstatus]
|
||||
status = {0: "Draft", 1: "Scheduled", 2: "Cancelled"}[trip_doc.docstatus]
|
||||
|
||||
if trip_doc.docstatus == 1:
|
||||
visited_stops = [stop.visited for stop in trip_doc.delivery_stops]
|
||||
|
||||
@@ -4,16 +4,18 @@ from frappe.utils.nestedset import rebuild_tree
|
||||
|
||||
|
||||
def execute():
|
||||
""" assign lft and rgt appropriately """
|
||||
"""assign lft and rgt appropriately"""
|
||||
frappe.reload_doc("hr", "doctype", "department")
|
||||
if not frappe.db.exists("Department", _('All Departments')):
|
||||
frappe.get_doc({
|
||||
'doctype': 'Department',
|
||||
'department_name': _('All Departments'),
|
||||
'is_group': 1
|
||||
}).insert(ignore_permissions=True, ignore_mandatory=True)
|
||||
if not frappe.db.exists("Department", _("All Departments")):
|
||||
frappe.get_doc(
|
||||
{"doctype": "Department", "department_name": _("All Departments"), "is_group": 1}
|
||||
).insert(ignore_permissions=True, ignore_mandatory=True)
|
||||
|
||||
frappe.db.sql("""update `tabDepartment` set parent_department = '{0}'
|
||||
where is_group = 0""".format(_('All Departments')))
|
||||
frappe.db.sql(
|
||||
"""update `tabDepartment` set parent_department = '{0}'
|
||||
where is_group = 0""".format(
|
||||
_("All Departments")
|
||||
)
|
||||
)
|
||||
|
||||
rebuild_tree("Department", "parent_department")
|
||||
|
||||
@@ -5,25 +5,28 @@ from frappe import _
|
||||
def execute():
|
||||
from erpnext.setup.setup_wizard.operations.install_fixtures import default_sales_partner_type
|
||||
|
||||
frappe.reload_doc('selling', 'doctype', 'sales_partner_type')
|
||||
frappe.reload_doc("selling", "doctype", "sales_partner_type")
|
||||
|
||||
frappe.local.lang = frappe.db.get_default("lang") or 'en'
|
||||
frappe.local.lang = frappe.db.get_default("lang") or "en"
|
||||
|
||||
for s in default_sales_partner_type:
|
||||
insert_sales_partner_type(_(s))
|
||||
|
||||
# get partner type in existing forms (customized)
|
||||
# and create a document if not created
|
||||
for d in ['Sales Partner']:
|
||||
partner_type = frappe.db.sql_list('select distinct partner_type from `tab{0}`'.format(d))
|
||||
for d in ["Sales Partner"]:
|
||||
partner_type = frappe.db.sql_list("select distinct partner_type from `tab{0}`".format(d))
|
||||
for s in partner_type:
|
||||
if s and s not in default_sales_partner_type:
|
||||
insert_sales_partner_type(s)
|
||||
|
||||
# remove customization for partner type
|
||||
for p in frappe.get_all('Property Setter', {'doc_type':d, 'field_name':'partner_type', 'property':'options'}):
|
||||
frappe.delete_doc('Property Setter', p.name)
|
||||
for p in frappe.get_all(
|
||||
"Property Setter", {"doc_type": d, "field_name": "partner_type", "property": "options"}
|
||||
):
|
||||
frappe.delete_doc("Property Setter", p.name)
|
||||
|
||||
|
||||
def insert_sales_partner_type(s):
|
||||
if not frappe.db.exists('Sales Partner Type', s):
|
||||
frappe.get_doc(dict(doctype='Sales Partner Type', sales_partner_type=s)).insert()
|
||||
if not frappe.db.exists("Sales Partner Type", s):
|
||||
frappe.get_doc(dict(doctype="Sales Partner Type", sales_partner_type=s)).insert()
|
||||
|
||||
@@ -2,33 +2,46 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('buying', 'doctype', 'purchase_order')
|
||||
frappe.reload_doc('buying', 'doctype', 'supplier_quotation')
|
||||
frappe.reload_doc('selling', 'doctype', 'sales_order')
|
||||
frappe.reload_doc('selling', 'doctype', 'quotation')
|
||||
frappe.reload_doc('stock', 'doctype', 'delivery_note')
|
||||
frappe.reload_doc('stock', 'doctype', 'purchase_receipt')
|
||||
frappe.reload_doc('accounts', 'doctype', 'sales_invoice')
|
||||
frappe.reload_doc('accounts', 'doctype', 'purchase_invoice')
|
||||
frappe.reload_doc("buying", "doctype", "purchase_order")
|
||||
frappe.reload_doc("buying", "doctype", "supplier_quotation")
|
||||
frappe.reload_doc("selling", "doctype", "sales_order")
|
||||
frappe.reload_doc("selling", "doctype", "quotation")
|
||||
frappe.reload_doc("stock", "doctype", "delivery_note")
|
||||
frappe.reload_doc("stock", "doctype", "purchase_receipt")
|
||||
frappe.reload_doc("accounts", "doctype", "sales_invoice")
|
||||
frappe.reload_doc("accounts", "doctype", "purchase_invoice")
|
||||
|
||||
doctypes = ["Sales Order", "Sales Invoice", "Delivery Note",\
|
||||
"Purchase Order", "Purchase Invoice", "Purchase Receipt", "Quotation", "Supplier Quotation"]
|
||||
doctypes = [
|
||||
"Sales Order",
|
||||
"Sales Invoice",
|
||||
"Delivery Note",
|
||||
"Purchase Order",
|
||||
"Purchase Invoice",
|
||||
"Purchase Receipt",
|
||||
"Quotation",
|
||||
"Supplier Quotation",
|
||||
]
|
||||
|
||||
for doctype in doctypes:
|
||||
total_qty = frappe.db.sql('''
|
||||
total_qty = frappe.db.sql(
|
||||
"""
|
||||
SELECT
|
||||
parent, SUM(qty) as qty
|
||||
FROM
|
||||
`tab{0} Item`
|
||||
where parenttype = '{0}'
|
||||
GROUP BY parent
|
||||
'''.format(doctype), as_dict = True)
|
||||
""".format(
|
||||
doctype
|
||||
),
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
# Query to update total_qty might become too big, Update in batches
|
||||
# batch_size is chosen arbitrarily, Don't try too hard to reason about it
|
||||
batch_size = 100000
|
||||
for i in range(0, len(total_qty), batch_size):
|
||||
batch_transactions = total_qty[i:i + batch_size]
|
||||
batch_transactions = total_qty[i : i + batch_size]
|
||||
|
||||
# UPDATE with CASE for some reason cannot use PRIMARY INDEX,
|
||||
# causing all rows to be examined, leading to a very slow update
|
||||
@@ -42,7 +55,11 @@ def execute():
|
||||
for d in batch_transactions:
|
||||
values.append("({0}, {1})".format(frappe.db.escape(d.parent), d.qty))
|
||||
conditions = ",".join(values)
|
||||
frappe.db.sql("""
|
||||
frappe.db.sql(
|
||||
"""
|
||||
INSERT INTO `tab{}` (name, total_qty) VALUES {}
|
||||
ON DUPLICATE KEY UPDATE name = VALUES(name), total_qty = VALUES(total_qty)
|
||||
""".format(doctype, conditions))
|
||||
""".format(
|
||||
doctype, conditions
|
||||
)
|
||||
)
|
||||
|
||||
@@ -6,4 +6,4 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.delete_doc_if_exists('Page', 'bom-browser')
|
||||
frappe.delete_doc_if_exists("Page", "bom-browser")
|
||||
|
||||
@@ -6,25 +6,45 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('manufacturing', 'doctype', 'job_card_time_log')
|
||||
frappe.reload_doc("manufacturing", "doctype", "job_card_time_log")
|
||||
|
||||
if (frappe.db.table_exists("Job Card")
|
||||
and frappe.get_meta("Job Card").has_field("actual_start_date")):
|
||||
time_logs = []
|
||||
for d in frappe.get_all('Job Card',
|
||||
fields = ["actual_start_date", "actual_end_date", "time_in_mins", "name", "for_quantity"],
|
||||
filters = {'docstatus': ("<", 2)}):
|
||||
if d.actual_start_date:
|
||||
time_logs.append([d.actual_start_date, d.actual_end_date, d.time_in_mins,
|
||||
d.for_quantity, d.name, 'Job Card', 'time_logs', frappe.generate_hash("", 10)])
|
||||
if frappe.db.table_exists("Job Card") and frappe.get_meta("Job Card").has_field(
|
||||
"actual_start_date"
|
||||
):
|
||||
time_logs = []
|
||||
for d in frappe.get_all(
|
||||
"Job Card",
|
||||
fields=["actual_start_date", "actual_end_date", "time_in_mins", "name", "for_quantity"],
|
||||
filters={"docstatus": ("<", 2)},
|
||||
):
|
||||
if d.actual_start_date:
|
||||
time_logs.append(
|
||||
[
|
||||
d.actual_start_date,
|
||||
d.actual_end_date,
|
||||
d.time_in_mins,
|
||||
d.for_quantity,
|
||||
d.name,
|
||||
"Job Card",
|
||||
"time_logs",
|
||||
frappe.generate_hash("", 10),
|
||||
]
|
||||
)
|
||||
|
||||
if time_logs:
|
||||
frappe.db.sql(""" INSERT INTO
|
||||
if time_logs:
|
||||
frappe.db.sql(
|
||||
""" INSERT INTO
|
||||
`tabJob Card Time Log`
|
||||
(from_time, to_time, time_in_mins, completed_qty, parent, parenttype, parentfield, name)
|
||||
values {values}
|
||||
""".format(values = ','.join(['%s'] * len(time_logs))), tuple(time_logs))
|
||||
""".format(
|
||||
values=",".join(["%s"] * len(time_logs))
|
||||
),
|
||||
tuple(time_logs),
|
||||
)
|
||||
|
||||
frappe.reload_doc('manufacturing', 'doctype', 'job_card')
|
||||
frappe.db.sql(""" update `tabJob Card` set total_completed_qty = for_quantity,
|
||||
total_time_in_mins = time_in_mins where docstatus < 2 """)
|
||||
frappe.reload_doc("manufacturing", "doctype", "job_card")
|
||||
frappe.db.sql(
|
||||
""" update `tabJob Card` set total_completed_qty = for_quantity,
|
||||
total_time_in_mins = time_in_mins where docstatus < 2 """
|
||||
)
|
||||
|
||||
@@ -8,8 +8,14 @@ import frappe
|
||||
def execute():
|
||||
frappe.reload_doctype("Quotation")
|
||||
frappe.db.sql(""" UPDATE `tabQuotation` set party_name = lead WHERE quotation_to = 'Lead' """)
|
||||
frappe.db.sql(""" UPDATE `tabQuotation` set party_name = customer WHERE quotation_to = 'Customer' """)
|
||||
frappe.db.sql(
|
||||
""" UPDATE `tabQuotation` set party_name = customer WHERE quotation_to = 'Customer' """
|
||||
)
|
||||
|
||||
frappe.reload_doctype("Opportunity")
|
||||
frappe.db.sql(""" UPDATE `tabOpportunity` set party_name = lead WHERE opportunity_from = 'Lead' """)
|
||||
frappe.db.sql(""" UPDATE `tabOpportunity` set party_name = customer WHERE opportunity_from = 'Customer' """)
|
||||
frappe.db.sql(
|
||||
""" UPDATE `tabOpportunity` set party_name = lead WHERE opportunity_from = 'Lead' """
|
||||
)
|
||||
frappe.db.sql(
|
||||
""" UPDATE `tabOpportunity` set party_name = customer WHERE opportunity_from = 'Customer' """
|
||||
)
|
||||
|
||||
@@ -6,6 +6,6 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
for report in ["Delayed Order Item Summary", "Delayed Order Summary"]:
|
||||
if frappe.db.exists("Report", report):
|
||||
frappe.delete_doc("Report", report)
|
||||
for report in ["Delayed Order Item Summary", "Delayed Order Summary"]:
|
||||
if frappe.db.exists("Report", report):
|
||||
frappe.delete_doc("Report", report)
|
||||
|
||||
@@ -6,11 +6,13 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
stock_settings = frappe.get_doc('Stock Settings')
|
||||
if stock_settings.default_warehouse and not frappe.db.exists("Warehouse", stock_settings.default_warehouse):
|
||||
stock_settings.default_warehouse = None
|
||||
if stock_settings.stock_uom and not frappe.db.exists("UOM", stock_settings.stock_uom):
|
||||
stock_settings.stock_uom = None
|
||||
stock_settings.flags.ignore_mandatory = True
|
||||
stock_settings.action_if_quality_inspection_is_not_submitted = "Stop"
|
||||
stock_settings.save()
|
||||
stock_settings = frappe.get_doc("Stock Settings")
|
||||
if stock_settings.default_warehouse and not frappe.db.exists(
|
||||
"Warehouse", stock_settings.default_warehouse
|
||||
):
|
||||
stock_settings.default_warehouse = None
|
||||
if stock_settings.stock_uom and not frappe.db.exists("UOM", stock_settings.stock_uom):
|
||||
stock_settings.stock_uom = None
|
||||
stock_settings.flags.ignore_mandatory = True
|
||||
stock_settings.action_if_quality_inspection_is_not_submitted = "Stop"
|
||||
stock_settings.save()
|
||||
|
||||
@@ -5,13 +5,23 @@ def execute():
|
||||
|
||||
frappe.reload_doctype("Opportunity")
|
||||
if frappe.db.has_column("Opportunity", "enquiry_from"):
|
||||
frappe.db.sql(""" UPDATE `tabOpportunity` set opportunity_from = enquiry_from
|
||||
where ifnull(opportunity_from, '') = '' and ifnull(enquiry_from, '') != ''""")
|
||||
frappe.db.sql(
|
||||
""" UPDATE `tabOpportunity` set opportunity_from = enquiry_from
|
||||
where ifnull(opportunity_from, '') = '' and ifnull(enquiry_from, '') != ''"""
|
||||
)
|
||||
|
||||
if frappe.db.has_column("Opportunity", "lead") and frappe.db.has_column("Opportunity", "enquiry_from"):
|
||||
frappe.db.sql(""" UPDATE `tabOpportunity` set party_name = lead
|
||||
where enquiry_from = 'Lead' and ifnull(party_name, '') = '' and ifnull(lead, '') != ''""")
|
||||
if frappe.db.has_column("Opportunity", "lead") and frappe.db.has_column(
|
||||
"Opportunity", "enquiry_from"
|
||||
):
|
||||
frappe.db.sql(
|
||||
""" UPDATE `tabOpportunity` set party_name = lead
|
||||
where enquiry_from = 'Lead' and ifnull(party_name, '') = '' and ifnull(lead, '') != ''"""
|
||||
)
|
||||
|
||||
if frappe.db.has_column("Opportunity", "customer") and frappe.db.has_column("Opportunity", "enquiry_from"):
|
||||
frappe.db.sql(""" UPDATE `tabOpportunity` set party_name = customer
|
||||
where enquiry_from = 'Customer' and ifnull(party_name, '') = '' and ifnull(customer, '') != ''""")
|
||||
if frappe.db.has_column("Opportunity", "customer") and frappe.db.has_column(
|
||||
"Opportunity", "enquiry_from"
|
||||
):
|
||||
frappe.db.sql(
|
||||
""" UPDATE `tabOpportunity` set party_name = customer
|
||||
where enquiry_from = 'Customer' and ifnull(party_name, '') = '' and ifnull(customer, '') != ''"""
|
||||
)
|
||||
|
||||
@@ -4,7 +4,8 @@ import frappe
|
||||
def execute():
|
||||
frappe.reload_doctype("Quotation")
|
||||
# update customer_name from Customer document if quotation_to is set to Customer
|
||||
frappe.db.sql('''
|
||||
frappe.db.sql(
|
||||
"""
|
||||
update tabQuotation, tabCustomer
|
||||
set
|
||||
tabQuotation.customer_name = tabCustomer.customer_name,
|
||||
@@ -13,11 +14,13 @@ def execute():
|
||||
tabQuotation.customer_name is null
|
||||
and tabQuotation.party_name = tabCustomer.name
|
||||
and tabQuotation.quotation_to = 'Customer'
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
# update customer_name from Lead document if quotation_to is set to Lead
|
||||
|
||||
frappe.db.sql('''
|
||||
frappe.db.sql(
|
||||
"""
|
||||
update tabQuotation, tabLead
|
||||
set
|
||||
tabQuotation.customer_name = case when ifnull(tabLead.company_name, '') != '' then tabLead.company_name else tabLead.lead_name end,
|
||||
@@ -26,4 +29,5 @@ def execute():
|
||||
tabQuotation.customer_name is null
|
||||
and tabQuotation.party_name = tabLead.name
|
||||
and tabQuotation.quotation_to = 'Lead'
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -2,8 +2,10 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.db.sql("""
|
||||
frappe.db.sql(
|
||||
"""
|
||||
update `tabSalary Structure` ss, `tabSalary Detail` sd
|
||||
set sd.docstatus=1
|
||||
where ss.name=sd.parent and ss.docstatus=1 and sd.parenttype='Salary Structure'
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -2,8 +2,10 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.db.sql("""
|
||||
frappe.db.sql(
|
||||
"""
|
||||
update `tabMaterial Request`
|
||||
set status='Manufactured'
|
||||
where docstatus=1 and material_request_type='Manufacture' and per_ordered=100 and status != 'Stopped'
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -6,7 +6,9 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.db.sql("""update tabItem set variant_based_on = 'Item Attribute'
|
||||
frappe.db.sql(
|
||||
"""update tabItem set variant_based_on = 'Item Attribute'
|
||||
where ifnull(variant_based_on, '') = ''
|
||||
and (has_variants=1 or ifnull(variant_of, '') != '')
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -2,11 +2,8 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
if 'Education' in frappe.get_active_domains() and not frappe.db.exists("Role", "Guardian"):
|
||||
if "Education" in frappe.get_active_domains() and not frappe.db.exists("Role", "Guardian"):
|
||||
doc = frappe.new_doc("Role")
|
||||
doc.update({
|
||||
"role_name": "Guardian",
|
||||
"desk_access": 0
|
||||
})
|
||||
doc.update({"role_name": "Guardian", "desk_access": 0})
|
||||
|
||||
doc.insert(ignore_permissions=True)
|
||||
|
||||
@@ -6,22 +6,26 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc("accounts", "doctype", "bank_transaction")
|
||||
frappe.reload_doc("accounts", "doctype", "bank_transaction")
|
||||
|
||||
bank_transaction_fields = frappe.get_meta("Bank Transaction").get_valid_columns()
|
||||
bank_transaction_fields = frappe.get_meta("Bank Transaction").get_valid_columns()
|
||||
|
||||
if 'debit' in bank_transaction_fields:
|
||||
frappe.db.sql(""" UPDATE `tabBank Transaction`
|
||||
if "debit" in bank_transaction_fields:
|
||||
frappe.db.sql(
|
||||
""" UPDATE `tabBank Transaction`
|
||||
SET status = 'Reconciled'
|
||||
WHERE
|
||||
status = 'Settled' and (debit = allocated_amount or credit = allocated_amount)
|
||||
and ifnull(allocated_amount, 0) > 0
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
elif 'deposit' in bank_transaction_fields:
|
||||
frappe.db.sql(""" UPDATE `tabBank Transaction`
|
||||
elif "deposit" in bank_transaction_fields:
|
||||
frappe.db.sql(
|
||||
""" UPDATE `tabBank Transaction`
|
||||
SET status = 'Reconciled'
|
||||
WHERE
|
||||
status = 'Settled' and (deposit = allocated_amount or withdrawal = allocated_amount)
|
||||
and ifnull(allocated_amount, 0) > 0
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -6,21 +6,23 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
'''
|
||||
default supplier was not set in the item defaults for multi company instance,
|
||||
this patch will set the default supplier
|
||||
"""
|
||||
default supplier was not set in the item defaults for multi company instance,
|
||||
this patch will set the default supplier
|
||||
|
||||
'''
|
||||
if not frappe.db.has_column('Item', 'default_supplier'):
|
||||
"""
|
||||
if not frappe.db.has_column("Item", "default_supplier"):
|
||||
return
|
||||
|
||||
frappe.reload_doc('stock', 'doctype', 'item_default')
|
||||
frappe.reload_doc('stock', 'doctype', 'item')
|
||||
frappe.reload_doc("stock", "doctype", "item_default")
|
||||
frappe.reload_doc("stock", "doctype", "item")
|
||||
|
||||
companies = frappe.get_all("Company")
|
||||
if len(companies) > 1:
|
||||
frappe.db.sql(""" UPDATE `tabItem Default`, `tabItem`
|
||||
frappe.db.sql(
|
||||
""" UPDATE `tabItem Default`, `tabItem`
|
||||
SET `tabItem Default`.default_supplier = `tabItem`.default_supplier
|
||||
WHERE
|
||||
`tabItem Default`.parent = `tabItem`.name and `tabItem Default`.default_supplier is null
|
||||
and `tabItem`.default_supplier is not null and `tabItem`.default_supplier != '' """)
|
||||
and `tabItem`.default_supplier is not null and `tabItem`.default_supplier != '' """
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ from frappe.utils import cint
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc("erpnext_integrations", "doctype","woocommerce_settings")
|
||||
frappe.reload_doc("erpnext_integrations", "doctype", "woocommerce_settings")
|
||||
doc = frappe.get_doc("Woocommerce Settings")
|
||||
|
||||
if cint(doc.enable_sync):
|
||||
|
||||
@@ -4,15 +4,18 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
if not company or not frappe.db.count('E Invoice User'):
|
||||
company = frappe.get_all("Company", filters={"country": "India"})
|
||||
if not company or not frappe.db.count("E Invoice User"):
|
||||
return
|
||||
|
||||
frappe.reload_doc("regional", "doctype", "e_invoice_user")
|
||||
for creds in frappe.db.get_all('E Invoice User', fields=['name', 'gstin']):
|
||||
company_name = frappe.db.sql("""
|
||||
for creds in frappe.db.get_all("E Invoice User", fields=["name", "gstin"]):
|
||||
company_name = frappe.db.sql(
|
||||
"""
|
||||
select dl.link_name from `tabAddress` a, `tabDynamic Link` dl
|
||||
where a.gstin = %s and dl.parent = a.name and dl.link_doctype = 'Company'
|
||||
""", (creds.get('gstin')))
|
||||
""",
|
||||
(creds.get("gstin")),
|
||||
)
|
||||
if company_name and len(company_name) > 0:
|
||||
frappe.db.set_value('E Invoice User', creds.get('name'), 'company', company_name[0][0])
|
||||
frappe.db.set_value("E Invoice User", creds.get("name"), "company", company_name[0][0])
|
||||
|
||||
@@ -8,12 +8,16 @@ from frappe.model.utils.rename_field import rename_field
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc("setup", "doctype", "company")
|
||||
if frappe.db.has_column('Company', 'default_terms'):
|
||||
rename_field('Company', "default_terms", "default_selling_terms")
|
||||
if frappe.db.has_column("Company", "default_terms"):
|
||||
rename_field("Company", "default_terms", "default_selling_terms")
|
||||
|
||||
for company in frappe.get_all("Company", ["name", "default_selling_terms", "default_buying_terms"]):
|
||||
for company in frappe.get_all(
|
||||
"Company", ["name", "default_selling_terms", "default_buying_terms"]
|
||||
):
|
||||
if company.default_selling_terms and not company.default_buying_terms:
|
||||
frappe.db.set_value("Company", company.name, "default_buying_terms", company.default_selling_terms)
|
||||
frappe.db.set_value(
|
||||
"Company", company.name, "default_buying_terms", company.default_selling_terms
|
||||
)
|
||||
|
||||
frappe.reload_doc("setup", "doctype", "terms_and_conditions")
|
||||
frappe.db.sql("update `tabTerms and Conditions` set selling=1, buying=1, hr=1")
|
||||
|
||||
@@ -3,15 +3,19 @@ from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'Italy'})
|
||||
company = frappe.get_all("Company", filters={"country": "Italy"})
|
||||
if not company:
|
||||
return
|
||||
|
||||
custom_fields = {
|
||||
'Sales Invoice': [
|
||||
dict(fieldname='type_of_document', label='Type of Document',
|
||||
fieldtype='Select', insert_after='customer_fiscal_code',
|
||||
options='\nTD01\nTD02\nTD03\nTD04\nTD05\nTD06\nTD16\nTD17\nTD18\nTD19\nTD20\nTD21\nTD22\nTD23\nTD24\nTD25\nTD26\nTD27'),
|
||||
"Sales Invoice": [
|
||||
dict(
|
||||
fieldname="type_of_document",
|
||||
label="Type of Document",
|
||||
fieldtype="Select",
|
||||
insert_after="customer_fiscal_code",
|
||||
options="\nTD01\nTD02\nTD03\nTD04\nTD05\nTD06\nTD16\nTD17\nTD18\nTD19\nTD20\nTD21\nTD22\nTD23\nTD24\nTD25\nTD26\nTD27",
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -7,66 +7,154 @@ from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
company = frappe.get_all("Company", filters={"country": "India"})
|
||||
if not company:
|
||||
return
|
||||
|
||||
# move hidden einvoice fields to a different section
|
||||
custom_fields = {
|
||||
'Sales Invoice': [
|
||||
dict(fieldname='einvoice_section', label='E-Invoice Fields', fieldtype='Section Break', insert_after='gst_vehicle_type',
|
||||
print_hide=1, hidden=1),
|
||||
|
||||
dict(fieldname='ack_no', label='Ack. No.', fieldtype='Data', read_only=1, hidden=1, insert_after='einvoice_section',
|
||||
no_copy=1, print_hide=1),
|
||||
|
||||
dict(fieldname='ack_date', label='Ack. Date', fieldtype='Data', read_only=1, hidden=1, insert_after='ack_no', no_copy=1, print_hide=1),
|
||||
|
||||
dict(fieldname='irn_cancel_date', label='Cancel Date', fieldtype='Data', read_only=1, hidden=1, insert_after='ack_date',
|
||||
no_copy=1, print_hide=1),
|
||||
|
||||
dict(fieldname='signed_einvoice', label='Signed E-Invoice', fieldtype='Code', options='JSON', hidden=1, insert_after='irn_cancel_date',
|
||||
no_copy=1, print_hide=1, read_only=1),
|
||||
|
||||
dict(fieldname='signed_qr_code', label='Signed QRCode', fieldtype='Code', options='JSON', hidden=1, insert_after='signed_einvoice',
|
||||
no_copy=1, print_hide=1, read_only=1),
|
||||
|
||||
dict(fieldname='qrcode_image', label='QRCode', fieldtype='Attach Image', hidden=1, insert_after='signed_qr_code',
|
||||
no_copy=1, print_hide=1, read_only=1),
|
||||
|
||||
dict(fieldname='einvoice_status', label='E-Invoice Status', fieldtype='Select', insert_after='qrcode_image',
|
||||
options='\nPending\nGenerated\nCancelled\nFailed', default=None, hidden=1, no_copy=1, print_hide=1, read_only=1),
|
||||
|
||||
dict(fieldname='failure_description', label='E-Invoice Failure Description', fieldtype='Code', options='JSON',
|
||||
hidden=1, insert_after='einvoice_status', no_copy=1, print_hide=1, read_only=1)
|
||||
"Sales Invoice": [
|
||||
dict(
|
||||
fieldname="einvoice_section",
|
||||
label="E-Invoice Fields",
|
||||
fieldtype="Section Break",
|
||||
insert_after="gst_vehicle_type",
|
||||
print_hide=1,
|
||||
hidden=1,
|
||||
),
|
||||
dict(
|
||||
fieldname="ack_no",
|
||||
label="Ack. No.",
|
||||
fieldtype="Data",
|
||||
read_only=1,
|
||||
hidden=1,
|
||||
insert_after="einvoice_section",
|
||||
no_copy=1,
|
||||
print_hide=1,
|
||||
),
|
||||
dict(
|
||||
fieldname="ack_date",
|
||||
label="Ack. Date",
|
||||
fieldtype="Data",
|
||||
read_only=1,
|
||||
hidden=1,
|
||||
insert_after="ack_no",
|
||||
no_copy=1,
|
||||
print_hide=1,
|
||||
),
|
||||
dict(
|
||||
fieldname="irn_cancel_date",
|
||||
label="Cancel Date",
|
||||
fieldtype="Data",
|
||||
read_only=1,
|
||||
hidden=1,
|
||||
insert_after="ack_date",
|
||||
no_copy=1,
|
||||
print_hide=1,
|
||||
),
|
||||
dict(
|
||||
fieldname="signed_einvoice",
|
||||
label="Signed E-Invoice",
|
||||
fieldtype="Code",
|
||||
options="JSON",
|
||||
hidden=1,
|
||||
insert_after="irn_cancel_date",
|
||||
no_copy=1,
|
||||
print_hide=1,
|
||||
read_only=1,
|
||||
),
|
||||
dict(
|
||||
fieldname="signed_qr_code",
|
||||
label="Signed QRCode",
|
||||
fieldtype="Code",
|
||||
options="JSON",
|
||||
hidden=1,
|
||||
insert_after="signed_einvoice",
|
||||
no_copy=1,
|
||||
print_hide=1,
|
||||
read_only=1,
|
||||
),
|
||||
dict(
|
||||
fieldname="qrcode_image",
|
||||
label="QRCode",
|
||||
fieldtype="Attach Image",
|
||||
hidden=1,
|
||||
insert_after="signed_qr_code",
|
||||
no_copy=1,
|
||||
print_hide=1,
|
||||
read_only=1,
|
||||
),
|
||||
dict(
|
||||
fieldname="einvoice_status",
|
||||
label="E-Invoice Status",
|
||||
fieldtype="Select",
|
||||
insert_after="qrcode_image",
|
||||
options="\nPending\nGenerated\nCancelled\nFailed",
|
||||
default=None,
|
||||
hidden=1,
|
||||
no_copy=1,
|
||||
print_hide=1,
|
||||
read_only=1,
|
||||
),
|
||||
dict(
|
||||
fieldname="failure_description",
|
||||
label="E-Invoice Failure Description",
|
||||
fieldtype="Code",
|
||||
options="JSON",
|
||||
hidden=1,
|
||||
insert_after="einvoice_status",
|
||||
no_copy=1,
|
||||
print_hide=1,
|
||||
read_only=1,
|
||||
),
|
||||
]
|
||||
}
|
||||
create_custom_fields(custom_fields, update=True)
|
||||
|
||||
if frappe.db.exists('E Invoice Settings') and frappe.db.get_single_value('E Invoice Settings', 'enable'):
|
||||
frappe.db.sql('''
|
||||
if frappe.db.exists("E Invoice Settings") and frappe.db.get_single_value(
|
||||
"E Invoice Settings", "enable"
|
||||
):
|
||||
frappe.db.sql(
|
||||
"""
|
||||
UPDATE `tabSales Invoice` SET einvoice_status = 'Pending'
|
||||
WHERE
|
||||
posting_date >= '2021-04-01'
|
||||
AND ifnull(irn, '') = ''
|
||||
AND ifnull(`billing_address_gstin`, '') != ifnull(`company_gstin`, '')
|
||||
AND ifnull(gst_category, '') in ('Registered Regular', 'SEZ', 'Overseas', 'Deemed Export')
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
# set appropriate statuses
|
||||
frappe.db.sql('''UPDATE `tabSales Invoice` SET einvoice_status = 'Generated'
|
||||
WHERE ifnull(irn, '') != '' AND ifnull(irn_cancelled, 0) = 0''')
|
||||
frappe.db.sql(
|
||||
"""UPDATE `tabSales Invoice` SET einvoice_status = 'Generated'
|
||||
WHERE ifnull(irn, '') != '' AND ifnull(irn_cancelled, 0) = 0"""
|
||||
)
|
||||
|
||||
frappe.db.sql('''UPDATE `tabSales Invoice` SET einvoice_status = 'Cancelled'
|
||||
WHERE ifnull(irn_cancelled, 0) = 1''')
|
||||
frappe.db.sql(
|
||||
"""UPDATE `tabSales Invoice` SET einvoice_status = 'Cancelled'
|
||||
WHERE ifnull(irn_cancelled, 0) = 1"""
|
||||
)
|
||||
|
||||
# set correct acknowledgement in e-invoices
|
||||
einvoices = frappe.get_all('Sales Invoice', {'irn': ['is', 'set']}, ['name', 'signed_einvoice'])
|
||||
einvoices = frappe.get_all("Sales Invoice", {"irn": ["is", "set"]}, ["name", "signed_einvoice"])
|
||||
|
||||
if einvoices:
|
||||
for inv in einvoices:
|
||||
signed_einvoice = inv.get('signed_einvoice')
|
||||
signed_einvoice = inv.get("signed_einvoice")
|
||||
if signed_einvoice:
|
||||
signed_einvoice = json.loads(signed_einvoice)
|
||||
frappe.db.set_value('Sales Invoice', inv.get('name'), 'ack_no', signed_einvoice.get('AckNo'), update_modified=False)
|
||||
frappe.db.set_value('Sales Invoice', inv.get('name'), 'ack_date', signed_einvoice.get('AckDt'), update_modified=False)
|
||||
frappe.db.set_value(
|
||||
"Sales Invoice",
|
||||
inv.get("name"),
|
||||
"ack_no",
|
||||
signed_einvoice.get("AckNo"),
|
||||
update_modified=False,
|
||||
)
|
||||
frappe.db.set_value(
|
||||
"Sales Invoice",
|
||||
inv.get("name"),
|
||||
"ack_date",
|
||||
signed_einvoice.get("AckDt"),
|
||||
update_modified=False,
|
||||
)
|
||||
|
||||
@@ -4,17 +4,17 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
company = frappe.get_all("Company", filters={"country": "India"})
|
||||
if not company:
|
||||
return
|
||||
|
||||
if frappe.db.exists('Report', 'E-Invoice Summary') and \
|
||||
not frappe.db.get_value('Custom Role', dict(report='E-Invoice Summary')):
|
||||
frappe.get_doc(dict(
|
||||
doctype='Custom Role',
|
||||
report='E-Invoice Summary',
|
||||
roles= [
|
||||
dict(role='Accounts User'),
|
||||
dict(role='Accounts Manager')
|
||||
]
|
||||
)).insert()
|
||||
if frappe.db.exists("Report", "E-Invoice Summary") and not frappe.db.get_value(
|
||||
"Custom Role", dict(report="E-Invoice Summary")
|
||||
):
|
||||
frappe.get_doc(
|
||||
dict(
|
||||
doctype="Custom Role",
|
||||
report="E-Invoice Summary",
|
||||
roles=[dict(role="Accounts User"), dict(role="Accounts Manager")],
|
||||
)
|
||||
).insert()
|
||||
|
||||
@@ -3,18 +3,21 @@ from frappe.custom.doctype.custom_field.custom_field import create_custom_field
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
company = frappe.get_all("Company", filters={"country": "India"})
|
||||
|
||||
if not company:
|
||||
return
|
||||
if not company:
|
||||
return
|
||||
|
||||
create_custom_field('Delivery Note', {
|
||||
'fieldname': 'ewaybill',
|
||||
'label': 'E-Way Bill No.',
|
||||
'fieldtype': 'Data',
|
||||
'depends_on': 'eval:(doc.docstatus === 1)',
|
||||
'allow_on_submit': 1,
|
||||
'insert_after': 'customer_name_in_arabic',
|
||||
'translatable': 0,
|
||||
'owner': 'Administrator'
|
||||
})
|
||||
create_custom_field(
|
||||
"Delivery Note",
|
||||
{
|
||||
"fieldname": "ewaybill",
|
||||
"label": "E-Way Bill No.",
|
||||
"fieldtype": "Data",
|
||||
"depends_on": "eval:(doc.docstatus === 1)",
|
||||
"allow_on_submit": 1,
|
||||
"insert_after": "customer_name_in_arabic",
|
||||
"translatable": 0,
|
||||
"owner": "Administrator",
|
||||
},
|
||||
)
|
||||
|
||||
@@ -5,14 +5,23 @@ from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
company = frappe.get_all("Company", filters={"country": "India"})
|
||||
if not company:
|
||||
return
|
||||
|
||||
custom_fields = {
|
||||
'Sales Invoice': [
|
||||
dict(fieldname='eway_bill_validity', label='E-Way Bill Validity', fieldtype='Data', no_copy=1, print_hide=1,
|
||||
depends_on='ewaybill', read_only=1, allow_on_submit=1, insert_after='ewaybill')
|
||||
"Sales Invoice": [
|
||||
dict(
|
||||
fieldname="eway_bill_validity",
|
||||
label="E-Way Bill Validity",
|
||||
fieldtype="Data",
|
||||
no_copy=1,
|
||||
print_hide=1,
|
||||
depends_on="ewaybill",
|
||||
read_only=1,
|
||||
allow_on_submit=1,
|
||||
insert_after="ewaybill",
|
||||
)
|
||||
]
|
||||
}
|
||||
create_custom_fields(custom_fields, update=True)
|
||||
|
||||
@@ -5,37 +5,38 @@ from erpnext.regional.india.setup import make_custom_fields
|
||||
|
||||
def execute():
|
||||
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
company = frappe.get_all("Company", filters={"country": "India"})
|
||||
if not company:
|
||||
return
|
||||
|
||||
make_custom_fields()
|
||||
|
||||
frappe.reload_doctype('Tax Category')
|
||||
frappe.reload_doctype('Sales Taxes and Charges Template')
|
||||
frappe.reload_doctype('Purchase Taxes and Charges Template')
|
||||
frappe.reload_doctype("Tax Category")
|
||||
frappe.reload_doctype("Sales Taxes and Charges Template")
|
||||
frappe.reload_doctype("Purchase Taxes and Charges Template")
|
||||
|
||||
# Create tax category with inter state field checked
|
||||
tax_category = frappe.db.get_value('Tax Category', {'name': 'OUT OF STATE'}, 'name')
|
||||
tax_category = frappe.db.get_value("Tax Category", {"name": "OUT OF STATE"}, "name")
|
||||
|
||||
if not tax_category:
|
||||
inter_state_category = frappe.get_doc({
|
||||
'doctype': 'Tax Category',
|
||||
'title': 'OUT OF STATE',
|
||||
'is_inter_state': 1
|
||||
}).insert()
|
||||
inter_state_category = frappe.get_doc(
|
||||
{"doctype": "Tax Category", "title": "OUT OF STATE", "is_inter_state": 1}
|
||||
).insert()
|
||||
|
||||
tax_category = inter_state_category.name
|
||||
|
||||
for doctype in ('Sales Taxes and Charges Template', 'Purchase Taxes and Charges Template'):
|
||||
if not frappe.get_meta(doctype).has_field('is_inter_state'): continue
|
||||
for doctype in ("Sales Taxes and Charges Template", "Purchase Taxes and Charges Template"):
|
||||
if not frappe.get_meta(doctype).has_field("is_inter_state"):
|
||||
continue
|
||||
|
||||
template = frappe.db.get_value(doctype, {'is_inter_state': 1, 'disabled': 0}, ['name'])
|
||||
template = frappe.db.get_value(doctype, {"is_inter_state": 1, "disabled": 0}, ["name"])
|
||||
if template:
|
||||
frappe.db.set_value(doctype, template, 'tax_category', tax_category)
|
||||
frappe.db.set_value(doctype, template, "tax_category", tax_category)
|
||||
|
||||
frappe.db.sql("""
|
||||
frappe.db.sql(
|
||||
"""
|
||||
DELETE FROM `tabCustom Field`
|
||||
WHERE fieldname = 'is_inter_state'
|
||||
AND dt IN ('Sales Taxes and Charges Template', 'Purchase Taxes and Charges Template')
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -3,16 +3,22 @@ from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
company = frappe.get_all("Company", filters={"country": "India"})
|
||||
if not company:
|
||||
return
|
||||
|
||||
custom_fields = {
|
||||
'Delivery Note': [
|
||||
dict(fieldname='gst_category', label='GST Category',
|
||||
fieldtype='Select', insert_after='gst_vehicle_type', print_hide=1,
|
||||
options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
|
||||
fetch_from='customer.gst_category', fetch_if_empty=1),
|
||||
"Delivery Note": [
|
||||
dict(
|
||||
fieldname="gst_category",
|
||||
label="GST Category",
|
||||
fieldtype="Select",
|
||||
insert_after="gst_vehicle_type",
|
||||
print_hide=1,
|
||||
options="\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders",
|
||||
fetch_from="customer.gst_category",
|
||||
fetch_if_empty=1,
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@ import frappe
|
||||
def execute():
|
||||
frappe.reload_doc("manufacturing", "doctype", "work_order")
|
||||
|
||||
frappe.db.sql("""
|
||||
frappe.db.sql(
|
||||
"""
|
||||
UPDATE
|
||||
`tabWork Order` wo
|
||||
JOIN `tabItem` item ON wo.production_item = item.item_code
|
||||
SET
|
||||
wo.item_name = item.item_name
|
||||
""")
|
||||
"""
|
||||
)
|
||||
frappe.db.commit()
|
||||
|
||||
@@ -3,12 +3,12 @@ from frappe.permissions import add_permission, update_permission_property
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
company = frappe.get_all("Company", filters={"country": "India"})
|
||||
if not company:
|
||||
return
|
||||
|
||||
frappe.reload_doc('regional', 'doctype', 'Lower Deduction Certificate')
|
||||
frappe.reload_doc("regional", "doctype", "Lower Deduction Certificate")
|
||||
|
||||
add_permission('Lower Deduction Certificate', 'Accounts Manager', 0)
|
||||
update_permission_property('Lower Deduction Certificate', 'Accounts Manager', 0, 'write', 1)
|
||||
update_permission_property('Lower Deduction Certificate', 'Accounts Manager', 0, 'create', 1)
|
||||
add_permission("Lower Deduction Certificate", "Accounts Manager", 0)
|
||||
update_permission_property("Lower Deduction Certificate", "Accounts Manager", 0, "write", 1)
|
||||
update_permission_property("Lower Deduction Certificate", "Accounts Manager", 0, "create", 1)
|
||||
|
||||
@@ -5,15 +5,15 @@ from erpnext.regional.india import states
|
||||
|
||||
def execute():
|
||||
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
company = frappe.get_all("Company", filters={"country": "India"})
|
||||
if not company:
|
||||
return
|
||||
|
||||
custom_fields = ['Address-gst_state', 'Tax Category-gst_state']
|
||||
custom_fields = ["Address-gst_state", "Tax Category-gst_state"]
|
||||
|
||||
# Update options in gst_state custom fields
|
||||
for field in custom_fields:
|
||||
if frappe.db.exists('Custom Field', field):
|
||||
gst_state_field = frappe.get_doc('Custom Field', field)
|
||||
gst_state_field.options = '\n'.join(states)
|
||||
if frappe.db.exists("Custom Field", field):
|
||||
gst_state_field = frappe.get_doc("Custom Field", field)
|
||||
gst_state_field.options = "\n".join(states)
|
||||
gst_state_field.save()
|
||||
|
||||
@@ -4,7 +4,7 @@ from erpnext.regional.united_states.setup import make_custom_fields
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters={'country': 'United States'})
|
||||
company = frappe.get_all("Company", filters={"country": "United States"})
|
||||
if not company:
|
||||
return
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('stock', 'doctype', 'item_variant_attribute')
|
||||
frappe.db.sql('''
|
||||
frappe.reload_doc("stock", "doctype", "item_variant_attribute")
|
||||
frappe.db.sql(
|
||||
"""
|
||||
UPDATE `tabItem Variant Attribute` t1
|
||||
INNER JOIN `tabItem` t2 ON t2.name = t1.parent
|
||||
SET t1.variant_of = t2.variant_of
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -4,10 +4,13 @@ from frappe.custom.doctype.custom_field.custom_field import create_custom_field
|
||||
|
||||
def execute():
|
||||
|
||||
frappe.reload_doc('accounts', 'doctype', 'accounting_dimension')
|
||||
frappe.reload_doc("accounts", "doctype", "accounting_dimension")
|
||||
|
||||
accounting_dimensions = frappe.db.sql("""select fieldname, label, document_type, disabled from
|
||||
`tabAccounting Dimension`""", as_dict=1)
|
||||
accounting_dimensions = frappe.db.sql(
|
||||
"""select fieldname, label, document_type, disabled from
|
||||
`tabAccounting Dimension`""",
|
||||
as_dict=1,
|
||||
)
|
||||
|
||||
if not accounting_dimensions:
|
||||
return
|
||||
@@ -15,13 +18,19 @@ def execute():
|
||||
count = 1
|
||||
for d in accounting_dimensions:
|
||||
|
||||
if count%2 == 0:
|
||||
insert_after_field = 'dimension_col_break'
|
||||
if count % 2 == 0:
|
||||
insert_after_field = "dimension_col_break"
|
||||
else:
|
||||
insert_after_field = 'accounting_dimensions_section'
|
||||
insert_after_field = "accounting_dimensions_section"
|
||||
|
||||
for doctype in ["Subscription Plan", "Subscription", "Opening Invoice Creation Tool", "Opening Invoice Creation Tool Item",
|
||||
"Expense Claim Detail", "Expense Taxes and Charges"]:
|
||||
for doctype in [
|
||||
"Subscription Plan",
|
||||
"Subscription",
|
||||
"Opening Invoice Creation Tool",
|
||||
"Opening Invoice Creation Tool Item",
|
||||
"Expense Claim Detail",
|
||||
"Expense Taxes and Charges",
|
||||
]:
|
||||
|
||||
field = frappe.db.get_value("Custom Field", {"dt": doctype, "fieldname": d.fieldname})
|
||||
|
||||
@@ -33,7 +42,7 @@ def execute():
|
||||
"label": d.label,
|
||||
"fieldtype": "Link",
|
||||
"options": d.document_type,
|
||||
"insert_after": insert_after_field
|
||||
"insert_after": insert_after_field,
|
||||
}
|
||||
|
||||
create_custom_field(doctype, df)
|
||||
|
||||
@@ -4,5 +4,5 @@ from erpnext.setup.install import create_default_energy_point_rules
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('social', 'doctype', 'energy_point_rule')
|
||||
frappe.reload_doc("social", "doctype", "energy_point_rule")
|
||||
create_default_energy_point_rules()
|
||||
|
||||
@@ -5,12 +5,12 @@ from erpnext.regional.united_states.setup import make_custom_fields
|
||||
|
||||
def execute():
|
||||
|
||||
frappe.reload_doc('accounts', 'doctype', 'allowed_to_transact_with', force=True)
|
||||
frappe.reload_doc('accounts', 'doctype', 'pricing_rule_detail', force=True)
|
||||
frappe.reload_doc('crm', 'doctype', 'lost_reason_detail', force=True)
|
||||
frappe.reload_doc('setup', 'doctype', 'quotation_lost_reason_detail', force=True)
|
||||
frappe.reload_doc("accounts", "doctype", "allowed_to_transact_with", force=True)
|
||||
frappe.reload_doc("accounts", "doctype", "pricing_rule_detail", force=True)
|
||||
frappe.reload_doc("crm", "doctype", "lost_reason_detail", force=True)
|
||||
frappe.reload_doc("setup", "doctype", "quotation_lost_reason_detail", force=True)
|
||||
|
||||
company = frappe.get_all('Company', filters = {'country': 'United States'})
|
||||
company = frappe.get_all("Company", filters={"country": "United States"})
|
||||
if not company:
|
||||
return
|
||||
|
||||
|
||||
@@ -6,44 +6,76 @@ from erpnext.regional.india.utils import get_gst_accounts
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'}, fields=['name'])
|
||||
company = frappe.get_all("Company", filters={"country": "India"}, fields=["name"])
|
||||
if not company:
|
||||
return
|
||||
|
||||
frappe.reload_doc("regional", "doctype", "gst_settings")
|
||||
frappe.reload_doc("accounts", "doctype", "gst_account")
|
||||
|
||||
journal_entry_types = frappe.get_meta("Journal Entry").get_options("voucher_type").split("\n") + ['Reversal Of ITC']
|
||||
make_property_setter('Journal Entry', 'voucher_type', 'options', '\n'.join(journal_entry_types), '')
|
||||
journal_entry_types = frappe.get_meta("Journal Entry").get_options("voucher_type").split("\n") + [
|
||||
"Reversal Of ITC"
|
||||
]
|
||||
make_property_setter(
|
||||
"Journal Entry", "voucher_type", "options", "\n".join(journal_entry_types), ""
|
||||
)
|
||||
|
||||
custom_fields = {
|
||||
'Journal Entry': [
|
||||
dict(fieldname='reversal_type', label='Reversal Type',
|
||||
fieldtype='Select', insert_after='voucher_type', print_hide=1,
|
||||
"Journal Entry": [
|
||||
dict(
|
||||
fieldname="reversal_type",
|
||||
label="Reversal Type",
|
||||
fieldtype="Select",
|
||||
insert_after="voucher_type",
|
||||
print_hide=1,
|
||||
options="As per rules 42 & 43 of CGST Rules\nOthers",
|
||||
depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
|
||||
mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'"),
|
||||
dict(fieldname='company_address', label='Company Address',
|
||||
fieldtype='Link', options='Address', insert_after='reversal_type',
|
||||
print_hide=1, depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
|
||||
mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'"),
|
||||
dict(fieldname='company_gstin', label='Company GSTIN',
|
||||
fieldtype='Data', read_only=1, insert_after='company_address', print_hide=1,
|
||||
fetch_from='company_address.gstin',
|
||||
mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
|
||||
),
|
||||
dict(
|
||||
fieldname="company_address",
|
||||
label="Company Address",
|
||||
fieldtype="Link",
|
||||
options="Address",
|
||||
insert_after="reversal_type",
|
||||
print_hide=1,
|
||||
depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
|
||||
mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'")
|
||||
mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
|
||||
),
|
||||
dict(
|
||||
fieldname="company_gstin",
|
||||
label="Company GSTIN",
|
||||
fieldtype="Data",
|
||||
read_only=1,
|
||||
insert_after="company_address",
|
||||
print_hide=1,
|
||||
fetch_from="company_address.gstin",
|
||||
depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
|
||||
mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
|
||||
),
|
||||
],
|
||||
'Purchase Invoice': [
|
||||
dict(fieldname='eligibility_for_itc', label='Eligibility For ITC',
|
||||
fieldtype='Select', insert_after='reason_for_issuing_document', print_hide=1,
|
||||
options='Input Service Distributor\nImport Of Service\nImport Of Capital Goods\nITC on Reverse Charge\nIneligible As Per Section 17(5)\nIneligible Others\nAll Other ITC',
|
||||
default="All Other ITC")
|
||||
"Purchase Invoice": [
|
||||
dict(
|
||||
fieldname="eligibility_for_itc",
|
||||
label="Eligibility For ITC",
|
||||
fieldtype="Select",
|
||||
insert_after="reason_for_issuing_document",
|
||||
print_hide=1,
|
||||
options="Input Service Distributor\nImport Of Service\nImport Of Capital Goods\nITC on Reverse Charge\nIneligible As Per Section 17(5)\nIneligible Others\nAll Other ITC",
|
||||
default="All Other ITC",
|
||||
)
|
||||
],
|
||||
"Purchase Invoice Item": [
|
||||
dict(
|
||||
fieldname="taxable_value",
|
||||
label="Taxable Value",
|
||||
fieldtype="Currency",
|
||||
insert_after="base_net_amount",
|
||||
hidden=1,
|
||||
options="Company:company:default_currency",
|
||||
print_hide=1,
|
||||
)
|
||||
],
|
||||
'Purchase Invoice Item': [
|
||||
dict(fieldname='taxable_value', label='Taxable Value',
|
||||
fieldtype='Currency', insert_after='base_net_amount', hidden=1, options="Company:company:default_currency",
|
||||
print_hide=1)
|
||||
]
|
||||
}
|
||||
|
||||
create_custom_fields(custom_fields, update=True)
|
||||
@@ -53,28 +85,40 @@ def execute():
|
||||
|
||||
gst_accounts = get_gst_accounts(only_non_reverse_charge=1)
|
||||
|
||||
frappe.db.sql("""
|
||||
frappe.db.sql(
|
||||
"""
|
||||
UPDATE `tabCustom Field` SET fieldtype='Currency', options='Company:company:default_currency'
|
||||
WHERE dt = 'Purchase Invoice' and fieldname in ('itc_integrated_tax', 'itc_state_tax', 'itc_central_tax',
|
||||
'itc_cess_amount')
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
frappe.db.sql("""UPDATE `tabPurchase Invoice` set itc_integrated_tax = '0'
|
||||
WHERE trim(coalesce(itc_integrated_tax, '')) = '' """)
|
||||
frappe.db.sql(
|
||||
"""UPDATE `tabPurchase Invoice` set itc_integrated_tax = '0'
|
||||
WHERE trim(coalesce(itc_integrated_tax, '')) = '' """
|
||||
)
|
||||
|
||||
frappe.db.sql("""UPDATE `tabPurchase Invoice` set itc_state_tax = '0'
|
||||
WHERE trim(coalesce(itc_state_tax, '')) = '' """)
|
||||
frappe.db.sql(
|
||||
"""UPDATE `tabPurchase Invoice` set itc_state_tax = '0'
|
||||
WHERE trim(coalesce(itc_state_tax, '')) = '' """
|
||||
)
|
||||
|
||||
frappe.db.sql("""UPDATE `tabPurchase Invoice` set itc_central_tax = '0'
|
||||
WHERE trim(coalesce(itc_central_tax, '')) = '' """)
|
||||
frappe.db.sql(
|
||||
"""UPDATE `tabPurchase Invoice` set itc_central_tax = '0'
|
||||
WHERE trim(coalesce(itc_central_tax, '')) = '' """
|
||||
)
|
||||
|
||||
frappe.db.sql("""UPDATE `tabPurchase Invoice` set itc_cess_amount = '0'
|
||||
WHERE trim(coalesce(itc_cess_amount, '')) = '' """)
|
||||
frappe.db.sql(
|
||||
"""UPDATE `tabPurchase Invoice` set itc_cess_amount = '0'
|
||||
WHERE trim(coalesce(itc_cess_amount, '')) = '' """
|
||||
)
|
||||
|
||||
# Get purchase invoices
|
||||
invoices = frappe.get_all('Purchase Invoice',
|
||||
{'posting_date': ('>=', '2021-04-01'), 'eligibility_for_itc': ('!=', 'Ineligible')},
|
||||
['name'])
|
||||
invoices = frappe.get_all(
|
||||
"Purchase Invoice",
|
||||
{"posting_date": (">=", "2021-04-01"), "eligibility_for_itc": ("!=", "Ineligible")},
|
||||
["name"],
|
||||
)
|
||||
|
||||
amount_map = {}
|
||||
|
||||
@@ -82,37 +126,42 @@ def execute():
|
||||
invoice_list = set([d.name for d in invoices])
|
||||
|
||||
# Get GST applied
|
||||
amounts = frappe.db.sql("""
|
||||
amounts = frappe.db.sql(
|
||||
"""
|
||||
SELECT parent, account_head, sum(base_tax_amount_after_discount_amount) as amount
|
||||
FROM `tabPurchase Taxes and Charges`
|
||||
where parent in %s
|
||||
GROUP BY parent, account_head
|
||||
""", (invoice_list), as_dict=1)
|
||||
""",
|
||||
(invoice_list),
|
||||
as_dict=1,
|
||||
)
|
||||
|
||||
for d in amounts:
|
||||
amount_map.setdefault(d.parent,
|
||||
{
|
||||
'itc_integrated_tax': 0,
|
||||
'itc_state_tax': 0,
|
||||
'itc_central_tax': 0,
|
||||
'itc_cess_amount': 0
|
||||
})
|
||||
amount_map.setdefault(
|
||||
d.parent,
|
||||
{"itc_integrated_tax": 0, "itc_state_tax": 0, "itc_central_tax": 0, "itc_cess_amount": 0},
|
||||
)
|
||||
if not gst_accounts:
|
||||
continue
|
||||
|
||||
if d.account_head in gst_accounts.get('igst_account'):
|
||||
amount_map[d.parent]['itc_integrated_tax'] += d.amount
|
||||
if d.account_head in gst_accounts.get('cgst_account'):
|
||||
amount_map[d.parent]['itc_central_tax'] += d.amount
|
||||
if d.account_head in gst_accounts.get('sgst_account'):
|
||||
amount_map[d.parent]['itc_state_tax'] += d.amount
|
||||
if d.account_head in gst_accounts.get('cess_account'):
|
||||
amount_map[d.parent]['itc_cess_amount'] += d.amount
|
||||
if d.account_head in gst_accounts.get("igst_account"):
|
||||
amount_map[d.parent]["itc_integrated_tax"] += d.amount
|
||||
if d.account_head in gst_accounts.get("cgst_account"):
|
||||
amount_map[d.parent]["itc_central_tax"] += d.amount
|
||||
if d.account_head in gst_accounts.get("sgst_account"):
|
||||
amount_map[d.parent]["itc_state_tax"] += d.amount
|
||||
if d.account_head in gst_accounts.get("cess_account"):
|
||||
amount_map[d.parent]["itc_cess_amount"] += d.amount
|
||||
|
||||
for invoice, values in amount_map.items():
|
||||
frappe.db.set_value('Purchase Invoice', invoice, {
|
||||
'itc_integrated_tax': values.get('itc_integrated_tax'),
|
||||
'itc_central_tax': values.get('itc_central_tax'),
|
||||
'itc_state_tax': values['itc_state_tax'],
|
||||
'itc_cess_amount': values['itc_cess_amount'],
|
||||
})
|
||||
frappe.db.set_value(
|
||||
"Purchase Invoice",
|
||||
invoice,
|
||||
{
|
||||
"itc_integrated_tax": values.get("itc_integrated_tax"),
|
||||
"itc_central_tax": values.get("itc_central_tax"),
|
||||
"itc_state_tax": values["itc_state_tax"],
|
||||
"itc_cess_amount": values["itc_cess_amount"],
|
||||
},
|
||||
)
|
||||
|
||||
@@ -3,15 +3,21 @@ from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
company = frappe.get_all("Company", filters={"country": "India"})
|
||||
if not company:
|
||||
return
|
||||
|
||||
custom_fields = {
|
||||
'Sales Invoice Item': [
|
||||
dict(fieldname='taxable_value', label='Taxable Value',
|
||||
fieldtype='Currency', insert_after='base_net_amount', hidden=1, options="Company:company:default_currency",
|
||||
print_hide=1)
|
||||
"Sales Invoice Item": [
|
||||
dict(
|
||||
fieldname="taxable_value",
|
||||
label="Taxable Value",
|
||||
fieldtype="Currency",
|
||||
insert_after="base_net_amount",
|
||||
hidden=1,
|
||||
options="Company:company:default_currency",
|
||||
print_hide=1,
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.db.sql("""
|
||||
frappe.db.sql(
|
||||
"""
|
||||
DELETE FROM `tabProperty Setter`
|
||||
WHERE `tabProperty Setter`.doc_type='Issue'
|
||||
AND `tabProperty Setter`.field_name='priority'
|
||||
AND `tabProperty Setter`.property='options'
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -4,10 +4,13 @@ from frappe.utils import flt
|
||||
|
||||
def execute():
|
||||
for project in frappe.get_all("Project", fields=["name", "percent_complete_method"]):
|
||||
total = frappe.db.count('Task', dict(project=project.name))
|
||||
total = frappe.db.count("Task", dict(project=project.name))
|
||||
if project.percent_complete_method == "Task Completion" and total > 0:
|
||||
completed = frappe.db.sql("""select count(name) from tabTask where
|
||||
project=%s and status in ('Cancelled', 'Completed')""", project.name)[0][0]
|
||||
completed = frappe.db.sql(
|
||||
"""select count(name) from tabTask where
|
||||
project=%s and status in ('Cancelled', 'Completed')""",
|
||||
project.name,
|
||||
)[0][0]
|
||||
percent_complete = flt(flt(completed) / total * 100, 2)
|
||||
if project.percent_complete != percent_complete:
|
||||
frappe.db.set_value("Project", project.name, "percent_complete", percent_complete)
|
||||
|
||||
@@ -13,12 +13,13 @@ def execute():
|
||||
so_item.docstatus = 1 and so.docstatus = 1
|
||||
and so_item.parent = so.name
|
||||
and so_item.prevdoc_docname = qo.name
|
||||
and qo.valid_till < so.transaction_date""" # check if SO was created after quotation expired
|
||||
and qo.valid_till < so.transaction_date""" # check if SO was created after quotation expired
|
||||
|
||||
frappe.db.sql(
|
||||
"""UPDATE `tabQuotation` qo SET qo.status = 'Expired' WHERE {cond} and exists({invalid_so_against_quo})"""
|
||||
.format(cond=cond, invalid_so_against_quo=invalid_so_against_quo)
|
||||
"""UPDATE `tabQuotation` qo SET qo.status = 'Expired' WHERE {cond} and exists({invalid_so_against_quo})""".format(
|
||||
cond=cond, invalid_so_against_quo=invalid_so_against_quo
|
||||
)
|
||||
)
|
||||
|
||||
valid_so_against_quo = """
|
||||
SELECT
|
||||
@@ -27,9 +28,10 @@ def execute():
|
||||
so_item.docstatus = 1 and so.docstatus = 1
|
||||
and so_item.parent = so.name
|
||||
and so_item.prevdoc_docname = qo.name
|
||||
and qo.valid_till >= so.transaction_date""" # check if SO was created before quotation expired
|
||||
and qo.valid_till >= so.transaction_date""" # check if SO was created before quotation expired
|
||||
|
||||
frappe.db.sql(
|
||||
"""UPDATE `tabQuotation` qo SET qo.status = 'Closed' WHERE {cond} and exists({valid_so_against_quo})"""
|
||||
.format(cond=cond, valid_so_against_quo=valid_so_against_quo)
|
||||
"""UPDATE `tabQuotation` qo SET qo.status = 'Closed' WHERE {cond} and exists({valid_so_against_quo})""".format(
|
||||
cond=cond, valid_so_against_quo=valid_so_against_quo
|
||||
)
|
||||
)
|
||||
|
||||
@@ -7,8 +7,8 @@ from frappe.utils import getdate, today
|
||||
|
||||
|
||||
def execute():
|
||||
""" Generates leave ledger entries for leave allocation/application/encashment
|
||||
for last allocation """
|
||||
"""Generates leave ledger entries for leave allocation/application/encashment
|
||||
for last allocation"""
|
||||
frappe.reload_doc("HR", "doctype", "Leave Ledger Entry")
|
||||
frappe.reload_doc("HR", "doctype", "Leave Encashment")
|
||||
frappe.reload_doc("HR", "doctype", "Leave Type")
|
||||
@@ -22,55 +22,79 @@ def execute():
|
||||
generate_encashment_leave_ledger_entries()
|
||||
generate_expiry_allocation_ledger_entries()
|
||||
|
||||
|
||||
def update_leave_allocation_fieldname():
|
||||
''' maps data from old field to the new field '''
|
||||
frappe.db.sql("""
|
||||
"""maps data from old field to the new field"""
|
||||
frappe.db.sql(
|
||||
"""
|
||||
UPDATE `tabLeave Allocation`
|
||||
SET `unused_leaves` = `carry_forwarded_leaves`
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def generate_allocation_ledger_entries():
|
||||
''' fix ledger entries for missing leave allocation transaction '''
|
||||
"""fix ledger entries for missing leave allocation transaction"""
|
||||
allocation_list = get_allocation_records()
|
||||
|
||||
for allocation in allocation_list:
|
||||
if not frappe.db.exists("Leave Ledger Entry", {'transaction_type': 'Leave Allocation', 'transaction_name': allocation.name}):
|
||||
if not frappe.db.exists(
|
||||
"Leave Ledger Entry",
|
||||
{"transaction_type": "Leave Allocation", "transaction_name": allocation.name},
|
||||
):
|
||||
allocation_obj = frappe.get_doc("Leave Allocation", allocation)
|
||||
allocation_obj.create_leave_ledger_entry()
|
||||
|
||||
|
||||
def generate_application_leave_ledger_entries():
|
||||
''' fix ledger entries for missing leave application transaction '''
|
||||
"""fix ledger entries for missing leave application transaction"""
|
||||
leave_applications = get_leaves_application_records()
|
||||
|
||||
for application in leave_applications:
|
||||
if not frappe.db.exists("Leave Ledger Entry", {'transaction_type': 'Leave Application', 'transaction_name': application.name}):
|
||||
if not frappe.db.exists(
|
||||
"Leave Ledger Entry",
|
||||
{"transaction_type": "Leave Application", "transaction_name": application.name},
|
||||
):
|
||||
frappe.get_doc("Leave Application", application.name).create_leave_ledger_entry()
|
||||
|
||||
|
||||
def generate_encashment_leave_ledger_entries():
|
||||
''' fix ledger entries for missing leave encashment transaction '''
|
||||
"""fix ledger entries for missing leave encashment transaction"""
|
||||
leave_encashments = get_leave_encashment_records()
|
||||
|
||||
for encashment in leave_encashments:
|
||||
if not frappe.db.exists("Leave Ledger Entry", {'transaction_type': 'Leave Encashment', 'transaction_name': encashment.name}):
|
||||
if not frappe.db.exists(
|
||||
"Leave Ledger Entry",
|
||||
{"transaction_type": "Leave Encashment", "transaction_name": encashment.name},
|
||||
):
|
||||
frappe.get_doc("Leave Encashment", encashment).create_leave_ledger_entry()
|
||||
|
||||
|
||||
def generate_expiry_allocation_ledger_entries():
|
||||
''' fix ledger entries for missing leave allocation transaction '''
|
||||
"""fix ledger entries for missing leave allocation transaction"""
|
||||
from erpnext.hr.doctype.leave_ledger_entry.leave_ledger_entry import expire_allocation
|
||||
|
||||
allocation_list = get_allocation_records()
|
||||
|
||||
for allocation in allocation_list:
|
||||
if not frappe.db.exists("Leave Ledger Entry", {'transaction_type': 'Leave Allocation', 'transaction_name': allocation.name, 'is_expired': 1}):
|
||||
if not frappe.db.exists(
|
||||
"Leave Ledger Entry",
|
||||
{"transaction_type": "Leave Allocation", "transaction_name": allocation.name, "is_expired": 1},
|
||||
):
|
||||
allocation_obj = frappe.get_doc("Leave Allocation", allocation)
|
||||
if allocation_obj.to_date <= getdate(today()):
|
||||
expire_allocation(allocation_obj)
|
||||
|
||||
|
||||
def get_allocation_records():
|
||||
return frappe.get_all("Leave Allocation", filters={"docstatus": 1},
|
||||
fields=['name'], order_by='to_date ASC')
|
||||
return frappe.get_all(
|
||||
"Leave Allocation", filters={"docstatus": 1}, fields=["name"], order_by="to_date ASC"
|
||||
)
|
||||
|
||||
|
||||
def get_leaves_application_records():
|
||||
return frappe.get_all("Leave Application", filters={"docstatus": 1}, fields=['name'])
|
||||
return frappe.get_all("Leave Application", filters={"docstatus": 1}, fields=["name"])
|
||||
|
||||
|
||||
def get_leave_encashment_records():
|
||||
return frappe.get_all("Leave Encashment", filters={"docstatus": 1}, fields=['name'])
|
||||
return frappe.get_all("Leave Encashment", filters={"docstatus": 1}, fields=["name"])
|
||||
|
||||
@@ -9,20 +9,29 @@ 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((
|
||||
frappe.generate_hash("", 10),
|
||||
d.name,
|
||||
d.manufacturer,
|
||||
d.manufacturer_part_no,
|
||||
d.creation,
|
||||
d.owner
|
||||
))
|
||||
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,
|
||||
)
|
||||
)
|
||||
|
||||
if item_manufacturer:
|
||||
frappe.db.sql('''
|
||||
frappe.db.sql(
|
||||
"""
|
||||
INSERT INTO `tabItem Manufacturer`
|
||||
(`name`, `item_code`, `manufacturer`, `manufacturer_part_no`, `creation`, `owner`)
|
||||
VALUES {}'''.format(', '.join(['%s'] * len(item_manufacturer))), tuple(item_manufacturer)
|
||||
VALUES {}""".format(
|
||||
", ".join(["%s"] * len(item_manufacturer))
|
||||
),
|
||||
tuple(item_manufacturer),
|
||||
)
|
||||
|
||||
@@ -2,16 +2,22 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('accounts', 'doctype', 'bank', force=1)
|
||||
frappe.reload_doc("accounts", "doctype", "bank", force=1)
|
||||
|
||||
if frappe.db.table_exists('Bank') and frappe.db.table_exists('Bank Account') and frappe.db.has_column('Bank Account', 'swift_number'):
|
||||
if (
|
||||
frappe.db.table_exists("Bank")
|
||||
and frappe.db.table_exists("Bank Account")
|
||||
and frappe.db.has_column("Bank Account", "swift_number")
|
||||
):
|
||||
try:
|
||||
frappe.db.sql("""
|
||||
frappe.db.sql(
|
||||
"""
|
||||
UPDATE `tabBank` b, `tabBank Account` ba
|
||||
SET b.swift_number = ba.swift_number WHERE b.name = ba.bank
|
||||
""")
|
||||
"""
|
||||
)
|
||||
except Exception as e:
|
||||
frappe.log_error(e, title="Patch Migration Failed")
|
||||
|
||||
frappe.reload_doc('accounts', 'doctype', 'bank_account')
|
||||
frappe.reload_doc('accounts', 'doctype', 'payment_request')
|
||||
frappe.reload_doc("accounts", "doctype", "bank_account")
|
||||
frappe.reload_doc("accounts", "doctype", "payment_request")
|
||||
|
||||
@@ -6,7 +6,7 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
''' Move credit limit and bypass credit limit to the child table of customer credit limit '''
|
||||
"""Move credit limit and bypass credit limit to the child table of customer credit limit"""
|
||||
frappe.reload_doc("Selling", "doctype", "Customer Credit Limit")
|
||||
frappe.reload_doc("Selling", "doctype", "Customer")
|
||||
frappe.reload_doc("Setup", "doctype", "Customer Group")
|
||||
@@ -16,28 +16,32 @@ def execute():
|
||||
|
||||
move_credit_limit_to_child_table()
|
||||
|
||||
def move_credit_limit_to_child_table():
|
||||
''' maps data from old field to the new field in the child table '''
|
||||
|
||||
companies = frappe.get_all("Company", 'name')
|
||||
def move_credit_limit_to_child_table():
|
||||
"""maps data from old field to the new field in the child table"""
|
||||
|
||||
companies = frappe.get_all("Company", "name")
|
||||
for doctype in ("Customer", "Customer Group"):
|
||||
fields = ""
|
||||
if doctype == "Customer" \
|
||||
and frappe.db.has_column('Customer', 'bypass_credit_limit_check_at_sales_order'):
|
||||
if doctype == "Customer" and frappe.db.has_column(
|
||||
"Customer", "bypass_credit_limit_check_at_sales_order"
|
||||
):
|
||||
fields = ", bypass_credit_limit_check_at_sales_order"
|
||||
|
||||
credit_limit_records = frappe.db.sql('''
|
||||
credit_limit_records = frappe.db.sql(
|
||||
"""
|
||||
SELECT name, credit_limit {0}
|
||||
FROM `tab{1}` where credit_limit > 0
|
||||
'''.format(fields, doctype), as_dict=1) #nosec
|
||||
""".format(
|
||||
fields, doctype
|
||||
),
|
||||
as_dict=1,
|
||||
) # nosec
|
||||
|
||||
for record in credit_limit_records:
|
||||
doc = frappe.get_doc(doctype, record.name)
|
||||
for company in companies:
|
||||
row = frappe._dict({
|
||||
'credit_limit': record.credit_limit,
|
||||
'company': company.name
|
||||
})
|
||||
row = frappe._dict({"credit_limit": record.credit_limit, "company": company.name})
|
||||
if doctype == "Customer":
|
||||
row.bypass_credit_limit_check = record.bypass_credit_limit_check_at_sales_order
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user