Merge pull request #25946 from gavindsouza/patch-tests

ci: Update Patch tests
This commit is contained in:
rohitwaghchaure 2021-06-10 14:11:08 +05:30 committed by GitHub
commit 64cc60f97a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
445 changed files with 16 additions and 10096 deletions

View File

@ -66,4 +66,8 @@ jobs:
run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
- name: Run Patch Tests
run: cd ~/frappe-bench/ && wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz && bench --site test_site --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz && bench --site test_site migrate
run: |
cd ~/frappe-bench/
wget https://erpnext.com/files/v10-erpnext.sql.gz
bench --site test_site --force restore ~/frappe-bench/v10-erpnext.sql.gz
bench --site test_site migrate

View File

@ -1,494 +1,19 @@
execute:import unidecode # new requirement
erpnext.patches.v8_0.move_perpetual_inventory_setting
erpnext.patches.v8_9.set_print_zero_amount_taxes
erpnext.patches.v12_0.update_is_cancelled_field
erpnext.patches.v11_0.rename_production_order_to_work_order
erpnext.patches.v11_0.refactor_naming_series
erpnext.patches.v11_0.refactor_autoname_naming
erpnext.patches.v10_0.rename_schools_to_education
erpnext.patches.v4_0.validate_v3_patch
erpnext.patches.v4_0.fix_employee_user_id
erpnext.patches.v4_0.remove_employee_role_if_no_employee
erpnext.patches.v4_0.update_user_properties
erpnext.patches.v4_0.apply_user_permissions
erpnext.patches.v4_0.move_warehouse_user_to_restrictions
erpnext.patches.v4_0.global_defaults_to_system_settings
erpnext.patches.v4_0.update_incharge_name_to_sales_person_in_maintenance_schedule
execute:frappe.reload_doc("accounts", "doctype", "POS Payment Method") #2020-05-28
execute:frappe.reload_doc("HR", "doctype", "HR Settings") #2020-01-16 #2020-07-24
execute:frappe.reload_doc('stock', 'doctype', 'warehouse') # 2017-04-24
execute:frappe.reload_doc('accounts', 'doctype', 'sales_invoice') # 2016-08-31
execute:frappe.reload_doc('selling', 'doctype', 'sales_order') # 2014-01-29
execute:frappe.reload_doc('selling', 'doctype', 'quotation') # 2014-01-29
execute:frappe.reload_doc('stock', 'doctype', 'delivery_note') # 2014-01-29
erpnext.patches.v4_0.reload_sales_print_format
execute:frappe.reload_doc('accounts', 'doctype', 'purchase_invoice') # 2014-01-29
execute:frappe.reload_doc('buying', 'doctype', 'purchase_order') # 2014-01-29
execute:frappe.reload_doc('buying', 'doctype', 'supplier_quotation') # 2014-01-29
execute:frappe.reload_doc('stock', 'doctype', 'purchase_receipt') # 2014-01-29
execute:frappe.reload_doc('accounts', 'doctype', 'pos_setting') # 2014-01-29
execute:frappe.reload_doc('selling', 'doctype', 'customer') # 2014-01-29
execute:frappe.reload_doc('buying', 'doctype', 'supplier') # 2014-01-29
execute:frappe.reload_doc('accounts', 'doctype', 'asset_category')
execute:frappe.reload_doc('accounts', 'doctype', 'pricing_rule')
erpnext.patches.v4_0.map_charge_to_taxes_and_charges
execute:frappe.reload_doc('support', 'doctype', 'newsletter') # 2014-01-31
execute:frappe.reload_doc('hr', 'doctype', 'employee') # 2014-02-03
execute:frappe.db.sql("update tabPage set module='Core' where name='Setup'")
erpnext.patches.v5_2.change_item_selects_to_checks
execute:frappe.reload_doctype('Item')
erpnext.patches.v4_0.fields_to_be_renamed
erpnext.patches.v4_0.rename_sitemap_to_route
erpnext.patches.v7_0.re_route #2016-06-27
erpnext.patches.v4_0.fix_contact_address
erpnext.patches.v4_0.customer_discount_to_pricing_rule
execute:frappe.db.sql("""delete from `tabWebsite Item Group` where ifnull(item_group, '')=''""")
erpnext.patches.v4_0.remove_module_home_pages
erpnext.patches.v4_0.split_email_settings
erpnext.patches.v4_0.import_country_codes
erpnext.patches.v4_0.countrywise_coa
execute:frappe.delete_doc("DocType", "MIS Control")
execute:frappe.delete_doc("Page", "Financial Statements")
execute:frappe.delete_doc("DocType", "Stock Ledger")
execute:frappe.delete_doc("DocType", "Grade")
execute:frappe.db.sql("delete from `tabWebsite Item Group` where ifnull(item_group, '')=''")
execute:frappe.delete_doc("Print Format", "SalesInvoice")
execute:import frappe.defaults;frappe.defaults.clear_default("price_list_currency")
erpnext.patches.v4_0.update_account_root_type
execute:frappe.delete_doc("Report", "Purchase In Transit")
erpnext.patches.v4_0.new_address_template
execute:frappe.delete_doc("DocType", "SMS Control")
execute:frappe.delete_doc_if_exists("DocType", "Bulk SMS") #2015-08-18
erpnext.patches.v4_0.fix_case_of_hr_module_def
erpnext.patches.v4_0.fix_address_template
# WATCHOUT: This patch reload's documents
erpnext.patches.v4_0.reset_permissions_for_masters
erpnext.patches.v6_20x.rename_project_name_to_project #2016-03-14
erpnext.patches.v4_0.update_tax_amount_after_discount
execute:frappe.permissions.reset_perms("GL Entry") #2014-06-09
execute:frappe.permissions.reset_perms("Stock Ledger Entry") #2014-06-09
erpnext.patches.v4_0.create_custom_fields_for_india_specific_fields
erpnext.patches.v4_0.save_default_letterhead
erpnext.patches.v4_0.update_custom_print_formats_for_renamed_fields
erpnext.patches.v4_0.update_other_charges_in_custom_purchase_print_formats
erpnext.patches.v4_0.create_price_list_if_missing
execute:frappe.db.sql("update `tabItem` set end_of_life=null where end_of_life='0000-00-00'") #2014-06-16
erpnext.patches.v4_0.update_users_report_view_settings
erpnext.patches.v4_0.set_pricing_rule_for_buying_or_selling
erpnext.patches.v4_1.set_outgoing_email_footer
erpnext.patches.v4_1.fix_sales_order_delivered_status
erpnext.patches.v4_1.fix_delivery_and_billing_status
execute:frappe.db.sql("update `tabAccount` set root_type='Liability' where root_type='Income' and report_type='Balance Sheet'")
execute:frappe.delete_doc("DocType", "Payment to Invoice Matching Tool") # 29-07-2014
execute:frappe.delete_doc("DocType", "Payment to Invoice Matching Tool Detail") # 29-07-2014
execute:frappe.delete_doc("Page", "trial-balance") #2014-07-22
erpnext.patches.v4_2.delete_old_print_formats #2014-07-29
erpnext.patches.v4_2.toggle_rounded_total #2014-07-30
erpnext.patches.v4_2.fix_account_master_type
erpnext.patches.v4_2.update_project_milestones
erpnext.patches.v4_2.add_currency_turkish_lira #2014-08-08
execute:frappe.delete_doc("DocType", "Landed Cost Wizard")
erpnext.patches.v4_2.default_website_style
erpnext.patches.v4_2.set_company_country
erpnext.patches.v4_2.update_sales_order_invoice_field_name
erpnext.patches.v4_2.seprate_manufacture_and_repack
execute:frappe.delete_doc("Report", "Warehouse-Wise Stock Balance")
execute:frappe.delete_doc("DocType", "Purchase Request")
execute:frappe.delete_doc("DocType", "Purchase Request Item")
erpnext.patches.v4_2.recalculate_bom_cost
erpnext.patches.v4_2.fix_gl_entries_for_stock_transactions
erpnext.patches.v4_2.update_requested_and_ordered_qty #2021-03-31
execute:frappe.rename_doc("DocType", "Support Ticket", "Issue", force=True)
erpnext.patches.v4_4.make_email_accounts
execute:frappe.delete_doc("DocType", "Contact Control")
erpnext.patches.v4_2.discount_amount
erpnext.patches.v4_2.reset_bom_costs
erpnext.patches.v5_0.update_frozen_accounts_permission_role
erpnext.patches.v5_0.update_dn_against_doc_fields
execute:frappe.db.sql("update `tabMaterial Request` set material_request_type = 'Material Transfer' where material_request_type = 'Transfer'")
execute:frappe.reload_doc('stock', 'doctype', 'item')
erpnext.patches.v5_0.set_default_company_in_bom
execute:frappe.reload_doc('crm', 'doctype', 'lead')
execute:frappe.reload_doc('crm', 'doctype', 'opportunity')
erpnext.patches.v5_0.rename_taxes_and_charges_master
erpnext.patches.v5_1.sales_bom_rename
erpnext.patches.v5_0.rename_table_fieldnames
execute:frappe.db.sql("update `tabJournal Entry` set voucher_type='Journal Entry' where ifnull(voucher_type, '')=''")
erpnext.patches.v5_0.is_group
erpnext.patches.v4_2.party_model
erpnext.patches.v5_0.party_model_patch_fix
erpnext.patches.v4_1.fix_jv_remarks
erpnext.patches.v4_2.update_landed_cost_voucher
erpnext.patches.v4_2.set_item_has_batch
erpnext.patches.v4_2.update_stock_uom_for_dn_in_sle
erpnext.patches.v5_0.recalculate_total_amount_in_jv
erpnext.patches.v5_0.update_companywise_payment_account
erpnext.patches.v5_0.remove_birthday_events
erpnext.patches.v5_0.update_item_name_in_bom
erpnext.patches.v5_0.rename_customer_issue
erpnext.patches.v5_0.rename_total_fields
erpnext.patches.v5_0.new_crm_module
erpnext.patches.v5_0.rename_customer_issue
erpnext.patches.v5_0.update_material_transfer_for_manufacture
execute:frappe.reload_doc('crm', 'doctype', 'opportunity_item')
erpnext.patches.v5_0.update_item_description_and_image
erpnext.patches.v5_0.update_material_transferred_for_manufacturing
erpnext.patches.v5_0.stock_entry_update_value
erpnext.patches.v5_0.convert_stock_reconciliation
erpnext.patches.v5_0.update_projects
erpnext.patches.v5_0.item_patches
erpnext.patches.v5_0.update_journal_entry_title
erpnext.patches.v5_0.taxes_and_totals_in_party_currency
erpnext.patches.v5_0.replace_renamed_fields_in_custom_scripts_and_print_formats
erpnext.patches.v5_0.update_from_bom
erpnext.patches.v5_0.update_account_types
erpnext.patches.v5_0.update_sms_sender
erpnext.patches.v5_0.set_appraisal_remarks
erpnext.patches.v5_0.update_time_log_title
erpnext.patches.v7_0.create_warehouse_nestedset
erpnext.patches.v7_0.merge_account_type_stock_and_warehouse_to_stock
erpnext.patches.v7_0.set_is_group_for_warehouse
erpnext.patches.v7_2.stock_uom_in_selling
erpnext.patches.v4_2.repost_sle_for_si_with_no_warehouse
erpnext.patches.v5_0.newsletter
execute:frappe.delete_doc("DocType", "Chart of Accounts")
execute:frappe.delete_doc("DocType", "Style Settings")
erpnext.patches.v5_0.update_opportunity
erpnext.patches.v5_0.opportunity_not_submittable
execute:frappe.permissions.reset_perms("Purchase Taxes and Charges Template") #2014-06-09
execute:frappe.permissions.reset_perms("Expense Claim Type") #2014-06-19
erpnext.patches.v5_0.execute_on_doctype_update
erpnext.patches.v4_2.fix_recurring_orders
erpnext.patches.v4_2.delete_gl_entries_for_cancelled_invoices
erpnext.patches.v5_0.project_costing
erpnext.patches.v5_0.update_temporary_account
erpnext.patches.v5_0.update_advance_paid
erpnext.patches.v5_0.link_warehouse_with_account
execute:frappe.delete_doc("Page", "stock-ledger")
execute:frappe.delete_doc("Page","stock-level")
erpnext.patches.v5_0.reclculate_planned_operating_cost_in_production_order
erpnext.patches.v5_0.repost_requested_qty
erpnext.patches.v5_0.fix_taxes_and_totals_in_party_currency
erpnext.patches.v5_0.update_tax_amount_after_discount_in_purchase_cycle
erpnext.patches.v5_0.rename_pos_setting
erpnext.patches.v5_0.update_operation_description
erpnext.patches.v5_0.set_footer_address
execute:frappe.db.set_value("Backup Manager", None, "send_backups_to_dropbox", 1 if frappe.db.get_value("Backup Manager", None, "upload_backups_to_dropbox") in ("Daily", "Weekly") else 0)
execute:frappe.db.sql_list("delete from `tabDocPerm` where parent='Issue' and modified_by='Administrator' and role='Guest'")
erpnext.patches.v5_0.update_item_and_description_again
erpnext.patches.v6_0.multi_currency
erpnext.patches.v7_0.create_budget_record
erpnext.patches.v5_0.repost_gle_for_jv_with_multiple_party
erpnext.patches.v5_0.portal_fixes
erpnext.patches.v5_0.reset_values_in_tools # 02-05-2016
execute:frappe.delete_doc("Page", "users")
erpnext.patches.v5_0.update_material_transferred_for_manufacturing_again
erpnext.patches.v5_0.index_on_account_and_gl_entry
execute:frappe.db.sql("""delete from `tabProject Task`""")
erpnext.patches.v5_0.update_item_desc_in_invoice
erpnext.patches.v5_1.fix_against_account
execute:frappe.rename_doc("DocType", "Salary Manager", "Process Payroll", force=True)
erpnext.patches.v5_1.rename_roles
erpnext.patches.v5_1.default_bom
execute:frappe.delete_doc("DocType", "Party Type")
execute:frappe.delete_doc("Module Def", "Contacts")
erpnext.patches.v5_4.fix_reserved_qty_and_sle_for_packed_items # 30-07-2015
execute:frappe.reload_doctype("Leave Type")
execute:frappe.db.sql("update `tabLeave Type` set include_holiday=0")
erpnext.patches.v5_4.set_root_and_report_type
erpnext.patches.v5_4.notify_system_managers_regarding_wrong_tax_calculation
erpnext.patches.v5_4.fix_invoice_outstanding
execute:frappe.db.sql("update `tabStock Ledger Entry` set stock_queue = '[]' where voucher_type = 'Stock Reconciliation' and ifnull(qty_after_transaction, 0) = 0")
erpnext.patches.v5_4.fix_missing_item_images
erpnext.patches.v5_4.stock_entry_additional_costs
erpnext.patches.v5_4.cleanup_journal_entry #2015-08-14
erpnext.patches.v5_7.update_item_description_based_on_item_master
erpnext.patches.v5_7.item_template_attributes
execute:frappe.delete_doc_if_exists("DocType", "Manage Variants")
execute:frappe.delete_doc_if_exists("DocType", "Manage Variants Item")
erpnext.patches.v4_2.repost_reserved_qty #2021-03-31
erpnext.patches.v5_4.update_purchase_cost_against_project
erpnext.patches.v5_8.update_order_reference_in_return_entries
erpnext.patches.v5_8.add_credit_note_print_heading
execute:frappe.delete_doc_if_exists("Print Format", "Credit Note - Negative Invoice")
# V6.0
erpnext.patches.v6_0.set_default_title # 2015-09-03
erpnext.patches.v6_0.default_activity_rate
execute:frappe.db.set_value("Stock Settings", None, "automatically_set_serial_nos_based_on_fifo", 1)
execute:frappe.db.sql("""update `tabProject` set percent_complete=round(percent_complete, 2) where percent_complete is not null""")
erpnext.patches.v6_0.fix_outstanding_amount
erpnext.patches.v6_0.fix_planned_qty
erpnext.patches.v6_2.remove_newsletter_duplicates
erpnext.patches.v6_2.fix_missing_default_taxes_and_lead
erpnext.patches.v6_3.convert_applicable_territory
erpnext.patches.v6_4.round_status_updater_percentages
erpnext.patches.v6_4.repost_gle_for_journal_entries_where_reference_name_missing
erpnext.patches.v6_4.fix_journal_entries_due_to_reconciliation
erpnext.patches.v6_4.fix_status_in_sales_and_purchase_order
erpnext.patches.v6_4.fix_modified_in_sales_order_and_purchase_order
erpnext.patches.v6_4.fix_duplicate_bins
erpnext.patches.v6_4.fix_sales_order_maintenance_status
erpnext.patches.v6_4.email_digest_update
# delete shopping cart doctypes
execute:frappe.delete_doc_if_exists("DocType", "Applicable Territory")
execute:frappe.delete_doc_if_exists("DocType", "Shopping Cart Price List")
execute:frappe.delete_doc_if_exists("DocType", "Shopping Cart Taxes and Charges Master")
erpnext.patches.v6_4.set_user_in_contact
erpnext.patches.v6_4.make_image_thumbnail #2015-10-20
erpnext.patches.v6_5.show_in_website_for_template_item
erpnext.patches.v6_4.fix_expense_included_in_valuation
execute:frappe.delete_doc_if_exists("Report", "Item-wise Last Purchase Rate")
erpnext.patches.v6_6.fix_website_image
erpnext.patches.v6_6.remove_fiscal_year_from_leave_allocation
execute:frappe.delete_doc_if_exists("DocType", "Stock UOM Replace Utility")
erpnext.patches.v6_8.make_webform_standard #2015-11-23
erpnext.patches.v6_8.move_drop_ship_to_po_items
erpnext.patches.v6_10.fix_ordered_received_billed
erpnext.patches.v6_10.fix_jv_total_amount #2015-11-30
erpnext.patches.v6_10.email_digest_default_quote
erpnext.patches.v6_10.fix_billed_amount_in_drop_ship_po
erpnext.patches.v6_10.fix_delivery_status_of_drop_ship_item #2015-12-08
erpnext.patches.v5_8.tax_rule #2015-12-08
erpnext.patches.v6_12.set_overdue_tasks
erpnext.patches.v6_16.update_billing_status_in_dn_and_pr
erpnext.patches.v6_16.create_manufacturer_records
execute:frappe.db.sql("update `tabPricing Rule` set title=name where title='' or title is null") #2016-01-27
erpnext.patches.v6_20.set_party_account_currency_in_orders
erpnext.patches.v6_19.comment_feed_communication
erpnext.patches.v6_21.fix_reorder_level
erpnext.patches.v6_21.rename_material_request_fields
erpnext.patches.v6_23.update_stopped_status_to_closed
erpnext.patches.v6_24.set_recurring_id
erpnext.patches.v6_20x.set_compact_print
execute:frappe.delete_doc_if_exists("Web Form", "contact") #2016-03-10
erpnext.patches.v6_20x.remove_fiscal_year_from_holiday_list
erpnext.patches.v6_24.map_customer_address_to_shipping_address_on_po
erpnext.patches.v6_27.fix_recurring_order_status
erpnext.patches.v6_20x.update_product_bundle_description
erpnext.patches.v7_0.update_party_status #2016-09-22
erpnext.patches.v7_0.remove_features_setup
erpnext.patches.v7_0.update_home_page
execute:frappe.delete_doc_if_exists("Page", "financial-analytics")
erpnext.patches.v7_0.update_project_in_gl_entry
execute:frappe.db.sql('update tabQuotation set status="Cancelled" where docstatus=2')
execute:frappe.rename_doc("DocType", "Payments", "Sales Invoice Payment", force=True)
erpnext.patches.v7_0.update_mins_to_first_response
erpnext.patches.v6_20x.repost_valuation_rate_for_negative_inventory
erpnext.patches.v7_0.migrate_mode_of_payments_v6_to_v7
erpnext.patches.v7_0.system_settings_setup_complete
erpnext.patches.v7_0.set_naming_series_for_timesheet #2016-07-27
execute:frappe.reload_doc('projects', 'doctype', 'project')
execute:frappe.reload_doc('projects', 'doctype', 'project_user')
erpnext.patches.v7_0.convert_timelogbatch_to_timesheet
erpnext.patches.v7_0.convert_timelog_to_timesheet
erpnext.patches.v7_0.move_timelogbatch_from_salesinvoiceitem_to_salesinvoicetimesheet
erpnext.patches.v7_0.remove_doctypes_and_reports #2016-10-29
erpnext.patches.v7_0.update_maintenance_module_in_doctype
erpnext.patches.v7_0.update_prevdoc_values_for_supplier_quotation_item
erpnext.patches.v7_0.rename_advance_table_fields
erpnext.patches.v7_0.rename_salary_components
erpnext.patches.v7_0.rename_prevdoc_fields
erpnext.patches.v7_0.rename_time_sheet_doctype
execute:frappe.delete_doc_if_exists("Report", "Customers Not Buying Since Long Time")
erpnext.patches.v7_0.make_is_group_fieldtype_as_check
execute:frappe.reload_doc('projects', 'doctype', 'timesheet') #2016-09-12
erpnext.patches.v7_1.rename_field_timesheet
execute:frappe.delete_doc_if_exists("Report", "Employee Holiday Attendance")
execute:frappe.delete_doc_if_exists("DocType", "Payment Tool")
execute:frappe.delete_doc_if_exists("DocType", "Payment Tool Detail")
erpnext.patches.v7_0.setup_account_table_for_expense_claim_type_if_exists
erpnext.patches.v7_0.migrate_schools_to_erpnext
erpnext.patches.v7_1.update_lead_source
erpnext.patches.v6_20x.remove_customer_supplier_roles
erpnext.patches.v7_0.remove_administrator_role_in_doctypes
erpnext.patches.v7_0.rename_fee_amount_to_fee_component
erpnext.patches.v7_0.calculate_total_costing_amount
erpnext.patches.v7_0.fix_nonwarehouse_ledger_gl_entries_for_transactions
erpnext.patches.v7_0.remove_old_earning_deduction_doctypes
erpnext.patches.v7_0.make_guardian
erpnext.patches.v7_0.update_refdoc_in_landed_cost_voucher
erpnext.patches.v7_0.set_material_request_type_in_item
erpnext.patches.v7_0.rename_examination_to_assessment
erpnext.patches.v7_0.set_portal_settings
erpnext.patches.v7_0.update_change_amount_account
erpnext.patches.v7_0.fix_duplicate_icons
erpnext.patches.v7_0.repost_gle_for_pos_sales_return
erpnext.patches.v7_1.update_total_billing_hours
erpnext.patches.v7_1.update_component_type
erpnext.patches.v7_0.repost_gle_for_pos_sales_return
erpnext.patches.v7_0.update_missing_employee_in_timesheet
erpnext.patches.v7_0.update_status_for_timesheet
erpnext.patches.v7_0.set_party_name_in_payment_entry
erpnext.patches.v7_1.set_student_guardian
erpnext.patches.v7_0.update_conversion_factor_in_supplier_quotation_item
erpnext.patches.v7_1.move_sales_invoice_from_parent_to_child_timesheet
execute:frappe.db.sql("update `tabTimesheet` ts, `tabEmployee` emp set ts.employee_name = emp.employee_name where emp.name = ts.employee and ts.employee_name is null and ts.employee is not null")
erpnext.patches.v7_1.fix_link_for_customer_from_lead
execute:frappe.db.sql("delete from `tabTimesheet Detail` where NOT EXISTS (select name from `tabTimesheet` where name = `tabTimesheet Detail`.parent)")
erpnext.patches.v7_0.update_mode_of_payment_type
execute:frappe.reload_doctype('Employee') #2016-10-18
execute:frappe.db.sql("update `tabEmployee` set prefered_contact_email = IFNULL(prefered_contact_email,'') ")
execute:frappe.reload_doc("Payroll", "doctype", "salary_slip")
execute:frappe.db.sql("update `tabSalary Slip` set posting_date=creation")
execute:frappe.reload_doc("stock", "doctype", "stock_settings")
erpnext.patches.v8_0.create_domain_docs #16-05-2017
erpnext.patches.v7_1.update_portal_roles
erpnext.patches.v7_1.set_total_amount_currency_in_je
finally:erpnext.patches.v7_0.update_timesheet_communications
erpnext.patches.v7_0.update_status_of_zero_amount_sales_order
erpnext.patches.v7_1.add_field_for_task_dependent
erpnext.patches.v7_0.repost_bin_qty_and_item_projected_qty
erpnext.patches.v7_1.set_prefered_contact_email
execute:frappe.reload_doc('accounts', 'doctype', 'accounts_settings')
execute:frappe.db.set_value("Accounts Settings", "Accounts Settings", "unlink_payment_on_cancellation_of_invoice", 0)
execute:frappe.db.sql("update `tabStock Entry` set total_amount = 0 where purpose in('Repack', 'Manufacture')")
erpnext.patches.v7_1.save_stock_settings
erpnext.patches.v7_0.repost_gle_for_pi_with_update_stock #2016-11-01
erpnext.patches.v7_1.add_account_user_role_for_timesheet
erpnext.patches.v7_0.set_base_amount_in_invoice_payment_table
erpnext.patches.v7_1.update_invoice_status
erpnext.patches.v7_0.po_status_issue_for_pr_return
erpnext.patches.v7_1.update_missing_salary_component_type
erpnext.patches.v7_1.rename_quality_inspection_field
erpnext.patches.v7_0.update_autoname_field
erpnext.patches.v7_1.update_bom_base_currency
erpnext.patches.v7_0.update_status_of_po_so
erpnext.patches.v7_1.set_budget_against_as_cost_center
erpnext.patches.v7_1.set_currency_exchange_date
erpnext.patches.v7_1.set_sales_person_status
erpnext.patches.v7_1.repost_stock_for_deleted_bins_for_merging_items
erpnext.patches.v7_2.update_website_for_variant
erpnext.patches.v7_2.update_assessment_modules
erpnext.patches.v7_2.update_doctype_status
erpnext.patches.v7_2.update_salary_slips
erpnext.patches.v7_2.delete_fleet_management_module_def
erpnext.patches.v7_2.contact_address_links
erpnext.patches.v7_2.mark_students_active
erpnext.patches.v7_2.set_null_value_to_fields
erpnext.patches.v7_2.update_guardian_name_in_student_master
erpnext.patches.v7_2.update_abbr_in_salary_slips
erpnext.patches.v7_2.rename_evaluation_criteria
erpnext.patches.v7_2.update_party_type
erpnext.patches.v7_2.setup_auto_close_settings
erpnext.patches.v7_2.empty_supplied_items_for_non_subcontracted
erpnext.patches.v7_2.arrear_leave_encashment_as_salary_component
erpnext.patches.v7_2.rename_att_date_attendance
erpnext.patches.v7_2.update_attendance_docstatus
erpnext.patches.v7_2.make_all_assessment_group
erpnext.patches.v8_0.repost_reserved_qty_for_multiple_sales_uom
erpnext.patches.v8_0.addresses_linked_to_lead
execute:frappe.delete_doc('DocType', 'Purchase Common')
erpnext.patches.v8_0.update_stock_qty_value_in_purchase_invoice
erpnext.patches.v8_0.update_supplier_address_in_stock_entry
erpnext.patches.v8_0.rename_is_sample_item_to_allow_zero_valuation_rate
erpnext.patches.v8_0.set_null_to_serial_nos_for_disabled_sales_invoices
erpnext.patches.v8_0.enable_booking_asset_depreciation_automatically
erpnext.patches.v8_0.set_project_copied_from
erpnext.patches.v8_0.update_status_as_paid_for_completed_expense_claim
erpnext.patches.v7_2.stock_uom_in_selling
erpnext.patches.v8_0.revert_manufacturers_table_from_item
erpnext.patches.v8_0.disable_instructor_role
erpnext.patches.v8_0.merge_student_batch_and_student_group
erpnext.patches.v8_0.rename_total_margin_to_rate_with_margin # 11-05-2017
erpnext.patches.v8_0.fix_status_for_invoices_with_negative_outstanding
erpnext.patches.v8_0.make_payments_table_blank_for_non_pos_invoice
erpnext.patches.v8_0.set_sales_invoice_serial_number_from_delivery_note
erpnext.patches.v8_0.delete_schools_depricated_doctypes
erpnext.patches.v8_0.update_customer_pos_id
erpnext.patches.v8_0.rename_items_in_status_field_of_material_request
erpnext.patches.v8_0.delete_bin_indexes
erpnext.patches.v8_0.move_account_head_from_account_to_warehouse_for_inventory
erpnext.patches.v8_0.change_in_words_varchar_length
erpnext.patches.v8_0.update_stock_qty_value_in_bom_item
erpnext.patches.v8_0.update_sales_cost_in_project
erpnext.patches.v8_0.save_system_settings
erpnext.patches.v8_1.delete_deprecated_reports
erpnext.patches.v9_0.remove_subscription_module
erpnext.patches.v8_7.make_subscription_from_recurring_data
erpnext.patches.v8_1.setup_gst_india #2017-06-27
execute:frappe.reload_doc('regional', 'doctype', 'gst_hsn_code')
erpnext.patches.v8_1.removed_roles_from_gst_report_non_indian_account #16-08-2018
erpnext.patches.v8_1.gst_fixes #2017-07-06
erpnext.patches.v8_0.update_production_orders
erpnext.patches.v8_1.remove_sales_invoice_from_returned_serial_no
erpnext.patches.v8_1.allow_invoice_copy_to_edit_after_submit
erpnext.patches.v8_1.add_hsn_sac_codes
erpnext.patches.v8_1.update_gst_state #17-07-2017
erpnext.patches.v8_1.removed_report_support_hours
erpnext.patches.v8_1.add_indexes_in_transaction_doctypes
erpnext.patches.v8_3.set_restrict_to_domain_for_module_def
erpnext.patches.v8_1.update_expense_claim_status
erpnext.patches.v8_3.update_company_total_sales #2017-08-16
erpnext.patches.v8_4.make_scorecard_records
erpnext.patches.v8_1.set_delivery_date_in_so_item #2017-07-28
erpnext.patches.v8_5.fix_tax_breakup_for_non_invoice_docs
erpnext.patches.v8_5.remove_quotations_route_in_sidebar
erpnext.patches.v8_5.update_existing_data_in_project_type
erpnext.patches.v8_5.set_default_mode_of_payment
erpnext.patches.v8_5.update_customer_group_in_POS_profile
erpnext.patches.v8_6.update_timesheet_company_from_PO
erpnext.patches.v8_6.set_write_permission_for_quotation_for_sales_manager
erpnext.patches.v8_5.remove_project_type_property_setter
erpnext.patches.v8_7.sync_india_custom_fields
erpnext.patches.v8_7.fix_purchase_receipt_status
erpnext.patches.v8_6.rename_bom_update_tool
erpnext.patches.v8_9.add_setup_progress_actions #08-09-2017 #26-09-2017 #22-11-2017 #15-12-2017
erpnext.patches.v8_9.rename_company_sales_target_field
erpnext.patches.v8_8.set_bom_rate_as_per_uom
erpnext.patches.v8_8.add_new_fields_in_accounts_settings
erpnext.patches.v8_9.set_default_customer_group
erpnext.patches.v8_9.delete_gst_doctypes_for_outside_india_accounts
erpnext.patches.v8_9.set_default_fields_in_variant_settings
erpnext.patches.v8_9.update_billing_gstin_for_indian_account
erpnext.patches.v8_9.set_member_party_type
erpnext.patches.v9_0.add_user_to_child_table_in_pos_profile
erpnext.patches.v9_0.set_schedule_date_for_material_request_and_purchase_order
erpnext.patches.v9_0.student_admission_childtable_migrate
erpnext.patches.v9_0.add_healthcare_domain
erpnext.patches.v9_0.set_variant_item_description
erpnext.patches.v9_0.set_uoms_in_variant_field
erpnext.patches.v9_0.copy_old_fees_field_data
execute:frappe.delete_doc_if_exists("DocType", "Program Fee")
erpnext.patches.v9_0.set_pos_profile_name
erpnext.patches.v9_0.remove_non_existing_warehouse_from_stock_settings
execute:frappe.delete_doc_if_exists("DocType", "Program Fee")
erpnext.patches.v8_10.change_default_customer_credit_days
erpnext.patches.v9_0.update_employee_loan_details
erpnext.patches.v9_2.delete_healthcare_domain_default_items
erpnext.patches.v9_1.create_issue_opportunity_type
erpnext.patches.v9_2.rename_translated_domains_in_en
erpnext.patches.v9_0.set_shipping_type_for_existing_shipping_rules
erpnext.patches.v9_0.update_multi_uom_fields_in_material_request
erpnext.patches.v9_2.repost_reserved_qty_for_production
erpnext.patches.v9_2.remove_company_from_patient
erpnext.patches.v9_2.set_item_name_in_production_order
erpnext.patches.v10_0.update_lft_rgt_for_employee
erpnext.patches.v9_2.rename_net_weight_in_item_master
erpnext.patches.v9_2.delete_process_payroll
erpnext.patches.v10_0.add_agriculture_domain
erpnext.patches.v10_0.add_non_profit_domain
erpnext.patches.v10_0.setup_vat_for_uae_and_saudi_arabia #2017-12-28
erpnext.patches.v10_0.set_primary_contact_for_customer
erpnext.patches.v10_0.copy_projects_renamed_fields
erpnext.patches.v10_0.enabled_regional_print_format_based_on_country
erpnext.patches.v10_0.update_asset_calculate_depreciation
erpnext.patches.v10_0.add_guardian_role_for_parent_portal
erpnext.patches.v10_0.set_numeric_ranges_in_template_if_blank
erpnext.patches.v10_0.update_reserved_qty_for_purchase_order
erpnext.patches.v10_0.fichier_des_ecritures_comptables_for_france
erpnext.patches.v10_0.update_assessment_plan
erpnext.patches.v10_0.update_assessment_result
erpnext.patches.v10_0.set_default_payment_terms_based_on_company
erpnext.patches.v10_0.update_sales_order_link_to_purchase_order
erpnext.patches.v10_0.rename_price_to_rate_in_pricing_rule
erpnext.patches.v10_0.set_currency_in_pricing_rule
erpnext.patches.v10_0.set_b2c_limit
erpnext.patches.v10_0.update_translatable_fields
erpnext.patches.v10_0.rename_offer_letter_to_job_offer
execute:frappe.delete_doc('DocType', 'Production Planning Tool', ignore_missing=True)
@ -496,16 +21,6 @@ erpnext.patches.v10_0.migrate_daily_work_summary_settings_to_daily_work_summary_
erpnext.patches.v10_0.add_default_cash_flow_mappers
erpnext.patches.v11_0.rename_duplicate_item_code_values
erpnext.patches.v11_0.make_quality_inspection_template
erpnext.patches.v10_0.update_status_for_multiple_source_in_po
erpnext.patches.v10_0.set_auto_created_serial_no_in_stock_entry
erpnext.patches.v10_0.update_territory_and_customer_group
erpnext.patches.v10_0.update_warehouse_address_details
erpnext.patches.v10_0.update_reserved_qty_for_purchase_order
erpnext.patches.v10_0.update_hub_connector_domain
erpnext.patches.v10_0.set_student_party_type
erpnext.patches.v10_0.update_project_in_sle
erpnext.patches.v10_0.fix_reserved_qty_for_sub_contract
erpnext.patches.v10_0.repost_requested_qty_for_non_stock_uom_items
erpnext.patches.v11_0.merge_land_unit_with_location
erpnext.patches.v11_0.add_index_on_nestedset_doctypes
erpnext.patches.v11_0.remove_modules_setup_page
@ -514,7 +29,6 @@ erpnext.patches.v11_0.update_department_lft_rgt
erpnext.patches.v11_0.add_default_email_template_for_leave
erpnext.patches.v11_0.set_default_email_template_in_hr #08-06-2018
erpnext.patches.v11_0.uom_conversion_data #30-06-2018
erpnext.patches.v10_0.taxes_issue_with_pos
erpnext.patches.v11_0.update_account_type_in_party_type
erpnext.patches.v11_0.rename_healthcare_doctype_and_fields
erpnext.patches.v11_0.rename_supplier_type_to_supplier_group
@ -522,8 +36,6 @@ erpnext.patches.v10_1.transfer_subscription_to_auto_repeat
erpnext.patches.v11_0.update_brand_in_item_price
erpnext.patches.v11_0.create_default_success_action
erpnext.patches.v11_0.add_healthcare_service_unit_tree_root
erpnext.patches.v10_0.set_qty_in_transactions_based_on_serial_no_input
erpnext.patches.v10_0.show_leaves_of_all_department_members_in_calendar
erpnext.patches.v11_0.rename_field_max_days_allowed
erpnext.patches.v11_0.create_salary_structure_assignments
erpnext.patches.v11_0.rename_health_insurance
@ -536,7 +48,6 @@ erpnext.patches.v11_0.move_item_defaults_to_child_table_for_multicompany #02-07-
erpnext.patches.v11_0.refactor_erpnext_shopify #2018-09-07
erpnext.patches.v11_0.rename_overproduction_percent_field
erpnext.patches.v11_0.update_backflush_subcontract_rm_based_on_bom
erpnext.patches.v10_0.update_status_in_purchase_receipt
erpnext.patches.v11_0.inter_state_field_for_gst
erpnext.patches.v11_0.rename_members_with_naming_series #04-06-2018
erpnext.patches.v11_0.set_update_field_and_value_in_workflow_state
@ -550,13 +61,10 @@ erpnext.patches.v11_0.skip_user_permission_check_for_department
erpnext.patches.v11_0.set_department_for_doctypes
erpnext.patches.v11_0.update_allow_transfer_for_manufacture
erpnext.patches.v11_0.add_item_group_defaults
erpnext.patches.v10_0.update_address_template_for_india
erpnext.patches.v11_0.add_expense_claim_default_account
execute:frappe.delete_doc("Page", "hub")
erpnext.patches.v11_0.reset_publish_in_hub_for_all_items
erpnext.patches.v11_0.update_hub_url # 2018-08-31 # 2018-09-03
erpnext.patches.v10_0.set_discount_amount
erpnext.patches.v10_0.recalculate_gross_margin_for_project
erpnext.patches.v11_0.make_job_card
erpnext.patches.v11_0.redesign_healthcare_billing_work_flow
erpnext.patches.v10_0.delete_hub_documents # 12-08-2018
@ -570,9 +78,6 @@ execute:frappe.delete_doc_if_exists("Page", "stock-analytics")
execute:frappe.delete_doc_if_exists("Page", "production-analytics")
erpnext.patches.v11_0.ewaybill_fields_gst_india #2018-11-13 #2019-01-09 #2019-04-01 #2019-04-26 #2019-05-03
erpnext.patches.v11_0.drop_column_max_days_allowed
erpnext.patches.v10_0.update_user_image_in_employee
erpnext.patches.v10_0.repost_gle_for_purchase_receipts_with_rejected_items
erpnext.patches.v10_0.allow_operators_in_supplier_scorecard
erpnext.patches.v10_0.item_barcode_childtable_migrate # 16-02-2019
erpnext.patches.v11_0.update_delivery_trip_status
erpnext.patches.v11_0.set_missing_gst_hsn_code

