def execute():
	webnotes.reload_doc("stock", "doctype", "price_list")
	webnotes.reload_doc("stock", "doctype", "item_price")

	webnotes.conn.sql("""update `tabPrice List` pl, `tabItem Price` ip 
		set pl.selling=ip.selling, pl.buying=ip.buying 
		where pl.name=ip.price_list_name""")
def execute():
	import webnotes
	webnotes.reload_doc("setup", "doctype", "global_defaults")
	
	gd = webnotes.bean('Global Defaults')
	gd.doc.maintain_same_sales_rate = 1
	gd.save()
def execute():
	webnotes.reload_doc("Accounts", "DocType", "Sales Taxes and Charges")
	webnotes.conn.sql("""update `tabSales Taxes and Charges`
		set cost_center = cost_center_other_charges""")
	webnotes.conn.sql_ddl("""alter table `tabSales Taxes and Charges`
		drop column cost_center_other_charges""")
	
Beispiel #4
0
def execute():
	webnotes.reload_doc("hr", "doctype", "leave_application")
	
	if not webnotes.get_doctype("Leave Application").get({"doctype": "DocField", 
			"parent": "Leave Application", "permlevel": 2}):
		webnotes.conn.sql("""update `tabDocPerm` set permlevel=1 
			where parent="Leave Application" and permlevel=2""")
Beispiel #5
0
def pre_import():
	webnotes.conn.begin()
	make_modules()
	make_roles()
	webnotes.conn.commit()
	webnotes.reload_doc("utilities", "doctype", "gl_mapper")
	webnotes.reload_doc("utilities", "doctype", "gl_mapper_detail")
def execute():
	webnotes.reload_doc("setup", "doctype", "company")
	create_chart_of_accounts_if_not_exists()
	add_group_accounts()
	add_ledger_accounts()
	add_aii_cost_center()
	set_default_accounts()
Beispiel #7
0
def execute():
    webnotes.reload_doc("setup", "doctype", "email_digest")

    from webnotes.profile import get_system_managers
    system_managers = get_system_managers(only_name=True)
    if not system_managers:
        return

    # no default company
    company = webnotes.conn.sql_list("select name from `tabCompany`")
    if company:
        company = company[0]
    if not company:
        return

    # scheduler errors digest
    edigest = webnotes.new_bean("Email Digest")
    edigest.doc.fields.update({
        "name": "Scheduler Errors",
        "company": company,
        "frequency": "Daily",
        "enabled": 1,
        "recipient_list": "\n".join(system_managers),
        "scheduler_errors": 1
    })
    edigest.insert()
Beispiel #8
0
def execute():
	webnotes.reload_doc("Accounts", "DocType", "Sales Taxes and Charges")
	webnotes.conn.sql("""update `tabSales Taxes and Charges`
		set cost_center = cost_center_other_charges""")
	webnotes.conn.sql_ddl("""alter table `tabSales Taxes and Charges`
		drop column cost_center_other_charges""")
	
Beispiel #9
0
def pre_import():
	webnotes.conn.begin()
	make_modules()
	make_roles()
	webnotes.conn.commit()
	webnotes.reload_doc("utilities", "doctype", "gl_mapper")
	webnotes.reload_doc("utilities", "doctype", "gl_mapper_detail")
def execute():
	webnotes.clear_perms("Leave Application")
	webnotes.reload_doc("hr", "doctype", "leave_application")
	webnotes.conn.sql("""update `tabLeave Application` set status='Approved'
		where docstatus=1""")
	webnotes.conn.sql("""update `tabLeave Application` set status='Open'
		where docstatus=0""")		
