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

@@ -18,7 +18,7 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, flt, getdate
from webnotes.model.wrapper import getlist
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint

View File

@@ -20,7 +20,7 @@ import webnotes
from webnotes.utils import add_days, getdate, now
from webnotes.model import db_exists
from webnotes.model.doc import make_autoname
from webnotes.model.wrapper import copy_doclist
from webnotes.model.bean import copy_doclist
from webnotes import msgprint
sql = webnotes.conn.sql

View File

@@ -19,7 +19,7 @@ import webnotes
from webnotes.utils import cint, cstr, date_diff, formatdate, get_defaults, getdate, now
from webnotes.model import db_exists
from webnotes.model.wrapper import copy_doclist
from webnotes.model.bean import copy_doclist
from webnotes import form, msgprint
sql = webnotes.conn.sql

View File

@@ -79,7 +79,7 @@ class DocType:
from webnotes.profile import add_role
add_role(self.doc.user_id, "HR User")
profile_wrapper = webnotes.model_wrapper("Profile", self.doc.user_id)
profile_wrapper = webnotes.bean("Profile", self.doc.user_id)
# copy details like Fullname, DOB and Image to Profile
if self.doc.employee_name:

View File

@@ -18,7 +18,7 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days
from webnotes.model.wrapper import getlist
from webnotes.model.bean import getlist
from webnotes import form, msgprint
from webnotes.model.code import get_obj

View File

@@ -20,7 +20,7 @@ import webnotes
from webnotes.utils import add_days, add_years, cint, getdate
from webnotes.model import db_exists
from webnotes.model.doc import addchild, make_autoname
from webnotes.model.wrapper import copy_doclist
from webnotes.model.bean import copy_doclist
from webnotes import msgprint
sql = webnotes.conn.sql

View File

@@ -31,14 +31,14 @@ class JobsMailbox(POP3Mailbox):
name = webnotes.conn.get_value("Job Applicant", {"email_id": mail.from_email},
"name")
if name:
applicant = webnotes.model_wrapper("Job Applicant", name)
applicant = webnotes.bean("Job Applicant", name)
if applicant.doc.status!="Rejected":
applicant.doc.status = "Open"
applicant.doc.save()
else:
name = (mail.from_real_name and (mail.from_real_name + " - ") or "") \
+ mail.from_email
applicant = webnotes.model_wrapper({
applicant = webnotes.bean({
"creation": mail.date,
"doctype":"Job Applicant",
"applicant_name": name,

View File

@@ -5,18 +5,18 @@ from hr.doctype.leave_application.leave_application import LeaveDayBlockedError
class TestLeaveApplication(unittest.TestCase):
def get_application(self, doclist):
application = webnotes.model_wrapper(doclist)
application = webnotes.bean(copy=doclist)
application.doc.from_date = "2013-01-01"
application.doc.to_date = "2013-01-05"
return application
def test_block_list(self):
import webnotes
webnotes.conn.set_value("Employee", "_T-Employee-0001", "department",
"_Test Department with Block List")
webnotes.conn.set_value("Department", "_Test Department", "leave_block_list", "_Test Leave Block List")
application = self.get_application(test_records[1])
application.insert()
application.doc.status = "Approved"
self.assertRaises(LeaveDayBlockedError, application.submit)
webnotes.session.user = "test1@example.com"
@@ -45,6 +45,7 @@ class TestLeaveApplication(unittest.TestCase):
from webnotes.profile import add_role
add_role("test@example.com", "Leave Approver")
application.doc.status = "Approved"
self.assertRaises(LeaveDayBlockedError, application.submit)

View File

@@ -20,7 +20,7 @@ import webnotes
from webnotes.utils import cint, cstr, flt, now, nowdate
from webnotes.model import db_exists
from webnotes.model.doc import Document
from webnotes.model.wrapper import copy_doclist
from webnotes.model.bean import copy_doclist
from webnotes.model.code import get_obj
from webnotes import msgprint

View File

@@ -20,7 +20,7 @@ import webnotes
from webnotes.utils import cint, flt
from webnotes.model import db_exists
from webnotes.model.doc import Document
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.bean import getlist, copy_doclist
from webnotes.model.code import get_obj
from webnotes import msgprint

View File

@@ -19,7 +19,7 @@ import webnotes
from webnotes.utils import add_days, cint, cstr, flt, getdate
from webnotes.model.doc import make_autoname
from webnotes.model.wrapper import getlist
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint
from setup.utils import get_company_currency

View File

@@ -20,7 +20,7 @@ import webnotes
from webnotes.utils import cstr, flt
from webnotes.model import db_exists
from webnotes.model.doc import addchild, make_autoname
from webnotes.model.wrapper import copy_doclist
from webnotes.model.bean import copy_doclist
from webnotes import msgprint
sql = webnotes.conn.sql