View File

@ -1,13 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
from erpnext.stock.stock_balance import set_stock_balance_as_per_serial_no
frappe.db.auto_commit_on_many_writes = 1
set_stock_balance_as_per_serial_no()
frappe.db.auto_commit_on_many_writes = 0

View File

@ -1,13 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
domain = 'Agriculture'
if not frappe.db.exists('Domain', domain):
frappe.get_doc({
'doctype': 'Domain',
'domain': domain
}).insert(ignore_permissions=True)

View File

@ -1,23 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
# create guardian role
if not frappe.get_value('Role', dict(role_name='Guardian')):
frappe.get_doc({
'doctype': 'Role',
'role_name': 'Guardian',
'desk_access': 0,
'restrict_to_domain': 'Education'
}).insert(ignore_permissions=True)
# set guardian roles in already created users
if frappe.db.exists("Doctype", "Guardian"):
for user in frappe.db.sql_list("""select u.name from `tabUser` u , `tabGuardian` g where g.email_address = u.name"""):
user = frappe.get_doc('User', user)
user.flags.ignore_validate = True
user.flags.ignore_mandatory = True
user.save()

View File

@ -1,20 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
domain = 'Non Profit'
if not frappe.db.exists('Domain', domain):
frappe.get_doc({
'doctype': 'Domain',
'domain': domain
}).insert(ignore_permissions=True)
frappe.get_doc({
'doctype': 'Role',
'role_name': 'Non Profit Portal User',
'desk_access': 0,
'restrict_to_domain': domain
}).insert(ignore_permissions=True)