def execute():
	webnotes.reload_doc("stock", "doctype", "delivery_note_item")
	webnotes.reload_doc("accounts", "doctype", "sales_invoice_item")

	webnotes.conn.auto_commit_on_many_writes = True
	for company in webnotes.conn.sql("select name from `tabCompany`"):
		stock_ledger_entries = webnotes.conn.sql("""select item_code, voucher_type, voucher_no,
			voucher_detail_no, posting_date, posting_time, stock_value, 
			warehouse, actual_qty as qty from `tabStock Ledger Entry` 
			where ifnull(`is_cancelled`, "No") = "No" and company = %s
			order by item_code desc, warehouse desc, 
			posting_date desc, posting_time desc, name desc""", company[0], as_dict=True)
		
		dn_list = webnotes.conn.sql("""select name from `tabDelivery Note` 
			where docstatus < 2 and company = %s""", company[0])
		
		for dn in dn_list:
			dn = webnotes.get_obj("Delivery Note", dn[0], with_children = 1)
			dn.set_buying_amount(stock_ledger_entries)
		
		si_list = webnotes.conn.sql("""select name from `tabSales Invoice` 
			where docstatus < 2	and company = %s""", company[0])
		for si in si_list:
			si = webnotes.get_obj("Sales Invoice", si[0], with_children = 1)
			si.set_buying_amount(stock_ledger_entries)
		
	webnotes.conn.auto_commit_on_many_writes = False
def execute():
	webnotes.reload_doc("stock", "doctype", "item_price")
	
	# check for selling
	webnotes.conn.sql("""update `tabItem Price` set selling=1
		where ifnull(selling, 0)=0 and ifnull(buying, 0)=0""")
	
Beispiel #13
0
def execute():
    from webnotes.country_info import get_all
    data = get_all()

    webnotes.reload_doc("setup", "doctype", "country")
    webnotes.reload_doc("setup", "doctype", "currency")

    for c in webnotes.conn.sql("""select name from tabCountry"""):
        if c[0] in data:
            info = webnotes._dict(data[c[0]])
            doc = webnotes.doc("Country", c[0])
            doc.date_format = info.date_format or "dd-mm-yyyy"
            doc.time_zones = "\n".join(info.timezones or [])
            doc.save()

            if webnotes.conn.exists("Currency", info.currency):
                doc = webnotes.doc("Currency", info.currency)
                doc.fields.update({
                    "fraction":
                    info.currency_fraction,
                    "symbol":
                    info.currency_symbol,
                    "fraction_units":
                    info.currency_fraction_units
                })
                doc.save()
Beispiel #14
0
def execute():
	webnotes.reload_doc("core", "doctype", "docfield")
	webnotes.reload_doc("support", "doctype", "support_ticket")
	
	# customer issue resolved_by should be Profile
	if webnotes.conn.sql("""select count(*) from `tabCustomer Issue` 
		where ifnull(resolved_by,"")!="" """)[0][0]:
		webnotes.make_property_setter({
			"doctype":"Customer Issue", 
			"fieldname": "resolved_by", 
			"property": "options",
			"value": "Sales Person"
		})
		
	def get_communication_time(support_ticket, sort_order = 'asc'):
		tmp = webnotes.conn.sql("""select creation from tabCommunication where
			support_ticket=%s order by creation %s limit 1""" % ("%s", sort_order), 
			support_ticket)
		return tmp and tmp[0][0] or None
		
	# update in support ticket
	webnotes.conn.auto_commit_on_many_writes = True
	for st in webnotes.conn.sql("""select name, modified, status from 
		`tabSupport Ticket`""", as_dict=1):
		
		webnotes.conn.sql("""update `tabSupport Ticket` set first_responded_on=%s where 
			name=%s""", (get_communication_time(st.name) or st.modified, st.name))
		if st.status=="Closed":
			webnotes.conn.sql("""update `tabSupport Ticket` set resolution_date=%s where 
				name=%s""", (get_communication_time(st.name, 'desc') or st.modified, st.name))
def execute():
	webnotes.reload_doc("stock", "doctype", "stock_ledger_entry")
	webnotes.reload_doc("stock", "doctype", "stock_reconciliation")
	
	rename_fields()
	move_remarks_to_comments()
	store_stock_reco_json()
Beispiel #16
0
def execute():
    webnotes.reload_doc("setup", "doctype", "company")
    create_chart_of_accounts_if_not_exists()
    add_group_accounts()
    add_ledger_accounts()
    add_aii_cost_center()
    set_default_accounts()
