model_wrapper is now bean, refactoring defaults

This commit is contained in:
Rushabh Mehta
2013-02-18 18:24:28 +05:30
parent 9c880da381
commit c53231a841
104 changed files with 351 additions and 163 deletions

View File

@@ -1,5 +1,5 @@
from __future__ import unicode_literals
def execute():
import webnotes
from webnotes.model.wrapper import ModelWrapper
ModelWrapper("Website Settings", "Website Settings").save()
from webnotes.model.bean import Bean
Bean("Website Settings", "Website Settings").save()

View File

@@ -4,10 +4,10 @@ def execute():
# new roles
roles = [r[0] for r in webnotes.conn.sql("""select name from tabRole""")]
if not "Leave Approver" in roles:
webnotes.model_wrapper([{"doctype":"Role", "role_name":"Leave Approver",
webnotes.bean([{"doctype":"Role", "role_name":"Leave Approver",
"__islocal":1, "module":"HR"}]).save()
if not "Expense Approver" in roles:
webnotes.model_wrapper([{"doctype":"Role", "role_name":"Expense Approver",
webnotes.bean([{"doctype":"Role", "role_name":"Expense Approver",
"__islocal":1, "module":"HR"}]).save()
# reload

View File

@@ -6,6 +6,8 @@ def execute():
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.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")

View File

@@ -1,7 +1,7 @@
import webnotes
def execute():
for name in webnotes.conn.sql("""select name from `tabHoliday List`"""):
holiday_list_wrapper = webnotes.model_wrapper("Holiday List", name[0])
holiday_list_wrapper = webnotes.bean("Holiday List", name[0])
desc_count = _count([d.description for d in
holiday_list_wrapper.doclist.get({"doctype": "Holiday"})])

View File

@@ -5,7 +5,7 @@ def execute():
webnotes.conn.sql("""update tabDocPerm set report = 0 where parent = %s""", dt[0])
doctype = webnotes.model_wrapper("DocType", dt[0])
doctype = webnotes.bean("DocType", dt[0])
for pl in [1, 2, 3]:
if not doctype.doclist.get({"doctype": "DocField", "permlevel": pl}):
if doctype.doclist.get({"doctype":"DocPerm", "permlevel":pl}):

View File

@@ -23,7 +23,7 @@ def move_remarks_to_comments():
where ifnull(remark, '')!=''""")
fullname_map = {}
for reco, remark, modified_by in result:
webnotes.model_wrapper([{
webnotes.bean([{
"doctype": "Comment",
"comment": remark,
"comment_by": modified_by,

View File

@@ -67,13 +67,13 @@ def save_pages():
}
import webnotes
from webnotes.model.wrapper import ModelWrapper
from webnotes.model.bean import Bean
import webnotes.modules.patch_handler
for dt in query_map:
for result in webnotes.conn.sql(query_map[dt], as_dict=1):
try:
ModelWrapper(dt, result['name'].encode('utf-8')).save()
Bean(dt, result['name'].encode('utf-8')).save()
except Exception, e:
webnotes.modules.patch_handler.log(unicode(e))