View File

@ -1,23 +0,0 @@
# Copyright (c) 2019, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc('buying', 'doctype', 'supplier_scorecard_criteria')
frappe.reload_doc('buying', 'doctype', 'supplier_scorecard_scoring_criteria')
frappe.reload_doc('buying', 'doctype', 'supplier_scorecard')
for criteria in frappe.get_all('Supplier Scorecard Criteria', fields=['name', 'formula'], limit_page_length=None):
frappe.db.set_value('Supplier Scorecard Criteria', criteria.name,
'formula', criteria.formula.replace('&lt;','<').replace('&gt;','>'))
for criteria in frappe.get_all('Supplier Scorecard Scoring Criteria', fields=['name', 'formula'], limit_page_length=None):
if criteria.formula: # not mandatory
frappe.db.set_value('Supplier Scorecard Scoring Criteria', criteria.name,
'formula', criteria.formula.replace('&lt;','<').replace('&gt;','>'))
for sc in frappe.get_all('Supplier Scorecard', fields=['name', 'weighting_function'], limit_page_length=None):
frappe.db.set_value('Supplier Scorecard', sc.name, 'weighting_function',
sc.weighting_function.replace('&lt;','<').replace('&gt;','>'))

View File

@ -1,13 +0,0 @@
from __future__ import unicode_literals
import frappe
from frappe.model.utils.rename_field import rename_field
def execute():
""" copy data from old fields to new """
frappe.reload_doc("projects", "doctype", "project")
if frappe.db.has_column('Project', 'total_sales_cost'):
rename_field('Project', "total_sales_cost", "total_sales_amount")
if frappe.db.has_column('Project', 'total_billing_amount'):
rename_field('Project', "total_billing_amount", "total_billable_amount")