Beispiel #17
0
def execute():
	webnotes.reload_doc("utilities", "doctype", "note")
	webnotes.reload_doc("utilities", "doctype", "note_user")
	
	for question in webnotes.conn.sql("""select * from tabQuestion""", as_dict=True):
		if question.question:
			try:
				name = question.question[:180]
				if webnotes.conn.exists("Note", name):
					webnotes.delete_doc("Note", name)
				note = webnotes.bean({
					"doctype":"Note",
					"title": name,
					"content": "<hr>".join([markdown2.markdown(c) for c in webnotes.conn.sql_list("""
						select answer from tabAnswer where question=%s""", question.name)]),
					"owner": question.owner,
					"creation": question.creation,
					"public": 1
				}).insert()
			except NameError:
				pass

	webnotes.delete_doc("DocType", "Question")
	webnotes.delete_doc("DocType", "Answer")
	webnotes.bean("Style Settings").save()
	
	# update comment delete
	webnotes.conn.sql("""update tabDocPerm \
		set cancel=1 where parent='Comment' and role='System Manager'""")
Beispiel #18
0
def execute():
	webnotes.reload_doc("stock", "doctype", "item_price")
	
	# check for selling
	webnotes.conn.sql("""update `tabItem Price` set buying_or_selling = "Selling"
		where ifnull(buying_or_selling, '')=''""")
	
Beispiel #19
0
def execute():
	import webnotes
	webnotes.reload_doc("buying", "doctype", "purchase_order_item")
	webnotes.reload_doc("stock", "doctype", "purchase_receipt_item")
	for pi in webnotes.conn.sql("""select name from `tabPurchase Invoice` where docstatus = 1"""):
		webnotes.get_obj("Purchase Invoice", pi[0], 
			with_children=1).update_qty(change_modified=False)
def execute():
    webnotes.reload_doc("stock", "doctype", "delivery_note_item")
    webnotes.reload_doc("accounts", "doctype", "sales_invoice_item")

    webnotes.conn.auto_commit_on_many_writes = True
    for company in webnotes.conn.sql("select name from `tabCompany`"):
        stock_ledger_entries = webnotes.conn.sql(
            """select item_code, voucher_type, voucher_no,
			voucher_detail_no, posting_date, posting_time, stock_value, 
			warehouse, actual_qty as qty from `tabStock Ledger Entry` 
			where ifnull(`is_cancelled`, "No") = "No" and company = %s
			order by item_code desc, warehouse desc, 
			posting_date desc, posting_time desc, name desc""",
            company[0],
            as_dict=True)

        dn_list = webnotes.conn.sql(
            """select name from `tabDelivery Note` 
			where docstatus < 2 and company = %s""", company[0])

        for dn in dn_list:
            dn = webnotes.get_obj("Delivery Note", dn[0], with_children=1)
            dn.set_buying_amount(stock_ledger_entries)

        si_list = webnotes.conn.sql(
            """select name from `tabSales Invoice` 
			where docstatus < 2	and company = %s""", company[0])
        for si in si_list:
            si = webnotes.get_obj("Sales Invoice", si[0], with_children=1)
            si.set_buying_amount(stock_ledger_entries)

    webnotes.conn.auto_commit_on_many_writes = False
Beispiel #21
0
def execute():
    webnotes.reload_doc("core", "doctype", "docfield")
    webnotes.reload_doc("support", "doctype", "support_ticket")

    # customer issue resolved_by should be Profile
    if webnotes.conn.sql("""select count(*) from `tabCustomer Issue` 
		where ifnull(resolved_by,"")!="" """)[0][0]:
        webnotes.make_property_setter({
            "doctype": "Customer Issue",
            "fieldname": "resolved_by",
            "property": "options",
            "value": "Sales Person"
        })

    def get_communication_time(support_ticket, sort_order='asc'):
        tmp = webnotes.conn.sql(
            """select creation from tabCommunication where
			support_ticket=%s order by creation %s limit 1""" % ("%s", sort_order),
            support_ticket)
        return tmp and tmp[0][0] or None

    # update in support ticket
    webnotes.conn.auto_commit_on_many_writes = True
    for st in webnotes.conn.sql("""select name, modified, status from 
		`tabSupport Ticket`""",
                                as_dict=1):

        webnotes.conn.sql(
            """update `tabSupport Ticket` set first_responded_on=%s where 
			name=%s""", (get_communication_time(st.name) or st.modified, st.name))
        if st.status == "Closed":
            webnotes.conn.sql(
                """update `tabSupport Ticket` set resolution_date=%s where 
				name=%s""", (get_communication_time(st.name, 'desc')
                 or st.modified, st.name))
