本文整理汇总了Python中webnotes.rename_doc函数的典型用法代码示例。如果您正苦于以下问题:Python rename_doc函数的具体用法?Python rename_doc怎么用?Python rename_doc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rename_doc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_or_update_sitemap
def add_or_update_sitemap(self):
page_name = self.get_page_name()
existing_page_name = webnotes.conn.get_value("Website Sitemap", {"ref_doctype": self.doc.doctype,
"docname": self.doc.name})
opts = webnotes._dict({
"page_or_generator": "Generator",
"ref_doctype":self.doc.doctype,
"docname": self.doc.name,
"page_name": page_name,
"link_name": self._website_config.name,
"lastmod": webnotes.utils.get_datetime(self.doc.modified).strftime("%Y-%m-%d"),
"parent_website_sitemap": self.doc.parent_website_sitemap,
"page_title": self.get_page_title() \
if hasattr(self, "get_page_title") else (self.doc.title or self.doc.name)
})
if self.meta.get_field("public_read"):
opts.public_read = self.doc.public_read
opts.public_write = self.doc.public_write
else:
opts.public_read = 1
if existing_page_name:
if existing_page_name != page_name:
webnotes.rename_doc("Website Sitemap", existing_page_name, page_name, ignore_permissions=True)
update_sitemap(page_name, opts)
else:
add_to_sitemap(opts)
示例2: execute
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)""")
示例3: execute
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)
示例4: on_rename
def on_rename(self, new, old):
#update customer_name if not naming series
if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name':
update_fields = [
('Customer', 'name'),
('Address', 'customer'),
('Contact', 'customer'),
('Customer Issue', 'customer'),
('Delivery Note', 'customer'),
('Opportunity', 'customer'),
('Installation Note', 'customer'),
('Maintenance Schedule', 'customer'),
('Maintenance Visit', 'customer'),
('Project', 'customer'),
('Quotation', 'customer'),
('Sales Invoice', 'customer'),
('Sales Order', 'customer'),
('Serial No', 'customer'),
('Shipping Address', 'customer'),
('Stock Entry', 'customer'),
('Support Ticket', 'customer')]
for rec in update_fields:
sql("""update `tab%s` set customer_name = %s
where `%s` = %s""" % (rec[0], "%s" ,rec[1], "%s"), (new, old))
for account in webnotes.conn.sql("""select name, account_name from
tabAccount where master_name=%s and master_type='Customer'""", old, as_dict=1):
if account.account_name != new:
webnotes.rename_doc("Account", account.name, new)
#update master_name in doctype account
webnotes.conn.sql("""update `tabAccount` set master_name = %s,
master_type = 'Customer' where master_name = %s""", (new,old))
示例5: test_rename
def test_rename(self):
self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1"),
(("_Test Customer 1",),))
webnotes.rename_doc("Customer", "_Test Customer 1", "_Test Customer 1 Renamed")
self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1 Renamed"),
(("_Test Customer 1 Renamed",),))
self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1"), ())
示例6: execute
def execute():
email_lead = {}
for name, email in webnotes.conn.sql("""select name, email_id from `tabLead`
where ifnull(email_id, '')!='' order by creation asc"""):
email = extract_email_id(email)
if email:
if email not in email_lead:
email_lead[email] = name
else:
webnotes.rename_doc("Lead", name, email_lead[email], force=True, merge=True)
示例7: rename_account_for
def rename_account_for(dt, olddn, newdn, merge, company):
old_account = get_account_for(dt, olddn)
if old_account:
new_account = None
if not merge:
if old_account == add_abbr_if_missing(olddn, company):
new_account = webnotes.rename_doc("Account", old_account, newdn)
else:
existing_new_account = get_account_for(dt, newdn)
new_account = webnotes.rename_doc("Account", old_account,
existing_new_account or newdn, merge=True if existing_new_account else False)
webnotes.conn.set_value("Account", new_account or old_account, "master_name", newdn)
示例8: on_rename
def on_rename(self, new, old, merge=False):
#update customer_name if not naming series
if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name':
webnotes.conn.sql("""update `tabCustomer` set customer_name = %s where name = %s""",
(new, old))
for account in webnotes.conn.sql("""select name, account_name from
tabAccount where master_name=%s and master_type='Customer'""", old, as_dict=1):
if account.account_name != new:
webnotes.rename_doc("Account", account.name, new, merge=merge)
#update master_name in doctype account
webnotes.conn.sql("""update `tabAccount` set master_name = %s,
master_type = 'Customer' where master_name = %s""", (new,old))
示例9: rename_account_for
def rename_account_for(dt, olddn, newdn, merge):
old_account = get_account_for(dt, olddn)
if old_account:
new_account = None
if not merge:
if old_account == olddn:
new_account = webnotes.rename_doc("Account", olddn, newdn)
else:
existing_new_account = get_account_for(dt, newdn)
new_account = webnotes.rename_doc("Account", old_account,
existing_new_account or newdn, merge=True if existing_new_account else False)
if new_account:
webnotes.conn.set_value("Account", new_account, "master_name", newdn)
示例10: rename_module
def rename_module():
webnotes.reload_doc("core", "doctype", "role")
webnotes.reload_doc("core", "doctype", "page")
webnotes.reload_doc("core", "doctype", "module_def")
if webnotes.conn.exists("Role", "Production User"):
webnotes.rename_doc("Role", "Production User", "Manufacturing User")
if webnotes.conn.exists("Role", "Production Manager"):
webnotes.rename_doc("Role", "Production Manager", "Manufacturing Manager")
if webnotes.conn.exists("Page", "manufacturing-home"):
webnotes.delete_doc("Page", "production-home")
else:
webnotes.rename_doc("Page", "production-home", "manufacturing-home")
if webnotes.conn.exists("Module Def", "Production"):
webnotes.rename_doc("Module Def", "Production", "Manufacturing")
modules_list = webnotes.conn.get_global('modules_list')
if modules_list:
webnotes.conn.set_global("modules_list", modules_list.replace("Production",
"Manufacturing"))
# set end of life to null if "0000-00-00"
webnotes.conn.sql("""update `tabItem` set end_of_life=null where end_of_life='0000-00-00'""")
示例11: execute
def execute():
webnotes.reload_doc("core", "doctype", "doctype")
tables = webnotes.conn.sql_list("show tables")
if "tabPacked Item" not in tables:
webnotes.rename_doc("DocType", "Delivery Note Packing Item", "Packed Item", force=True)
webnotes.reload_doc("stock", "doctype", "packed_item")
if os.path.exists("app/stock/doctype/delivery_note_packing_item"):
os.system("rm -rf app/stock/doctype/delivery_note_packing_item")
if webnotes.conn.exists("DocType", "Delivery Note Packing Item"):
webnotes.delete_doc("DocType", "Delivery Note Packing Item")
示例12: after_rename
def after_rename(self, old, new, merge=False):
#update customer_name if not naming series
if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name':
webnotes.conn.set(self.doc, "customer_name", new)
for account in webnotes.conn.sql("""select name, account_name from
tabAccount where master_name=%s and master_type='Customer'""", old, as_dict=1):
if account.account_name != new:
merge_account = True if merge and webnotes.conn.get_value("Account",
{"master_name": new, "master_type": "Customer"}) else False
webnotes.rename_doc("Account", account.name, new, merge=merge_account)
#update master_name in account record
webnotes.conn.sql("""update `tabAccount` set master_name = %s,
master_type = 'Customer' where master_name = %s""", (new, old))
示例13: rename_account
def rename_account(self, olddn, newdn, merge):
old_account = webnotes.conn.get_value("Account",
{"account_type": "Warehouse", "master_name": olddn})
if old_account:
new_account = None
if not merge:
if old_account == olddn:
new_account = webnotes.rename_doc("Account", olddn, newdn)
else:
existing_new_account = webnotes.conn.get_value("Account",
{"account_type": "Warehouse", "master_name": newdn})
new_account = webnotes.rename_doc("Account", old_account,
existing_new_account or newdn, merge=True if existing_new_account else False)
if new_account:
webnotes.conn.set_value("Account", new_account, "master_name", newdn)
示例14: execute
def execute():
from webnotes.utils import get_base_path
import shutil
webnotes.reload_doc("core", "doctype", "doctype")
tables = webnotes.conn.sql_list("show tables")
if "tabApplicable Territory" not in tables:
webnotes.rename_doc("DocType", "For Territory", "Applicable Territory", force=True)
webnotes.reload_doc("setup", "doctype", "applicable_territory")
path = os.path.join(get_base_path(), "app", "setup", "doctype", "for_territory")
if os.path.exists(path):
shutil.rmtree(path)
if webnotes.conn.exists("DocType", "For Territory"):
webnotes.delete_doc("DocType", "For Territory")
示例15: test_merge
def test_merge(self):
from webnotes.test_runner import make_test_records
make_test_records("Sales Invoice")
# clear transactions for new name
webnotes.conn.sql("""delete from `tabSales Invoice` where customer='_Test Customer 1'""")
# check if they exist
self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer"),
(("_Test Customer",),))
self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer 1"),
(("_Test Customer 1",),))
self.assertEqual(webnotes.conn.exists("Account", "_Test Customer - _TC"),
(("_Test Customer - _TC",),))
self.assertEqual(webnotes.conn.exists("Account", "_Test Customer 1 - _TC"),
(("_Test Customer 1 - _TC",),))
# check if transactions exists
self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
where customer='_Test Customer'""", )[0][0], 0)
self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
where debit_to='_Test Customer - _TC'""", )[0][0], 0)
webnotes.rename_doc("Customer", "_Test Customer", "_Test Customer 1", merge=True)
# check that no transaction exists for old name
self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
where customer='_Test Customer 1'""", )[0][0], 0)
self.assertNotEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
where debit_to='_Test Customer 1 - _TC'""", )[0][0], 0)
# check that transactions exist for new name
self.assertEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
where customer='_Test Customer'""", )[0][0], 0)
self.assertEquals(webnotes.conn.sql("""select count(*) from `tabSales Invoice`
where debit_to='_Test Customer - _TC'""", )[0][0], 0)
# check that old name doesn't exist
self.assertEqual(webnotes.conn.exists("Customer", "_Test Customer"), ())
self.assertEqual(webnotes.conn.exists("Account", "_Test Customer - _TC"), ())
# create back _Test Customer
webnotes.bean(copy=test_records[0]).insert()