View File

@ -1,22 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
print_format_mapper = {
'India': ['GST POS Invoice', 'GST Tax Invoice'],
'Saudi Arabia': ['Simplified Tax Invoice', 'Detailed Tax Invoice', 'Tax Invoice'],
'United Arab Emirates': ['Simplified Tax Invoice', 'Detailed Tax Invoice', 'Tax Invoice']
}
frappe.db.sql(""" update `tabPrint Format` set disabled = 1 where name
in ('GST POS Invoice', 'GST Tax Invoice', 'Simplified Tax Invoice', 'Detailed Tax Invoice')""")
for d in frappe.get_all('Company', fields = ["country"],
filters={'country': ('in', ['India', 'Saudi Arabia', 'United Arab Emirates'])}):
if print_format_mapper.get(d.country):
print_formats = print_format_mapper.get(d.country)
frappe.db.sql(""" update `tabPrint Format` set disabled = 0
where name in (%s)""" % ", ".join(["%s"]*len(print_formats)), tuple(print_formats))

View File

@ -1,31 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from erpnext.stock.utils import get_bin
def execute():
frappe.reload_doc("stock", "doctype", "bin")
frappe.reload_doc("buying", "doctype", "purchase_order_item_supplied")
for d in frappe.db.sql("""
select distinct rm_item_code, reserve_warehouse
from `tabPurchase Order Item Supplied`
where docstatus=1 and reserve_warehouse is not null and reserve_warehouse != ''"""):
try:
bin_doc = get_bin(d[0], d[1])
bin_doc.update_reserved_qty_for_sub_contracting()
except:
pass
for d in frappe.db.sql("""select distinct item_code, source_warehouse
from `tabWork Order Item`
where docstatus=1 and transferred_qty > required_qty
and source_warehouse is not null and source_warehouse != ''""", as_list=1):
try:
bin_doc = get_bin(d[0], d[1])
bin_doc.update_reserved_qty_for_production()
except:
pass

View File

@ -1,14 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc('projects', 'doctype', 'project')
for d in frappe.db.sql(""" select name from `tabProject` where
ifnull(total_consumed_material_cost, 0 ) > 0 and ifnull(total_billed_amount, 0) > 0""", as_dict=1):
doc = frappe.get_doc("Project", d.name)
doc.calculate_gross_margin()
doc.db_set('gross_margin', doc.gross_margin)
doc.db_set('per_gross_margin', doc.per_gross_margin)

View File

@ -1,32 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
# rename the School module as Education
# rename the school module
if frappe.db.exists('Module Def', 'Schools') and not frappe.db.exists('Module Def', 'Education'):
frappe.rename_doc("Module Def", "Schools", "Education")
# delete the school module
if frappe.db.exists('Module Def', 'Schools') and frappe.db.exists('Module Def', 'Education'):
frappe.db.sql("""delete from `tabModule Def` where module_name = 'Schools'""")
# rename "School Settings" to the "Education Settings
if frappe.db.exists('DocType', 'School Settings'):
frappe.rename_doc("DocType", "School Settings", "Education Settings", force=True)
frappe.reload_doc("education", "doctype", "education_settings")
# delete the discussion web form if exists
if frappe.db.exists('Web Form', 'Discussion'):
frappe.db.sql("""delete from `tabWeb Form` where name = 'discussion'""")
# rename the select option field from "School Bus" to "Institute's Bus"
frappe.reload_doc("education", "doctype", "Program Enrollment")
if "mode_of_transportation" in frappe.db.get_table_columns("Program Enrollment"):
frappe.db.sql("""update `tabProgram Enrollment` set mode_of_transportation = "Institute's Bus"
where mode_of_transportation = "School Bus" """)

View File

@ -1,32 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe, erpnext
def execute():
for company in frappe.get_all("Company"):
if not erpnext.is_perpetual_inventory_enabled(company.name):
continue
acc_frozen_upto = frappe.db.get_value("Accounts Settings", None, "acc_frozen_upto") or "1900-01-01"
pr_with_rejected_warehouse = frappe.db.sql("""
select pr.name
from `tabPurchase Receipt` pr, `tabPurchase Receipt Item` pr_item
where pr.name = pr_item.parent
and pr.posting_date > %s
and pr.docstatus=1
and pr.company = %s
and pr_item.rejected_qty > 0
""", (acc_frozen_upto, company.name), as_dict=1)
for d in pr_with_rejected_warehouse:
doc = frappe.get_doc("Purchase Receipt", d.name)
doc.docstatus = 2
doc.make_gl_entries_on_cancel()
# update gl entries for submit state of PR
doc.docstatus = 1
doc.make_gl_entries()

View File

@ -1,21 +0,0 @@
# Copyright (c) 2019, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
from erpnext.stock.stock_balance import update_bin_qty, get_indented_qty
count=0
for item_code, warehouse in frappe.db.sql("""select distinct item_code, warehouse
from `tabMaterial Request Item` where docstatus = 1 and stock_uom<>uom"""):
try:
count += 1
update_bin_qty(item_code, warehouse, {
"indented_qty": get_indented_qty(item_code, warehouse),
})
if count % 200 == 0:
frappe.db.commit()
except:
frappe.db.rollback()

View File

@ -1,56 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
serialised_items = [d.name for d in frappe.get_all("Item", filters={"has_serial_no": 1})]
if not serialised_items:
return
for dt in ["Stock Entry Detail", "Purchase Receipt Item", "Purchase Invoice Item"]:
cond = ""
if dt=="Purchase Invoice Item":
cond = """ and parent in (select name from `tabPurchase Invoice`
where `tabPurchase Invoice`.name = `tabPurchase Invoice Item`.parent and update_stock=1)"""
item_rows = frappe.db.sql("""
select name
from `tab{0}`
where conversion_factor != 1
and docstatus = 1
and ifnull(serial_no, '') = ''
and item_code in ({1})
{2}
""".format(dt, ', '.join(['%s']*len(serialised_items)), cond), tuple(serialised_items))
if item_rows:
sle_serial_nos = dict(frappe.db.sql("""
select voucher_detail_no, serial_no
from `tabStock Ledger Entry`
where ifnull(serial_no, '') != ''
and voucher_detail_no in (%s)
""".format(', '.join(['%s']*len(item_rows))),
tuple([d[0] for d in item_rows])))
batch_size = 100
for i in range(0, len(item_rows), batch_size):
batch_item_rows = item_rows[i:i + batch_size]
when_then = []
for item_row in batch_item_rows:
when_then.append('WHEN `name` = "{row_name}" THEN "{value}"'.format(
row_name=item_row[0],
value=sle_serial_nos.get(item_row[0])))
frappe.db.sql("""
update
`tab{doctype}`
set
serial_no = CASE {when_then_cond} ELSE `serial_no` END
""".format(
doctype = dt,
when_then_cond=" ".join(when_then)
))

View File

@ -1,12 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc("regional", "doctype", "gst_settings")
frappe.reload_doc("accounts", "doctype", "gst_account")
gst_settings = frappe.get_doc("GST Settings")
gst_settings.b2c_limit = 250000
gst_settings.save()

View File

@ -1,37 +0,0 @@
from __future__ import unicode_literals
import frappe
from erpnext.patches.v8_10.change_default_customer_credit_days import make_payment_term, make_template
def execute():
for dt in ("Company", "Customer Group"):
frappe.reload_doc("setup", "doctype", frappe.scrub(dt))
credit_records = frappe.db.sql("""
SELECT DISTINCT `credit_days`, `credit_days_based_on`, `name`
from `tab{0}`
where
((credit_days_based_on='Fixed Days' or credit_days_based_on is null) and credit_days is not null)
or credit_days_based_on='Last Day of the Next Month'
""".format(dt), as_dict=1)
for d in credit_records:
template = create_payment_terms_template(d)
frappe.db.sql("""
update `tab{0}`
set `payment_terms` = %s
where name = %s
""".format(dt), (template.name, d.name))
def create_payment_terms_template(data):
if data.credit_days_based_on == "Fixed Days":
pyt_template_name = 'Default Payment Term - N{0}'.format(data.credit_days)
else:
pyt_template_name = 'Default Payment Term - EO2M'
if not frappe.db.exists("Payment Terms Template", pyt_template_name):
payment_term = make_payment_term(data.credit_days, data.credit_days_based_on)
template = make_template(payment_term)
else:
template = frappe.get_doc("Payment Terms Template", pyt_template_name)
return template

View File

@ -1,35 +0,0 @@
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc("accounts", "doctype", "sales_invoice_item")
frappe.reload_doc('accounts', 'doctype', 'purchase_invoice_item')
frappe.reload_doc('buying', 'doctype', 'purchase_order_item')
frappe.reload_doc('buying', 'doctype', 'supplier_quotation_item')
frappe.reload_doc('selling', 'doctype', 'sales_order_item')
frappe.reload_doc('selling', 'doctype', 'quotation_item')
frappe.reload_doc('stock', 'doctype', 'delivery_note_item')
frappe.reload_doc('stock', 'doctype', 'purchase_receipt_item')
selling_doctypes = ["Sales Order Item", "Sales Invoice Item", "Delivery Note Item", "Quotation Item"]
buying_doctypes = ["Purchase Order Item", "Purchase Invoice Item", "Purchase Receipt Item", "Supplier Quotation Item"]
for doctype in selling_doctypes:
frappe.db.sql('''
UPDATE
`tab%s`
SET
discount_amount = if(rate_with_margin > 0, rate_with_margin, price_list_rate) * discount_percentage / 100
WHERE
discount_percentage > 0
''' % (doctype))
for doctype in buying_doctypes:
frappe.db.sql('''
UPDATE
`tab%s`
SET
discount_amount = price_list_rate * discount_percentage / 100
WHERE
discount_percentage > 0
''' % (doctype))

View File

@ -1,35 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
item_numeric_attributes = frappe.db.sql("""
select name, numeric_values, from_range, to_range, increment
from `tabItem Attribute`
where numeric_values = 1
""", as_dict=1)
for d in item_numeric_attributes:
frappe.db.sql("""
update `tabItem Variant Attribute`
set
from_range = CASE
WHEN from_range = 0 THEN %(from_range)s
ELSE from_range
END,
to_range = CASE
WHEN to_range = 0 THEN %(to_range)s
ELSE to_range
END,
increment = CASE
WHEN increment = 0 THEN %(increment)s
ELSE increment
END,
numeric_values = %(numeric_values)s
where
attribute = %(name)s
and exists(select name from tabItem
where name=`tabItem Variant Attribute`.parent and has_variants=1)
""", d)

View File

@ -1,21 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doctype('Customer')
frappe.db.sql("""
update
`tabCustomer`, (
select `tabContact`.name, `tabContact`.mobile_no, `tabContact`.email_id,
`tabDynamic Link`.link_name from `tabContact`, `tabDynamic Link`
where `tabContact`.name = `tabDynamic Link`.parent and
`tabDynamic Link`.link_doctype = 'Customer' and `tabContact`.is_primary_contact = 1
) as contact
set
`tabCustomer`.customer_primary_contact = contact.name,
`tabCustomer`.mobile_no = contact.mobile_no, `tabCustomer`.email_id = contact.email_id
where `tabCustomer`.name = contact.link_name""")