def execute():
	webnotes.reload_doc("stock", "doctype", "delivery_note_item")
	webnotes.conn.sql("""update `tabDelivery Note Item` set against_sales_order=prevdoc_docname
		where prevdoc_doctype='Sales Order' """)
		
	webnotes.conn.sql("""update `tabDelivery Note Item` set against_sales_invoice=prevdoc_docname
		where prevdoc_doctype='Sales Invoice' """)
def execute():
    import webnotes
    import webnotes.model.doc
    webnotes.conn.sql(
        "delete from `tabDocPerm` where parent='Profile' and permlevel=1")
    new_perms = [
        {
            'parent': 'Profile',
            'parentfield': 'permissions',
            'parenttype': 'DocType',
            'role': 'Administrator',
            'permlevel': 1,
            'read': 1,
            'write': 1
        },
        {
            'parent': 'Profile',
            'parentfield': 'permissions',
            'parenttype': 'DocType',
            'role': 'System Manager',
            'permlevel': 1,
            'read': 1,
            'write': 1
        },
    ]
    for perms in new_perms:
        doc = webnotes.model.doc.Document('DocPerm')
        doc.fields.update(perms)
        doc.save()
    webnotes.conn.commit()
    webnotes.conn.begin()

    webnotes.reload_doc('core', 'doctype', 'profile')
def execute():
	webnotes.reload_doc("utilities", "doctype", "note")
	webnotes.reload_doc("utilities", "doctype", "note_user")
	
	for question in webnotes.conn.sql("""select * from tabQuestion""", as_dict=True):
		if question.question:
			try:
				name = question.question[:180]
				if webnotes.conn.exists("Note", name):
					webnotes.delete_doc("Note", name)

				similar_questions = webnotes.conn.sql_list("""select name from `tabQuestion`
					where question like %s""", "%s%%" % name)
				answers = [markdown2.markdown(c) for c in webnotes.conn.sql_list("""
						select answer from tabAnswer where question in (%s)""" % \
						", ".join(["%s"]*len(similar_questions)), similar_questions)]

				webnotes.bean({
					"doctype":"Note",
					"title": name,
					"content": "<hr>".join(answers),
					"owner": question.owner,
					"creation": question.creation,
					"public": 1
				}).insert()
			
			except NameError:
				pass
			except Exception, e:
				if e.args[0] != 1062:
					raise
def change_property_setter_fieldnames():
    webnotes.reload_doc('core', 'doctype', 'property_setter')
    docfield_list = webnotes.conn.sql("""\
		SELECT name, fieldname FROM `tabDocField`""",
                                      as_list=1)
    custom_field_list = webnotes.conn.sql("""\
		SELECT name, fieldname FROM `tabCustom Field`""",
                                          as_list=1)
    field_list = docfield_list + custom_field_list
    property_setter_list = webnotes.conn.sql("""\
		SELECT name, doc_name, value, property
		FROM `tabProperty Setter`
		WHERE doctype_or_field='DocField'""")
    field_dict = dict(field_list)
    for name, doc_name, value, prop in property_setter_list:
        if doc_name in field_dict:
            webnotes.conn.sql(
                """\
				UPDATE `tabProperty Setter`
				SET field_name = %s
				WHERE name = %s""", (field_dict.get(doc_name), name))
        if value in field_dict and prop == 'previous_field':
            webnotes.conn.sql(
                """\
				UPDATE `tabProperty Setter`
				SET value = %s
				WHERE name = %s""", (field_dict.get(value), name))