View File

@ -1,21 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc("stock", "doctype", "stock_settings")
ss = frappe.get_doc("Stock Settings")
ss.set_qty_in_transactions_based_on_serial_no_input = 1
if ss.default_warehouse \
and not frappe.db.exists("Warehouse", ss.default_warehouse):
ss.default_warehouse = None
if ss.stock_uom and not frappe.db.exists("UOM", ss.stock_uom):
ss.stock_uom = None
ss.flags.ignore_mandatory = True
ss.save()

View File

@ -1,8 +0,0 @@
from __future__ import unicode_literals
import frappe
def execute():
if not frappe.db.exists("Party Type", "Student"):
party = frappe.new_doc("Party Type")
party.party_type = "Student"
party.save()

View File

@ -1,13 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from erpnext.setup.doctype.company.company import install_country_fixtures
def execute():
frappe.reload_doc("accounts", "doctype", "account")
frappe.reload_doc("accounts", "doctype", "payment_schedule")
for d in frappe.get_all('Company',
filters={'country': ('in', ['Saudi Arabia', 'United Arab Emirates'])}):
install_country_fixtures(d.name)

View File

@ -1,6 +0,0 @@
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc("hr", "doctype", "hr_settings")
frappe.db.set_value("HR Settings", None, "show_leaves_of_all_department_members_in_calendar", 1)

View File

@ -1,26 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
for d in frappe.get_all('Sales Invoice', fields=["name"],
filters = {'is_pos':1, 'docstatus': 1, 'creation': ('>', '2018-04-23')}):
doc = frappe.get_doc('Sales Invoice', d.name)
if (not doc.taxes and doc.taxes_and_charges and doc.pos_profile and doc.outstanding_amount != 0 and
frappe.db.get_value('POS Profile', doc.pos_profile, 'taxes_and_charges', cache=True) == doc.taxes_and_charges):
doc.append_taxes_from_master()
doc.calculate_taxes_and_totals()
for d in doc.taxes:
d.db_update()
doc.db_update()
delete_gle_for_voucher(doc.name)
doc.make_gl_entries()
def delete_gle_for_voucher(voucher_no):
frappe.db.sql("""delete from `tabGL Entry` where voucher_no = %(voucher_no)s""",
{'voucher_no': voucher_no})

View File

@ -1,12 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from erpnext.regional.address_template.setup import set_up_address_templates
def execute():
if frappe.db.get_value('Company', {'country': 'India'}, 'name'):
address_template = frappe.db.get_value('Address Template', 'India', 'template')
if not address_template or "gstin" not in address_template:
set_up_address_templates(default_country='India')

View File

@ -1,17 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc('education', 'doctype', 'assessment_plan')
frappe.db.sql("""
UPDATE `tabAssessment Plan` as ap
INNER JOIN `tabStudent Group` as sg ON sg.name = ap.student_group
SET ap.academic_term = sg.academic_term,
ap.academic_year = sg.academic_year,
ap.program = sg.program
WHERE ap.docstatus = 1
""")

View File

@ -1,20 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc('education', 'doctype', 'assessment_result')
frappe.db.sql("""
UPDATE `tabAssessment Result` AS ar
INNER JOIN `tabAssessment Plan` AS ap ON ap.name = ar.assessment_plan
SET ar.academic_term = ap.academic_term,
ar.academic_year = ap.academic_year,
ar.program = ap.program,
ar.course = ap.course,
ar.assessment_group = ap.assessment_group,
ar.student_group = ap.student_group
WHERE ap.docstatus = 1
""")

View File

@ -1,12 +0,0 @@
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc('assets', 'doctype', 'asset')
frappe.reload_doc('assets', 'doctype', 'depreciation_schedule')
frappe.db.sql("""
update tabAsset a
set calculate_depreciation = 1
where exists(select ds.name from `tabDepreciation Schedule` ds where ds.parent=a.name)
""")

View File

@ -1,10 +0,0 @@
from __future__ import unicode_literals
import frappe
def execute():
if frappe.db.table_exists("Data Migration Connector"):
frappe.db.sql("""
UPDATE `tabData Migration Connector`
SET hostname = 'https://hubmarket.org'
WHERE connector_name = 'Hub Connector'
""")

View File

@ -1,9 +0,0 @@
from __future__ import unicode_literals
import frappe
from frappe.utils.nestedset import rebuild_tree
def execute():
""" assign lft and rgt appropriately """
frappe.reload_doc("hr", "doctype", "employee")
rebuild_tree("Employee", "reports_to")

View File

@ -1,15 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
for doctype in ['Sales Invoice', 'Delivery Note', 'Stock Entry']:
frappe.db.sql(""" update
`tabStock Ledger Entry` sle, `tab{0}` parent_doc
set
sle.project = parent_doc.project
where
sle.voucher_no = parent_doc.name and sle.voucher_type = %s and sle.project is null
and parent_doc.project is not null and parent_doc.project != ''""".format(doctype), doctype)

View File

@ -1,53 +0,0 @@
from __future__ import unicode_literals
import frappe
from erpnext.stock.utils import get_bin
def execute():
po_item = list(frappe.db.sql(("""
select distinct po.name as poname, poitem.rm_item_code as rm_item_code, po.company
from `tabPurchase Order` po, `tabPurchase Order Item Supplied` poitem
where po.name = poitem.parent
and po.is_subcontracted = "Yes"
and po.docstatus = 1"""), as_dict=1))
if not po_item:
return
frappe.reload_doc("stock", "doctype", "bin")
frappe.reload_doc("buying", "doctype", "purchase_order_item_supplied")
company_warehouse = frappe._dict(frappe.db.sql("""select company, min(name) from `tabWarehouse`
where is_group = 0 group by company"""))
items = list(set([d.rm_item_code for d in po_item]))
item_wh = frappe._dict(frappe.db.sql("""select item_code, default_warehouse
from `tabItem` where name in ({0})""".format(", ".join(["%s"] * len(items))), items))
# Update reserved warehouse
for item in po_item:
reserve_warehouse = get_warehouse(item.rm_item_code, item.company, company_warehouse, item_wh)
frappe.db.sql("""update `tabPurchase Order Item Supplied`
set reserve_warehouse = %s
where parent = %s and rm_item_code = %s
""", (reserve_warehouse, item["poname"], item["rm_item_code"]))
# Update bin
item_wh_bin = frappe.db.sql(("""
select distinct poitemsup.rm_item_code as rm_item_code,
poitemsup.reserve_warehouse as reserve_warehouse
from `tabPurchase Order` po, `tabPurchase Order Item Supplied` poitemsup
where po.name = poitemsup.parent
and po.is_subcontracted = "Yes"
and po.docstatus = 1"""), as_dict=1)
for d in item_wh_bin:
try:
stock_bin = get_bin(d["rm_item_code"], d["reserve_warehouse"])
stock_bin.update_reserved_qty_for_sub_contracting()
except:
pass
def get_warehouse(item_code, company, company_warehouse, item_wh):
reserve_warehouse = item_wh.get(item_code)
if frappe.db.get_value("Warehouse", reserve_warehouse, "company") != company:
reserve_warehouse = None
if not reserve_warehouse:
reserve_warehouse = company_warehouse.get(company)
return reserve_warehouse

View File

@ -1,18 +0,0 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc("buying", "doctype", "supplier_quotation_item")
for doctype in ['Purchase Order','Supplier Quotation']:
frappe.db.sql("""
Update
`tab{doctype} Item`, `tabMaterial Request Item`
set
`tab{doctype} Item`.sales_order = `tabMaterial Request Item`.sales_order
where
`tab{doctype} Item`.material_request= `tabMaterial Request Item`.parent
and `tab{doctype} Item`.material_request_item = `tabMaterial Request Item`.name
and `tabMaterial Request Item`.sales_order is not null""".format(doctype=doctype))

View File

@ -1,40 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
# update the sales order item in the material request
frappe.reload_doc('stock', 'doctype', 'material_request_item')
frappe.db.sql('''update `tabMaterial Request Item` mri, `tabSales Order Item` soi
set mri.sales_order_item = soi.name
where ifnull(mri.sales_order, "")!="" and soi.parent=mri.sales_order
and soi.item_code=mri.item_code and mri.docstatus=1
''')
# update the sales order item in the purchase order
frappe.db.sql('''update `tabPurchase Order Item` poi, `tabSales Order Item` soi
set poi.sales_order_item = soi.name
where ifnull(poi.sales_order, "")!="" and soi.parent=poi.sales_order
and soi.item_code=poi.item_code and poi.docstatus = 1
''')
# Update the status in material request and sales order
po_list = frappe.db.sql('''
select parent from `tabPurchase Order Item` where ifnull(material_request, "")!="" and
ifnull(sales_order, "")!="" and docstatus=1
''',as_dict=1)
for po in list(set([d.get("parent") for d in po_list if d.get("parent")])):
try:
po_doc = frappe.get_doc("Purchase Order", po)
# update the so in the status updater
po_doc.update_status_updater()
po_doc.update_qty(update_modified=False)
except Exception:
pass

View File

@ -1,8 +0,0 @@
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc("stock", "doctype", "purchase_receipt")
frappe.db.sql('''
UPDATE `tabPurchase Receipt` SET status = "Completed" WHERE per_billed = 100 AND docstatus = 1
''')

View File

@ -1,29 +0,0 @@
from __future__ import unicode_literals
import frappe
from frappe.model.rename_doc import get_fetch_fields
def execute():
ignore_doctypes = ["Lead", "Opportunity", "POS Profile", "Tax Rule", "Pricing Rule"]
customers = frappe.get_all('Customer', fields=["name", "customer_group"])
customer_group_fetch = get_fetch_fields('Customer', 'Customer Group', ignore_doctypes)
batch_size = 1000
for i in range(0, len(customers), batch_size):
batch_customers = customers[i:i + batch_size]
for d in customer_group_fetch:
when_then = []
for customer in batch_customers:
value = frappe.db.escape(frappe.as_unicode(customer.get("customer_group")))
when_then.append('''
WHEN `%s` = %s and %s != %s
THEN %s
'''%(d["master_fieldname"], frappe.db.escape(frappe.as_unicode(customer.name)),
d["linked_to_fieldname"], value, value))
frappe.db.sql("""
update
`tab%s`
set
%s = CASE %s ELSE `%s` END
"""%(d['doctype'], d.linked_to_fieldname, " ".join(when_then), d.linked_to_fieldname))

View File

@ -1,19 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc('hr', 'doctype', 'employee')
frappe.db.sql("""
UPDATE
`tabEmployee`, `tabUser`
SET
`tabEmployee`.image = `tabUser`.user_image
WHERE
`tabEmployee`.user_id = `tabUser`.name and
`tabEmployee`.user_id is not null and
`tabEmployee`.user_id != '' and `tabEmployee`.image is null
""")

View File

@ -1,37 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
warehouse = frappe.db.sql("""select name, email_id, phone_no, mobile_no, address_line_1,
address_line_2, city, state, pin from `tabWarehouse` where ifnull(address_line_1, '') != ''
or ifnull(mobile_no, '') != ''
or ifnull(email_id, '') != '' """, as_dict=1)
for d in warehouse:
try:
address = frappe.new_doc('Address')
address.name = d.name
address.address_title = d.name
address.address_line1 = d.address_line_1
address.city = d.city
address.state = d.state
address.pincode = d.pin
address.db_insert()
address.append('links',{'link_doctype':'Warehouse','link_name':d.name})
address.links[0].db_insert()
if d.name and (d.email_id or d.mobile_no or d.phone_no):
contact = frappe.new_doc('Contact')
contact.name = d.name
contact.first_name = d.name
contact.mobile_no = d.mobile_no
contact.email_id = d.email_id
contact.phone = d.phone_no
contact.db_insert()
contact.append('links',{'link_doctype':'Warehouse','link_name':d.name})
contact.links[0].db_insert()
except frappe.DuplicateEntryError:
pass

View File

@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@ -1,16 +0,0 @@
from __future__ import unicode_literals
import frappe
from frappe.model.utils.rename_field import rename_field
def execute():
""" copy subscribe field to customer """
frappe.reload_doc("accounts","doctype","subscription")
if frappe.db.exists("DocType", "Subscriber"):
if frappe.db.has_column('Subscription','subscriber'):
frappe.db.sql("""
update `tabSubscription` s1
set customer=(select customer from tabSubscriber where name=s1.subscriber)
""")
frappe.delete_doc("DocType", "Subscriber")

View File

@ -6,6 +6,10 @@ import frappe
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}, ''))= ''")
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':

View File

@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@ -2,6 +2,7 @@ from __future__ import unicode_literals
import frappe
from frappe.model.utils.rename_field import rename_field
def execute():
if frappe.db.exists('DocType', 'Lab Test') and frappe.db.exists('DocType', 'Lab Test Template'):
# rename child doctypes
@ -17,7 +18,12 @@ def execute():
frappe.reload_doc('healthcare', 'doctype', 'lab_test_template')
for old_dt, new_dt in doctypes.items():
if not frappe.db.table_exists(new_dt) and frappe.db.table_exists(old_dt):
frappe.flags.link_fields = {}
should_rename = (
frappe.db.table_exists(old_dt)
and not frappe.db.table_exists(new_dt)
)
if should_rename:
frappe.reload_doc('healthcare', 'doctype', frappe.scrub(old_dt))
frappe.rename_doc('DocType', old_dt, new_dt, force=True)
frappe.reload_doc('healthcare', 'doctype', frappe.scrub(new_dt))

View File

@ -1,50 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from erpnext.hr.doctype.employee.employee import EmployeeUserDisabledError
def execute():
update_hr_permissions()
update_permissions()
remove_duplicate_user_permissions()
frappe.clear_cache()
def update_hr_permissions():
# add set user permissions rights to HR Manager
frappe.db.sql("""update `tabDocPerm` set `set_user_permissions`=1 where parent in ('Employee', 'Leave Application')
and role='HR Manager' and permlevel=0 and `read`=1""")
docperm_meta = frappe.get_meta('DocPerm')
if docperm_meta.get_field('apply_user_permissions'):
# apply user permissions on Employee and Leave Application
frappe.db.sql("""update `tabDocPerm` set `apply_user_permissions`=1 where parent in ('Employee', 'Leave Application')
and role in ('Employee', 'Leave Approver') and permlevel=0 and `read`=1""")
frappe.clear_cache()
# save employees to run on_update events
for employee in frappe.db.sql_list("""select name from `tabEmployee` where docstatus < 2"""):
try:
emp = frappe.get_doc("Employee", employee)
emp.flags.ignore_mandatory = True
emp.save()
except EmployeeUserDisabledError:
pass
def update_permissions():
# clear match conditions other than owner
frappe.db.sql("""update tabDocPerm set `match`=''
where ifnull(`match`,'') not in ('', 'owner')""")
def remove_duplicate_user_permissions():
# remove duplicate user_permissions (if they exist)
for d in frappe.db.sql("""select parent, defkey, defvalue,
count(*) as cnt from tabDefaultValue
where parent not in ('__global', '__default')
group by parent, defkey, defvalue""", as_dict=1):
if d.cnt > 1:
# order by parenttype so that user permission does not get removed!
frappe.db.sql("""delete from tabDefaultValue where `parent`=%s and `defkey`=%s and
`defvalue`=%s order by parenttype limit %s""", (d.parent, d.defkey, d.defvalue, d.cnt-1))

View File

@ -1,29 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc("setup", 'doctype', "company")
frappe.reload_doc("accounts", 'doctype', "account")
frappe.db.sql("""update tabAccount set account_type='Cash'
where account_type='Bank or Cash' and account_name in ('Cash', 'Cash In Hand')""")
frappe.db.sql("""update tabAccount set account_type='Stock'
where account_name = 'Stock Assets'""")
ac_types = {"Fixed Asset Account": "Fixed Asset", "Bank or Cash": "Bank"}
for old, new in ac_types.items():
frappe.db.sql("""update tabAccount set account_type=%s
where account_type=%s""", (new, old))
try:
frappe.db.sql("""update `tabAccount` set report_type =
if(is_pl_account='Yes', 'Profit and Loss', 'Balance Sheet')""")
frappe.db.sql("""update `tabAccount` set balance_must_be=debit_or_credit
where ifnull(allow_negative_balance, 0) = 0""")
except:
pass

View File

@ -1,63 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.custom.doctype.custom_field.custom_field import create_custom_field_if_values_exist
def execute():
frappe.reload_doc("stock", "doctype", "purchase_receipt")
frappe.reload_doc("hr", "doctype", "employee")
frappe.reload_doc("Payroll", "doctype", "salary_slip")
india_specific_fields = {
"Purchase Receipt": [{
"label": "Supplier Shipment No",
"fieldname": "challan_no",
"fieldtype": "Data",
"insert_after": "is_subcontracted"
}, {
"label": "Supplier Shipment Date",
"fieldname": "challan_date",
"fieldtype": "Date",
"insert_after": "is_subcontracted"
}],
"Employee": [{
"label": "PAN Number",
"fieldname": "pan_number",
"fieldtype": "Data",
"insert_after": "company_email"
}, {
"label": "Gratuity LIC Id",
"fieldname": "gratuity_lic_id",
"fieldtype": "Data",
"insert_after": "company_email"
}, {
"label": "Esic Card No",
"fieldname": "esic_card_no",
"fieldtype": "Data",
"insert_after": "bank_ac_no"
}, {
"label": "PF Number",
"fieldname": "pf_number",
"fieldtype": "Data",
"insert_after": "bank_ac_no"
}],
"Salary Slip": [{
"label": "Esic No",
"fieldname": "esic_no",
"fieldtype": "Data",
"insert_after": "letter_head",
"permlevel": 1
}, {
"label": "PF Number",
"fieldname": "pf_no",
"fieldtype": "Data",
"insert_after": "letter_head",
"permlevel": 1
}]
}
for dt, docfields in india_specific_fields.items():
for df in docfields:
create_custom_field_if_values_exist(dt, df)

View File

@ -1,35 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils.nestedset import get_root_of
def execute():
# setup not complete
if not frappe.db.sql("""select name from tabCompany limit 1"""):
return
if "shopping_cart" in frappe.get_installed_apps():
frappe.reload_doc("shopping_cart", "doctype", "shopping_cart_settings")
if not frappe.db.sql("select name from `tabPrice List` where buying=1"):
create_price_list(_("Standard Buying"), buying=1)
if not frappe.db.sql("select name from `tabPrice List` where selling=1"):
create_price_list(_("Standard Selling"), selling=1)
def create_price_list(pl_name, buying=0, selling=0):
price_list = frappe.get_doc({
"doctype": "Price List",
"price_list_name": pl_name,
"enabled": 1,
"buying": buying,
"selling": selling,
"currency": frappe.db.get_default("currency"),
"territories": [{
"territory": get_root_of("Territory")
}]
})
price_list.insert()

View File

@ -1,33 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.utils.nestedset import get_root_of
def execute():
frappe.reload_doc("accounts", "doctype", "pricing_rule")
frappe.db.auto_commit_on_many_writes = True
default_item_group = get_root_of("Item Group")
for d in frappe.db.sql("""select * from `tabCustomer Discount`
where ifnull(parent, '') != ''""", as_dict=1):
if not d.discount:
continue
frappe.get_doc({
"doctype": "Pricing Rule",
"apply_on": "Item Group",
"item_group": d.item_group or default_item_group,
"applicable_for": "Customer",
"customer": d.parent,
"price_or_discount": "Discount Percentage",
"discount_percentage": d.discount,
"selling": 1
}).insert()
frappe.db.auto_commit_on_many_writes = False
frappe.delete_doc("DocType", "Customer Discount")

View File

@ -1,109 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.utils.rename_field import rename_field
from frappe.modules import scrub, get_doctype_module
rename_map = {
"Quotation Item": [
["ref_rate", "price_list_rate"],
["base_ref_rate", "base_price_list_rate"],
["adj_rate", "discount_percentage"],
["export_rate", "rate"],
["basic_rate", "base_rate"],
["amount", "base_amount"],
["export_amount", "amount"]
],
"Sales Order Item": [
["ref_rate", "price_list_rate"],
["base_ref_rate", "base_price_list_rate"],
["adj_rate", "discount_percentage"],
["export_rate", "rate"],
["basic_rate", "base_rate"],
["amount", "base_amount"],
["export_amount", "amount"],
["reserved_warehouse", "warehouse"]
],
"Delivery Note Item": [
["ref_rate", "price_list_rate"],
["base_ref_rate", "base_price_list_rate"],
["adj_rate", "discount_percentage"],
["export_rate", "rate"],
["basic_rate", "base_rate"],
["amount", "base_amount"],
["export_amount", "amount"]
],
"Sales Invoice Item": [
["ref_rate", "price_list_rate"],
["base_ref_rate", "base_price_list_rate"],
["adj_rate", "discount_percentage"],
["export_rate", "rate"],
["basic_rate", "base_rate"],
["amount", "base_amount"],
["export_amount", "amount"]
],
"Supplier Quotation Item": [
["import_ref_rate", "price_list_rate"],
["purchase_ref_rate", "base_price_list_rate"],
["discount_rate", "discount_percentage"],
["import_rate", "rate"],
["purchase_rate", "base_rate"],
["amount", "base_amount"],
["import_amount", "amount"]
],
"Purchase Order Item": [
["import_ref_rate", "price_list_rate"],
["purchase_ref_rate", "base_price_list_rate"],
["discount_rate", "discount_percentage"],
["import_rate", "rate"],
["purchase_rate", "base_rate"],
["amount", "base_amount"],
["import_amount", "amount"]
],
"Purchase Receipt Item": [
["import_ref_rate", "price_list_rate"],
["purchase_ref_rate", "base_price_list_rate"],
["discount_rate", "discount_percentage"],
["import_rate", "rate"],
["purchase_rate", "base_rate"],
["amount", "base_amount"],
["import_amount", "amount"]
],
"Purchase Invoice Item": [
["import_ref_rate", "price_list_rate"],
["purchase_ref_rate", "base_price_list_rate"],
["discount_rate", "discount_percentage"],
["import_rate", "rate"],
["rate", "base_rate"],
["amount", "base_amount"],
["import_amount", "amount"],
["expense_head", "expense_account"]
],
"Item": [
["purchase_account", "expense_account"],
["default_sales_cost_center", "selling_cost_center"],
["cost_center", "buying_cost_center"],
["default_income_account", "income_account"],
],
"Item Price": [
["ref_rate", "price_list_rate"]
]
}
def execute():
for dn in rename_map:
frappe.reload_doc(get_doctype_module(dn), "doctype", scrub(dn))
for dt, field_list in rename_map.items():
for field in field_list:
rename_field(dt, field[0], field[1])

View File

@ -1,12 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
from __future__ import unicode_literals
import frappe
def execute():
missing_line = """{{ address_line1 }}<br>"""
for name, template in frappe.db.sql("select name, template from `tabAddress Template`"):
if missing_line not in template:
d = frappe.get_doc("Address Template", name)
d.template = missing_line + d.template
d.save()

View File

@ -1,13 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
from __future__ import unicode_literals
import frappe
def execute():
hr = frappe.db.get_value("Module Def", "HR")
if hr == "Hr":
frappe.rename_doc("Module Def", "Hr", "HR")
frappe.db.set_value("Module Def", "HR", "module_name", "HR")
frappe.clear_cache()
frappe.setup_module_map()

View File

@ -1,13 +0,0 @@
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc("website", "doctype", "contact_us_settings")
address = frappe.db.get_value("Contact Us Settings", None, "address")
if address:
address = frappe.get_doc("Address", address)
contact = frappe.get_doc("Contact Us Settings", "Contact Us Settings")
for f in ("address_title", "address_line1", "address_line2", "city", "state", "country", "pincode"):
contact.set(f, address.get(f))
contact.save()

View File

@ -1,23 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.utils import get_fullname
def execute():
for user_id in frappe.db.sql_list("""select distinct user_id from `tabEmployee`
where ifnull(user_id, '')!=''
group by user_id having count(name) > 1"""):
fullname = get_fullname(user_id)
employee = frappe.db.get_value("Employee", {"employee_name": fullname, "user_id": user_id})
if employee:
frappe.db.sql("""update `tabEmployee` set user_id=null
where user_id=%s and name!=%s""", (user_id, employee))
else:
count = frappe.db.sql("""select count(*) from `tabEmployee` where user_id=%s""", user_id)[0][0]
frappe.db.sql("""update `tabEmployee` set user_id=null
where user_id=%s limit %s""", (user_id, count - 1))

View File

@ -1,39 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from __future__ import unicode_literals
import frappe
from collections import Counter
from frappe.core.doctype.user.user import STANDARD_USERS
def execute():
frappe.reload_doc("core", "doctype", "system_settings")
system_settings = frappe.get_doc("System Settings")
# set values from global_defauls
global_defaults = frappe.db.get_value("Global Defaults", None,
["time_zone", "date_format", "number_format", "float_precision", "session_expiry"], as_dict=True)
if global_defaults:
for key, val in global_defaults.items():
if not system_settings.get(key):
system_settings.set(key, val)
# language
if not system_settings.get("language"):
# find most common language
lang = frappe.db.sql_list("""select language from `tabUser`
where ifnull(language, '')!='' and language not like "Loading%%" and name not in ({standard_users})""".format(
standard_users=", ".join(["%s"]*len(STANDARD_USERS))), tuple(STANDARD_USERS))
lang = Counter(lang).most_common(1)
lang = (len(lang) > 0) and lang[0][0] or "english"
system_settings.language = lang
system_settings.flags.ignore_mandatory = True
system_settings.save()
global_defaults = frappe.get_doc("Global Defaults")
global_defaults.flags.ignore_mandatory = True
global_defaults.save()

View File

@ -1,15 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.geo.country_info import get_all
from frappe.utils.install import import_country_and_currency
from six import iteritems
def execute():
frappe.reload_doc("setup", "doctype", "country")
import_country_and_currency()
for name, country in iteritems(get_all()):
frappe.set_value("Country", name, "code", country.get("code"))

View File

@ -1,16 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
# update sales cycle
for d in ['Sales Invoice', 'Sales Order', 'Quotation', 'Delivery Note']:
frappe.db.sql("""update `tab%s` set taxes_and_charges=charge""" % d)
# update purchase cycle
for d in ['Purchase Invoice', 'Purchase Order', 'Supplier Quotation', 'Purchase Receipt']:
frappe.db.sql("""update `tab%s` set taxes_and_charges=purchase_other_charges""" % d)
frappe.db.sql("""update `tabPurchase Taxes and Charges` set parentfield='other_charges'""")

View File