Beispiel #26
0
def execute():
    webnotes.reload_doc("utilities", "doctype", "note")
    webnotes.reload_doc("utilities", "doctype", "note_user")

    for question in webnotes.conn.sql("""select * from tabQuestion""",
                                      as_dict=True):
        if question.question:
            try:
                name = question.question[:180]
                if webnotes.conn.exists("Note", name):
                    webnotes.delete_doc("Note", name)

                similar_questions = webnotes.conn.sql_list(
                    """select name from `tabQuestion`
					where question like %s""", "%s%%" % name)
                answers = [markdown2.markdown(c) for c in webnotes.conn.sql_list("""
						select answer from tabAnswer where question in (%s)""" % \
                  ", ".join(["%s"]*len(similar_questions)), similar_questions)]

                webnotes.bean({
                    "doctype": "Note",
                    "title": name,
                    "content": "<hr>".join(answers),
                    "owner": question.owner,
                    "creation": question.creation,
                    "public": 1
                }).insert()

            except NameError:
                pass
            except Exception, e:
                if e.args[0] != 1062:
                    raise
Beispiel #27
0
def execute():
	webnotes.reload_doc("stock", "doctype", "item_price")
	
	# check for selling
	webnotes.conn.sql("""update `tabItem Price` set buying_or_selling = "Selling"
		where ifnull(buying_or_selling, '')=''""")
	
def execute():
    import webnotes
    webnotes.conn.sql("""delete from `tabSearch Criteria` \
		where name = 'customer_address_contact'""")

    webnotes.reload_doc("core", "doctype", "report")
    webnotes.reload_doc('selling', 'report', 'customer_addresses_and_contacts')
def execute():
	import webnotes
	webnotes.reload_doc('stock', 'doctype', 'packed_item')
	for si in webnotes.conn.sql("""select name from `tabSales Invoice` where docstatus = 1"""):
		webnotes.get_obj("Sales Invoice", si[0], 
			with_children=1).update_qty(change_modified=False)
		webnotes.conn.commit()
def execute():
    import webnotes
    webnotes.reload_doc("setup", "doctype", "global_defaults")

    gd = webnotes.bean('Global Defaults')
    gd.doc.maintain_same_sales_rate = 1
    gd.save()
def execute():
	import webnotes
	import webnotes.model.doc
	webnotes.conn.sql("delete from `tabDocPerm` where parent='Profile' and permlevel=1")
	new_perms = [
		{
			'parent': 'Profile',
			'parentfield': 'permissions',
			'parenttype': 'DocType',
			'role': 'Administrator',			
			'permlevel': 1,
			'read': 1,
			'write': 1
		},
		{
			'parent': 'Profile',
			'parentfield': 'permissions',
			'parenttype': 'DocType',
			'role': 'System Manager',
			'permlevel': 1,
			'read': 1,
			'write': 1
		},
		
	]
	for perms in new_perms:
		doc = webnotes.model.doc.Document('DocPerm')
		doc.fields.update(perms)
		doc.save()
	webnotes.conn.commit()
	webnotes.conn.begin()
	
	webnotes.reload_doc('core', 'doctype', 'profile')
Beispiel #32
0
def execute():
    import webnotes
    webnotes.conn.sql("""
		delete from `tabSingles`
		where doctype='Notification Control'
		and field in (
			'payable_voucher',
			'payment_received_message',
			'payment_sent_message',
			'enquiry')
	""")
    ren_list = [
        ['expense_voucher', 'expense_claim'],
        ['receivable_voucher', 'sales_invoice'],
        ['enquiry', 'opportunity'],
    ]
    for r in ren_list:
        webnotes.conn.sql(
            """
			update `tabSingles`
			set field=%s
			where field=%s
			and doctype='Notification Control'
		""", (r[1], r[0]))

    webnotes.conn.commit()
    webnotes.conn.begin()
    webnotes.reload_doc('setup', 'doctype', 'notification_control')
def execute():
    webnotes.reload_doc("core", "doctype", "communication")
    webnotes.conn.commit()
    for d in webnotes.conn.sql(
            """select owner, creation, modified, modified_by, parent, 
		from_email, mail from `tabSupport Ticket Response`""",
            as_dict=1):
        c = webnotes.doc("Communication")
        c.creation = d.creation
        c.owner = d.owner
        c.modified = d.modified
        c.modified_by = d.modified_by
        c.naming_series = "COMM-"
        c.subject = "response to Support Ticket: " + d.parent
        c.content = d.mail
        c.email_address = d.from_email
        c.support_ticket = d.parent
        email_addr = email.utils.parseaddr(c.email_address)[1]
        c.contact = webnotes.conn.get_value(
            "Contact", {"email_id": email_addr}, "name") or None
        c.lead = webnotes.conn.get_value("Lead", {"email_id": email_addr},
                                         "name") or None
        c.communication_medium = "Email"
        webnotes.conn.begin()
        c.save(1, keep_timestamps=True)
        webnotes.conn.commit()

    webnotes.delete_doc("DocType", "Support Ticket Response")