@ -1,13 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
import frappe.permissions
def execute():
for warehouse, user in frappe.db.sql("""select parent, user from `tabWarehouse User`"""):
frappe.permissions.add_user_permission("Warehouse", warehouse, user)
frappe.delete_doc_if_exists("DocType", "Warehouse User")
frappe.reload_doc("stock", "doctype", "warehouse")

View File

@ -1,14 +0,0 @@
from __future__ import print_function, unicode_literals
import frappe
def execute():
frappe.reload_doc("utilities", "doctype", "address_template")
if not frappe.db.sql("select name from `tabAddress Template`"):
try:
d = frappe.new_doc("Address Template")
d.update({"country":frappe.db.get_default("country") or
frappe.db.get_value("Global Defaults", "Global Defaults", "country")})
d.insert()
except:
print(frappe.get_traceback())

View File

@ -1,8 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc('accounts', 'Print Format', 'POS Invoice')

View File

@ -1,18 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
import frappe.permissions
def execute():
for user in frappe.db.sql_list("select distinct parent from `tabHas Role` where role='Employee'"):
# if employee record does not exists, remove employee role!
if not frappe.db.get_value("Employee", {"user_id": user}):
try:
user = frappe.get_doc("User", user)
for role in user.get("roles", {"role": "Employee"}):
user.get("roles").remove(role)
user.save()
except frappe.DoesNotExistError:
pass

View File

@ -1,10 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
for page in ("accounts-home", "website-home", "support-home", "stock-home", "selling-home", "projects-home",
"manufacturing-home", "hr-home", "buying-home"):
frappe.delete_doc("Page", page)

View File

@ -1,17 +0,0 @@
from __future__ import unicode_literals
import frappe
import frappe.model
def execute():
frappe.reload_doc("setup", "doctype", "item_group")
frappe.reload_doc("stock", "doctype", "item")
frappe.reload_doc("setup", "doctype", "sales_partner")
try:
frappe.model.rename_field("Item Group", "parent_website_sitemap", "parent_website_route")
frappe.model.rename_field("Item", "parent_website_sitemap", "parent_website_route")
frappe.model.rename_field("Sales Partner", "parent_website_sitemap",
"parent_website_route")
except Exception as e:
if e.args[0]!=1054:
raise

View File

@ -1,20 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import print_function, unicode_literals
from frappe.permissions import reset_perms
def execute():
for doctype in ("About Us Settings", "Accounts Settings", "Activity Type",
"Blog Category", "Blog Settings", "Blogger", "Branch", "Brand", "Buying Settings",
"Communication", "Company", "Contact Us Settings",
"Country", "Currency", "Currency Exchange", "Deduction Type", "Department",
"Designation", "Earning Type", "Event", "Feed", "File", "Fiscal Year",
"HR Settings", "Industry Type", "Leave Type", "Letter Head",
"Mode of Payment", "Module Def", "Naming Series", "POS Setting", "Print Heading",
"Report", "Role", "Selling Settings", "Stock Settings", "Supplier Type", "UOM"):
try:
reset_perms(doctype)
except:
print("Error resetting perms for", doctype)
raise

View File

@ -1,13 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
"""save default letterhead to set default_letter_head_content"""
try:
letter_head = frappe.get_doc("Letter Head", {"is_default": 1})
letter_head.save()
except frappe.DoesNotExistError:
pass

View File

@ -1,13 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc("accounts", "doctype", "pricing_rule")
frappe.db.sql("""update `tabPricing Rule` set selling=1 where ifnull(applicable_for, '') in
('', 'Customer', 'Customer Group', 'Territory', 'Sales Partner', 'Campaign')""")
frappe.db.sql("""update `tabPricing Rule` set buying=1 where ifnull(applicable_for, '') in
('', 'Supplier', 'Supplier Type')""")

View File

@ -1,67 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import print_function, unicode_literals
import frappe
def execute():
print("WARNING!!!! Email Settings not migrated. Please setup your email again.")
# this will happen if you are migrating very old accounts
# comment out this line below and remember to create new Email Accounts
# for incoming and outgoing mails
raise Exception
return
frappe.reload_doc("core", "doctype", "outgoing_email_settings")
frappe.reload_doc("support", "doctype", "support_email_settings")
email_settings = get_email_settings()
map_outgoing_email_settings(email_settings)
map_support_email_settings(email_settings)
def map_outgoing_email_settings(email_settings):
outgoing_email_settings = frappe.get_doc("Outgoing Email Settings")
for fieldname in (("outgoing_mail_server", "mail_server"),
"use_ssl", "mail_port", "mail_login", "mail_password",
"always_use_login_id_as_sender", "auto_email_id"):
if isinstance(fieldname, tuple):
from_fieldname, to_fieldname = fieldname
else:
from_fieldname = to_fieldname = fieldname
outgoing_email_settings.set(to_fieldname, email_settings.get(from_fieldname))
outgoing_email_settings._fix_numeric_types()
outgoing_email_settings.save()
def map_support_email_settings(email_settings):
support_email_settings = frappe.get_doc("Support Email Settings")
for fieldname in ("sync_support_mails", "support_email",
("support_host", "mail_server"),
("support_use_ssl", "use_ssl"),
("support_username", "mail_login"),
("support_password", "mail_password"),
"support_signature", "send_autoreply", "support_autoreply"):
if isinstance(fieldname, tuple):
from_fieldname, to_fieldname = fieldname
else:
from_fieldname = to_fieldname = fieldname
support_email_settings.set(to_fieldname, email_settings.get(from_fieldname))
support_email_settings._fix_numeric_types()
support_email_settings.save()
def get_email_settings():
ret = {}
for field, value in frappe.db.sql("select field, value from tabSingles where doctype='Email Settings'"):
ret[field] = value
return ret

View File

@ -1,34 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import print_function, unicode_literals
import frappe
def execute():
frappe.reload_doc("accounts", "doctype", "account")
account_table_columns = frappe.db.get_table_columns("Account")
if "debit_or_credit" in account_table_columns and "is_pl_account" in account_table_columns:
frappe.db.sql("""UPDATE tabAccount
SET root_type = CASE
WHEN (debit_or_credit='Debit' and is_pl_account = 'No') THEN 'Asset'
WHEN (debit_or_credit='Credit' and is_pl_account = 'No') THEN 'Liability'
WHEN (debit_or_credit='Debit' and is_pl_account = 'Yes') THEN 'Expense'
WHEN (debit_or_credit='Credit' and is_pl_account = 'Yes') THEN 'Income'
END
WHERE ifnull(parent_account, '') = ''
""")
else:
for key, root_type in (("asset", "Asset"), ("liabilities", "Liability"), ("expense", "Expense"),
("income", "Income")):
frappe.db.sql("""update tabAccount set root_type=%s where name like %s
and ifnull(parent_account, '')=''""", (root_type, "%" + key + "%"))
for root in frappe.db.sql("""SELECT name, lft, rgt, root_type FROM `tabAccount`
WHERE ifnull(parent_account, '')=''""", as_dict=True):
if root.root_type:
frappe.db.sql("""UPDATE tabAccount SET root_type=%s WHERE lft>%s and rgt<%s""",
(root.root_type, root.lft, root.rgt))
else:
print(b"Root type not found for {0}".format(root.name.encode("utf-8")))

View File

@ -1,36 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
import re
def execute():
# NOTE: sequence is important
fields_list = (
("amount", "base_amount"),
("ref_rate", "price_list_rate"),
("base_ref_rate", "base_price_list_rate"),
("adj_rate", "discount_percentage"),
("export_rate", "rate"),
("basic_rate", "base_rate"),
("export_amount", "amount"),
("reserved_warehouse", "warehouse"),
("import_ref_rate", "price_list_rate"),
("purchase_ref_rate", "base_price_list_rate"),
("discount_rate", "discount_percentage"),
("import_rate", "rate"),
("purchase_rate", "base_rate"),
("import_amount", "amount")
)
condition = " or ".join("""html like "%%{}%%" """.format(d[0].replace("_", "\\_")) for d in fields_list
if d[0] != "amount")
for name, html in frappe.db.sql("""select name, html from `tabPrint Format`
where standard = 'No' and ({}) and html not like '%%frappe.%%'""".format(condition)):
html = html.replace("wn.", "frappe.")
for from_field, to_field in fields_list:
html = re.sub(r"\b{}\b".format(from_field), to_field, html)
frappe.db.set_value("Print Format", name, "html", html)

View File

@ -1,12 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc("support", "doctype", "schedules")
frappe.reload_doc("support", "doctype", "maintenance_schedule_item")
frappe.db.sql("""update `tabMaintenance Schedule Detail` set sales_person=incharge_name""")
frappe.db.sql("""update `tabMaintenance Schedule Item` set sales_person=incharge_name""")

View File

@ -1,12 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
import re
def execute():
for name, html in frappe.db.sql("""select name, html from `tabPrint Format`
where standard = 'No' and html like '%%purchase\\_tax\\_details%%'"""):
html = re.sub(r"\bpurchase_tax_details\b", "taxes", html)
frappe.db.set_value("Print Format", name, "html", html)

View File

@ -1,20 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc("accounts", "doctype", "sales_taxes_and_charges")
docs_with_discount_amount = frappe._dict()
for dt in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]:
records = frappe.db.sql_list("""select name from `tab%s`
where ifnull(discount_amount, 0) > 0 and docstatus=1""" % dt)
docs_with_discount_amount[dt] = records
for dt, discounted_records in docs_with_discount_amount.items():
frappe.db.sql("""update `tabSales Taxes and Charges`
set tax_amount_after_discount_amount = tax_amount
where parenttype = %s and parent not in (%s)""" %
('%s', ', '.join(['%s']*(len(discounted_records)+1))),
tuple([dt, ''] + discounted_records))

View File

@ -1,51 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
import frappe.permissions
import frappe.defaults
def execute():
frappe.reload_doc("core", "doctype", "docfield")
frappe.reload_doc("hr", "doctype", "employee")
set_print_email_permissions()
migrate_user_properties_to_user_permissions()
frappe.clear_cache()
def migrate_user_properties_to_user_permissions():
for d in frappe.db.sql("""select parent, defkey, defvalue from tabDefaultValue
where parent not in ('__global', '__default')""", as_dict=True):
df = frappe.db.sql("""select options from tabDocField
where fieldname=%s and fieldtype='Link'""", d.defkey, as_dict=True)
if df:
frappe.db.sql("""update tabDefaultValue
set defkey=%s, parenttype='User Permission'
where defkey=%s and
parent not in ('__global', '__default')""", (df[0].options, d.defkey))
def set_print_email_permissions():
# reset Page perms
from frappe.core.page.permission_manager.permission_manager import reset
reset("Page")
reset("Report")
if "allow_print" not in frappe.db.get_table_columns("DocType"):
return
# patch to move print, email into DocPerm
# NOTE: allow_print and allow_email are misnamed. They were used to hide print / hide email
for doctype, hide_print, hide_email in frappe.db.sql("""select name, ifnull(allow_print, 0), ifnull(allow_email, 0)
from `tabDocType` where ifnull(issingle, 0)=0 and ifnull(istable, 0)=0 and
(ifnull(allow_print, 0)=0 or ifnull(allow_email, 0)=0)"""):
if not hide_print:
frappe.db.sql("""update `tabDocPerm` set `print`=1
where permlevel=0 and `read`=1 and parent=%s""", doctype)
if not hide_email:
frappe.db.sql("""update `tabDocPerm` set `email`=1
where permlevel=0 and `read`=1 and parent=%s""", doctype)

View File

@ -1,12 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
from frappe.model.utils.rename_field import update_users_report_view_settings
from erpnext.patches.v4_0.fields_to_be_renamed import rename_map
def execute():
for dt, field_list in rename_map.items():
for field in field_list:
update_users_report_view_settings(dt, field[0], field[1])

View File

@ -1,11 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
from frappe.modules.patch_handler import executed
last_v3_patch = 'patches.1401.fix_pos_outstanding'
if not executed(last_v3_patch):
raise Exception("site not ready to migrate to version 4")

View File

@ -1,12 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.db.sql("""update `tabSales Order` set delivery_status = 'Not Delivered'
where delivery_status = 'Delivered' and ifnull(per_delivered, 0) = 0 and ifnull(docstatus, 0) in (0, 1)""")
frappe.db.sql("""update `tabSales Order` set billing_status = 'Not Billed'
where billing_status = 'Billed' and ifnull(per_billed, 0) = 0 and ifnull(docstatus, 0) in (0, 1)""")

View File

@ -1,21 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
reference_date = guess_reference_date()
for name in frappe.db.sql_list("""select name from `tabJournal Entry`
where date(creation)>=%s""", reference_date):
jv = frappe.get_doc("Journal Entry", name)
try:
jv.create_remarks()
except frappe.MandatoryError:
pass
else:
frappe.db.set_value("Journal Entry", jv.name, "remark", jv.remark)
def guess_reference_date():
return (frappe.db.get_value("Patch Log", {"patch": "erpnext.patches.v4_0.validate_v3_patch"}, "creation")
or "2014-05-06")

View File

@ -1,15 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
for si in frappe.db.sql_list("""select name
from `tabSales Invoice`
where ifnull(update_stock,0) = 1 and docstatus = 1 and exists(
select name from `tabSales Invoice Item` where parent=`tabSales Invoice`.name and
ifnull(so_detail, "") != "")"""):
invoice = frappe.get_doc("Sales Invoice", si)
invoice.update_qty()

View File

@ -1,12 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from erpnext.setup.install import default_mail_footer
def execute():
return
mail_footer = frappe.db.get_default('mail_footer') or ''
mail_footer += default_mail_footer
frappe.db.set_value("Outgoing Email Settings", "Outgoing Email Settings", "footer", mail_footer)

View File

@ -1,10 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
return
# country = get_country_info(country="Turkey")
# add_country_and_currency("Turkey", country)

View File

@ -1,11 +0,0 @@
from __future__ import unicode_literals
import frappe
def execute():
return
# frappe.reload_doc('website', 'doctype', 'style_settings')
# style_settings = frappe.get_doc("Style Settings", "Style Settings")
# if not style_settings.apply_style:
# style_settings.update(default_properties)
# style_settings.apply_style = 1
# style_settings.save()

View File

@ -1,14 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
cancelled_invoices = frappe.db.sql_list("""select name from `tabSales Invoice`
where docstatus = 2 and ifnull(update_stock, 0) = 1""")
if cancelled_invoices:
frappe.db.sql("""delete from `tabGL Entry`
where voucher_type = 'Sales Invoice' and voucher_no in (%s)"""
% (', '.join(['%s']*len(cancelled_invoices))), tuple(cancelled_invoices))

View File

@ -1,23 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
old_formats = ("Sales Invoice", "Sales Invoice Spartan", "Sales Invoice Modern",
"Sales Invoice Classic",
"Sales Order Spartan", "Sales Order Modern", "Sales Order Classic",
"Purchase Order Spartan", "Purchase Order Modern", "Purchase Order Classic",
"Quotation Spartan", "Quotation Modern", "Quotation Classic",
"Delivery Note Spartan", "Delivery Note Modern", "Delivery Note Classic")
for fmt in old_formats:
# update property setter
for ps in frappe.db.sql_list("""select name from `tabProperty Setter`
where property='default_print_format' and value=%s""", fmt):
ps = frappe.get_doc("Property Setter", ps)
ps.value = "Standard"
ps.save(ignore_permissions = True)
frappe.delete_doc_if_exists("Print Format", fmt)

View File

@ -1,12 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.modules import scrub, get_doctype_module
def execute():
for dt in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]:
frappe.reload_doc(get_doctype_module(dt), "doctype", scrub(dt))
frappe.db.sql("""update `tab{0}` set base_discount_amount=discount_amount,
discount_amount=discount_amount/conversion_rate""".format(dt))

View File

@ -1,12 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
for d in frappe.db.sql("""select name from `tabAccount`
where ifnull(master_type, '') not in ('Customer', 'Supplier', 'Employee', '') and docstatus=0"""):
ac = frappe.get_doc("Account", d[0])
ac.master_type = None
ac.save()

View File

@ -1,54 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import print_function, unicode_literals
import frappe
from frappe.utils import flt
def execute():
from erpnext.stock.stock_balance import repost
repost(allow_zero_rate=True, only_actual=True)
frappe.reload_doctype("Account")
warehouse_account = frappe.db.sql("""select name, master_name from tabAccount
where ifnull(account_type, '') = 'Warehouse'""")
if warehouse_account:
warehouses = [d[1] for d in warehouse_account]
accounts = [d[0] for d in warehouse_account]
stock_vouchers = frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no
from `tabStock Ledger Entry` sle
where sle.warehouse in (%s)
order by sle.posting_date""" %
', '.join(['%s']*len(warehouses)), tuple(warehouses))
rejected = []
for voucher_type, voucher_no in stock_vouchers:
stock_bal = frappe.db.sql("""select sum(stock_value_difference) from `tabStock Ledger Entry`
where voucher_type=%s and voucher_no =%s and warehouse in (%s)""" %
('%s', '%s', ', '.join(['%s']*len(warehouses))), tuple([voucher_type, voucher_no] + warehouses))
account_bal = frappe.db.sql("""select ifnull(sum(ifnull(debit, 0) - ifnull(credit, 0)), 0)
from `tabGL Entry`
where voucher_type=%s and voucher_no =%s and account in (%s)
group by voucher_type, voucher_no""" %
('%s', '%s', ', '.join(['%s']*len(accounts))), tuple([voucher_type, voucher_no] + accounts))
if stock_bal and account_bal and abs(flt(stock_bal[0][0]) - flt(account_bal[0][0])) > 0.1:
try:
print(voucher_type, voucher_no, stock_bal[0][0], account_bal[0][0])
frappe.db.sql("""delete from `tabGL Entry`
where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no))
voucher = frappe.get_doc(voucher_type, voucher_no)
voucher.make_gl_entries()
frappe.db.commit()
except Exception as e:
print(frappe.get_traceback())
rejected.append([voucher_type, voucher_no])
frappe.db.rollback()
print("Failed to repost: ")
print(rejected)

View File

@ -1,41 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
sales_orders = frappe.db.sql("""select name from `tabSales Order`
where docstatus = 1 and ifnull(is_recurring, 0) = 1
and (per_delivered > 0 or per_billed > 0)""", as_dict=1)
for so in sales_orders:
if not frappe.db.exists("Delivery Note Item", {"against_sales_order": so.name, "docstatus": 1}):
frappe.db.sql("""update `tabSales Order` set per_delivered = 0,
delivery_status = 'Not Delivered' where name = %s""", so.name)
frappe.db.sql("""update `tabSales Order Item` set delivered_qty = 0
where parent = %s""", so.name)
if not frappe.db.exists("Sales Invoice Item", {"sales_order": so.name, "docstatus": 1}):
frappe.db.sql("""update `tabSales Order` set per_billed = 0,
billing_status = 'Not Billed' where name = %s""", so.name)
frappe.db.sql("""update `tabSales Order Item` set billed_amt = 0
where parent = %s""", so.name)
purchase_orders = frappe.db.sql("""select name from `tabPurchase Order`
where docstatus = 1 and ifnull(is_recurring, 0) = 1
and (per_received > 0 or per_billed > 0)""", as_dict=1)
for po in purchase_orders:
if not frappe.db.exists("Purchase Receipt Item", {"prevdoc_doctype": "Purchase Order",
"prevdoc_docname": po.name, "docstatus": 1}):
frappe.db.sql("""update `tabPurchase Order` set per_received = 0
where name = %s""", po.name)
frappe.db.sql("""update `tabPurchase Order Item` set received_qty = 0
where parent = %s""", po.name)
if not frappe.db.exists("Purchase Invoice Item", {"purchase_order": po.name, "docstatus": 1}):
frappe.db.sql("""update `tabPurchase Order` set per_billed = 0
where name = %s""", po.name)
frappe.db.sql("""update `tabPurchase Order Item` set billed_amt = 0
where parent = %s""", po.name)

View File

@ -1,117 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import print_function, unicode_literals
import frappe
def execute():
frappe.reload_doc("accounts", "doctype", "account")
frappe.reload_doc("setup", "doctype", "company")
frappe.reload_doc("accounts", "doctype", "gl_entry")
frappe.reload_doc("accounts", "doctype", "journal_entry_account")
receivable_payable_accounts = create_receivable_payable_account()
if receivable_payable_accounts:
set_party_in_jv_and_gl_entry(receivable_payable_accounts)
delete_individual_party_account()
remove_customer_supplier_account_report()
def create_receivable_payable_account():
receivable_payable_accounts = frappe._dict()
def _create_account(args):
if args["parent_account"] and frappe.db.exists("Account", args["parent_account"]):
account_id = frappe.db.get_value("Account",
{"account_name": args["account_name"], "company": args["company"]})
if not account_id:
account = frappe.new_doc("Account")
account.is_group = 0
account.update(args)
account.insert()
account_id = account.name
frappe.db.set_value("Company", args["company"], ("default_receivable_account"
if args["account_type"]=="Receivable" else "default_payable_account"), account_id)
receivable_payable_accounts.setdefault(args["company"], {}).setdefault(args["account_type"], account_id)
for company in frappe.db.sql_list("select name from tabCompany"):
_create_account({
"account_name": "Debtors",
"account_type": "Receivable",
"company": company,
"parent_account": get_parent_account(company, "Customer")
})
_create_account({
"account_name": "Creditors",
"account_type": "Payable",
"company": company,
"parent_account": get_parent_account(company, "Supplier")
})
return receivable_payable_accounts
def get_parent_account(company, master_type):
parent_account = None
if "receivables_group" in frappe.db.get_table_columns("Company"):
parent_account = frappe.get_cached_value('Company', company,
"receivables_group" if master_type=="Customer" else "payables_group")
if not parent_account:
parent_account = frappe.db.get_value("Account", {"company": company,
"account_name": "Accounts Receivable" if master_type=="Customer" else "Accounts Payable"})
if not parent_account:
parent_account = frappe.db.sql_list("""select parent_account from tabAccount
where company=%s and ifnull(master_type, '')=%s and ifnull(master_name, '')!='' limit 1""",
(company, master_type))
parent_account = parent_account[0][0] if parent_account else None
return parent_account
def set_party_in_jv_and_gl_entry(receivable_payable_accounts):
accounts = frappe.db.sql("""select name, master_type, master_name, company from `tabAccount`
where ifnull(master_type, '') in ('Customer', 'Supplier') and ifnull(master_name, '') != ''""", as_dict=1)
account_map = frappe._dict()
for d in accounts:
account_map.setdefault(d.name, d)
if not account_map:
return
for dt in ["Journal Entry Account", "GL Entry"]:
records = frappe.db.sql("""select name, account from `tab%s`
where account in (%s) and ifnull(party, '') = '' and docstatus < 2""" %
(dt, ", ".join(['%s']*len(account_map))), tuple(account_map.keys()), as_dict=1)
for i, d in enumerate(records):
account_details = account_map.get(d.account, {})
account_type = "Receivable" if account_details.get("master_type")=="Customer" else "Payable"
new_account = receivable_payable_accounts[account_details.get("company")][account_type]
frappe.db.sql("update `tab{0}` set account=%s, party_type=%s, party=%s where name=%s".format(dt),
(new_account, account_details.get("master_type"), account_details.get("master_name"), d.name))
if i%500 == 0:
frappe.db.commit()
def delete_individual_party_account():
frappe.db.sql("""delete from `tabAccount`
where ifnull(master_type, '') in ('Customer', 'Supplier')
and ifnull(master_name, '') != ''
and not exists(select gle.name from `tabGL Entry` gle
where gle.account = tabAccount.name)""")
accounts_not_deleted = frappe.db.sql_list("""select tabAccount.name from `tabAccount`
where ifnull(master_type, '') in ('Customer', 'Supplier')
and ifnull(master_name, '') != ''
and exists(select gle.name from `tabGL Entry` gle where gle.account = tabAccount.name)""")
if accounts_not_deleted:
print("Accounts not deleted: " + "\n".join(accounts_not_deleted))
def remove_customer_supplier_account_report():
for d in ["Customer Account Head", "Supplier Account Head"]:
frappe.delete_doc("Report", d)

View File

@ -1,16 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
for d in frappe.db.sql("select name from `tabBOM` where docstatus < 2"):
try:
document = frappe.get_doc('BOM', d[0])
if document.docstatus == 1:
document.flags.ignore_validate_update_after_submit = True
document.calculate_cost()
document.save()
except:
pass

View File

@ -1,34 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import print_function, unicode_literals
import frappe
from erpnext.stock.stock_ledger import NegativeStockError
def execute():
si_list = frappe.db.sql("""select distinct si.name
from `tabSales Invoice Item` si_item, `tabSales Invoice` si
where si.name = si_item.parent and si.modified > '2015-02-16' and si.docstatus=1
and ifnull(si_item.warehouse, '') = '' and ifnull(si.update_stock, 0) = 1
order by posting_date, posting_time""", as_dict=1)
failed_list = []
for si in si_list:
try:
si_doc = frappe.get_doc("Sales Invoice", si.name)
si_doc.docstatus = 2
si_doc.on_cancel()
si_doc.docstatus = 1
si_doc.set_missing_item_details()
si_doc.on_submit()
frappe.db.commit()
except:
failed_list.append(si.name)
frappe.local.stockledger_exceptions = None
frappe.db.rollback()
print("Failed to repost: ", failed_list)

View File

@ -1,31 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
import json
def execute():
existing_allow_negative_stock = frappe.db.get_value("Stock Settings", None, "allow_negative_stock")
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
head_row = ["Item Code", "Warehouse", "Quantity", "Valuation Rate"]
stock_reco_to_be_reposted = []
for d in frappe.db.sql("""select name, reconciliation_json from `tabStock Reconciliation`
where docstatus=1 and creation > '2014-03-01'""", as_dict=1):
data = json.loads(d.reconciliation_json)
for row in data[data.index(head_row)+1:]:
if row[3] in ["", None]:
stock_reco_to_be_reposted.append(d.name)
break
for dn in stock_reco_to_be_reposted:
reco = frappe.get_doc("Stock Reconciliation", dn)
reco.docstatus = 2
reco.on_cancel()
reco.docstatus = 1
reco.validate()
reco.on_submit()
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", existing_allow_negative_stock)

View File

@ -1,17 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc('manufacturing', 'doctype', 'bom_operation')
for d in frappe.db.sql("""select name from `tabBOM` where docstatus < 2""", as_dict=1):
try:
bom = frappe.get_doc('BOM', d.name)
bom.flags.ignore_validate_update_after_submit = True
bom.calculate_cost()
bom.save()
frappe.db.commit()
except:
frappe.db.rollback()

Some files were not shown because too many files have changed in this diff Show More