Beispiel #34
0
def execute():
    webnotes.reload_doc("core", "doctype", "communication")
    webnotes.conn.sql("""update tabCommunication set sender=email_address 
		where ifnull(support_ticket,'') != ''""")
    webnotes.conn.sql(
        """update tabCommunication set recipients=email_address where
		ifnull(sender,'')=''""")
Beispiel #35
0
def execute():
    webnotes.reload_doc("stock", "doctype", "stock_ledger_entry")
    webnotes.reload_doc("stock", "doctype", "stock_reconciliation")

    rename_fields()
    move_remarks_to_comments()
    store_stock_reco_json()
def execute():
    import webnotes
    webnotes.reload_doc('accounts', 'doctype', 'sales_invoice')

    webnotes.conn.sql(
        "update `tabSales Invoice` set recurring_type = 'Monthly' where ifnull(convert_into_recurring_invoice, 0) = 1"
    )
Beispiel #37
0
def execute():
    # new roles
    roles = [r[0] for r in webnotes.conn.sql("""select name from tabRole""")]
    if not "Leave Approver" in roles:
        webnotes.bean([{
            "doctype": "Role",
            "role_name": "Leave Approver",
            "__islocal": 1,
            "module": "HR"
        }]).save()
    if not "Expense Approver" in roles:
        webnotes.bean([{
            "doctype": "Role",
            "role_name": "Expense Approver",
            "__islocal": 1,
            "module": "HR"
        }]).save()

    # reload
    webnotes.clear_perms("Leave Application")
    webnotes.reload_doc("hr", "doctype", "leave_application")

    webnotes.clear_perms("Expense Claim")
    webnotes.reload_doc("hr", "doctype", "expense_claim")

    # remove extra space in Approved Expense Vouchers
    webnotes.conn.sql(
        """update `tabExpense Claim` set approval_status='Approved'
		where approval_status='Approved '""")

    webnotes.conn.commit()
    for t in ['__CacheItem', '__SessionCache', 'tabSupport Ticket Response']:
        webnotes.conn.sql("drop table if exists `%s`" % t)
def execute():
	import webnotes
	webnotes.conn.sql("""delete from `tabSearch Criteria` \
		where name = 'customer_address_contact'""")
	
	webnotes.reload_doc("core", "doctype", "report")
	webnotes.reload_doc('selling', 'report', 'customer_addresses_and_contacts')
def execute():
	webnotes.reload_doc("core", "doctype", "event")
	webnotes.conn.sql("""delete from `tabEvent` where repeat_on='Every Year' and ref_type='Employee'""")
	for employee in webnotes.conn.sql_list("""select name from `tabEmployee` where status='Active' and 
		ifnull(date_of_birth, '')!=''"""):
			obj = webnotes.get_obj("Employee", employee)
			obj.update_dob_event()
def execute():
	import webnotes
	webnotes.conn.sql("""
		delete from `tabSingles`
		where doctype='Notification Control'
		and field in (
			'payable_voucher',
			'payment_received_message',
			'payment_sent_message',
			'enquiry')
	""")
	ren_list = [
		['expense_voucher', 'expense_claim'],
		['receivable_voucher', 'sales_invoice'],
		['enquiry', 'opportunity'],
	]
	for r in ren_list:
		webnotes.conn.sql("""
			update `tabSingles`
			set field=%s
			where field=%s
			and doctype='Notification Control'
		""", (r[1], r[0]))
	
	webnotes.conn.commit()
	webnotes.conn.begin()
	webnotes.reload_doc('setup', 'doctype', 'notification_control')
def execute():
	webnotes.reload_doc("core", "doctype", "event")
	webnotes.conn.sql("""delete from `tabEvent` where repeat_on='Every Year' and ref_type='Employee'""")
	for employee in webnotes.conn.sql_list("""select name from `tabEmployee` where status='Active' and 
		ifnull(date_of_birth, '')!=''"""):
			obj = webnotes.get_obj("Employee", employee)
			obj.update_dob_event()
def execute():
	webnotes.reload_doc('website', 'doctype', 'blogger')
	webnotes.rename_doc("DocType", "Blog", "Blog Post", force=True)
	webnotes.reload_doc('website', 'doctype', 'blog_post')
	webnotes.conn.sql('''update tabBlogger set posts=(select count(*) 
		from `tabBlog Post` where ifnull(blogger,"")=tabBlogger.name)''')
	webnotes.conn.sql("""update `tabBlog Post` set published_on=date(creation)""")
def execute():
	webnotes.reload_doc("core", "doctype", "doctype")
	
	tables = webnotes.conn.sql_list("show tables")
	if not "tabMaterial Request Item" in tables:
		webnotes.rename_doc("DocType", "Purchase Request Item", "Material Request Item", force=True)
	if not "tabMaterial Request" in tables:
		webnotes.rename_doc("DocType", "Purchase Request", "Material Request", force=True)
	webnotes.reload_doc("buying", "search_criteria", "pending_po_items_to_bill")
	webnotes.reload_doc("buying", "search_criteria", "pending_po_items_to_receive")

	webnotes.reload_doc("stock", "doctype", "material_request")
	webnotes.reload_doc("stock", "doctype", "material_request_item")
	
	webnotes.conn.sql("""update `tabMaterial Request` set material_request_type='Purchase'""")
	
	os.system("rm -rf app/buying/doctype/purchase_request")
	os.system("rm -rf app/buying/doctype/purchase_request_item")
	
	os.system("rm -rf app/hr/doctype/holiday_block_list")
	os.system("rm -rf app/hr/doctype/holiday_block_list_allow")
	os.system("rm -rf app/hr/doctype/holiday_block_list_date")
	
	for dt in ("Purchase Request", "Purchase Request Item"):
		if webnotes.conn.exists("DocType", dt):
			webnotes.delete_doc("DocType", dt)
def execute():
	webnotes.reload_doc("setup", "doctype", "email_digest")
	
	from webnotes.profile import get_system_managers
	system_managers = get_system_managers(only_name=True)
	if not system_managers: 
		return
	
	# no default company
	company = webnotes.conn.get_default("company")
	if not company:
		company = webnotes.conn.sql_list("select name from `tabCompany`")
		if company:
			company = company[0]
	if not company:
		return
	
	# scheduler errors digest
	edigest = webnotes.new_bean("Email Digest")
	edigest.doc.fields.update({
		"name": "Scheduler Errors",
		"company": company,
		"frequency": "Daily",
		"enabled": 1,
		"recipient_list": "\n".join(system_managers),
		"scheduler_errors": 1
	})
	edigest.insert()
def execute():
    import webnotes
    webnotes.reload_doc('stock', 'doctype', 'packed_item')
    for si in webnotes.conn.sql(
            """select name from `tabSales Invoice` where docstatus = 1"""):
        webnotes.get_obj("Sales Invoice", si[0],
                         with_children=1).update_qty(change_modified=False)
        webnotes.conn.commit()
def execute():
    webnotes.reload_doc('website', 'doctype', 'blogger')
    webnotes.rename_doc("DocType", "Blog", "Blog Post", force=True)
    webnotes.reload_doc('website', 'doctype', 'blog_post')
    webnotes.conn.sql('''update tabBlogger set posts=(select count(*) 
		from `tabBlog Post` where ifnull(blogger,"")=tabBlogger.name)''')
    webnotes.conn.sql(
        """update `tabBlog Post` set published_on=date(creation)""")
def execute():
    webnotes.reload_doc("core", "doctype", "patch_log")
    if webnotes.conn.table_exists("__PatchLog"):
        for d in webnotes.conn.sql("""select patch from __PatchLog"""):
            webnotes.doc({"doctype": "Patch Log", "patch": d[0]}).insert()

        webnotes.conn.commit()
        webnotes.conn.sql("drop table __PatchLog")
def execute():
	"""allow read permission to all for report list"""
	import webnotes
	webnotes.conn.sql("""\
		delete from `tabDocPerm`
		where parent in ('Report', 'Search Criteria')""")
	
	webnotes.reload_doc('core', 'doctype', 'report')
def execute():
	for dt, fieldname in \
		(("Journal Voucher Detail", "cost_center"), 
		("Sales Taxes and Charges", "cost_center_other_charges"), 
		("Purchase Taxes and Charges", "cost_center"), ("Delivery Note Item", "cost_center"),
		("Purchase Invoice Item", "cost_center"), ("Sales Invoice Item", "cost_center")):
			webnotes.conn.sql_ddl("""alter table `tab%s` alter `%s` drop default""" % (dt, fieldname))
			webnotes.reload_doc(webnotes.conn.get_value("DocType", dt, "module"), "DocType", dt)
def execute():
    import webnotes

    webnotes.reload_doc("stock", "doctype", "delivery_note")
    webnotes.conn.sql(
        """update `tabDelivery Note` set shipping_address_name = customer_address, 
		shipping_address = address_display"""
    )
def execute():
	webnotes.reload_doc("core", "doctype", "doctype")
	webnotes.clear_perms("Leave Application")
	webnotes.reload_doc("hr", "doctype", "leave_application")
	webnotes.conn.sql("""update `tabLeave Application` set status='Approved'
		where docstatus=1""")
	webnotes.conn.sql("""update `tabLeave Application` set status='Open'
		where docstatus=0""")		
Beispiel #52
0
def execute():
    """allow read permission to all for report list"""
    import webnotes
    webnotes.conn.sql("""\
		delete from `tabDocPerm`
		where parent in ('Report', 'Search Criteria')""")

    webnotes.reload_doc('core', 'doctype', 'report')
def execute():
    webnotes.reload_doc("Stock", "DocType", "Delivery Note Item")
    for dt in ("Journal Voucher Detail", "Sales Taxes and Charges", 
		"Purchase Taxes and Charges", "Delivery Note Item", 
		"Purchase Invoice Item", "Sales Invoice Item"):
			webnotes.conn.sql_ddl("""alter table `tab%s` alter `cost_center` drop default""" \
				% (dt,))
			webnotes.reload_doc(webnotes.conn.get_value("DocType", dt, "module"), "DocType", dt)
Beispiel #54
0
def execute():
    webnotes.reload_doc("Stock", "DocType", "Delivery Note Item")
    for dt in ("Journal Voucher Detail", "Sales Taxes and Charges", 
		"Purchase Taxes and Charges", "Delivery Note Item", 
		"Purchase Invoice Item", "Sales Invoice Item"):
			webnotes.conn.sql_ddl("""alter table `tab%s` alter `cost_center` drop default""" \
				% (dt,))
			webnotes.reload_doc(webnotes.conn.get_value("DocType", dt, "module"), "DocType", dt)
def execute():
	webnotes.reload_doc("selling", "doctype", "shopping_cart_settings")
	
	# create two default territories, one for home country and one named Rest of the World
	from setup.page.setup_wizard.setup_wizard import create_territories
	create_territories()
	
	webnotes.conn.set_value("Shopping Cart Settings", None, "default_territory", "Rest of the World")
	
Beispiel #56
0
def execute():
    webnotes.reload_doc("website", "doctype", "shopping_cart_settings")

    # create two default territories, one for home country and one named Rest of the World
    from setup.doctype.setup_control.setup_control import create_territories
    create_territories()

    webnotes.conn.set_value("Shopping Cart Settings", None,
                            "default_territory", "Rest of the World")
def execute():
	webnotes.reload_doc("support", "doctype", "support_ticket")
	webnotes.reload_doc("core", "doctype", "communication")
	for d in webnotes.conn.sql("""select name, raised_by from `tabSupport Ticket` 
			where docstatus < 2""", as_dict=True):
		tic = webnotes.get_obj("Support Ticket", d.name)
		tic.set_lead_contact(d.raised_by)
		webnotes.conn.sql("""update `tabSupport Ticket` set lead = %s, contact = %s, company = %s 
			where name = %s""", (tic.doc.lead, tic.doc.contact, tic.doc.company, d.name))