Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Rushabh Mehta 2013-08-28 14:07:04 +05:30
commit 8ba2f6396b
5 changed files with 49 additions and 18 deletions

View File

@ -340,7 +340,7 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
and batch_no like '%(txt)s'
and exists(select * from `tabBatch`
where name = sle.batch_no
and expiry_date >= '%(posting_date)s'
and (ifnull(expiry_date, '')='' or expiry_date >= '%(posting_date)s')
and docstatus != 2)
%(mcond)s
group by batch_no having sum(actual_qty) > 0
@ -353,11 +353,11 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
return webnotes.conn.sql("""select name from tabBatch
where docstatus != 2
and item = '%(item_code)s'
and expiry_date >= '%(posting_date)s'
and (ifnull(expiry_date, '')='' or expiry_date >= '%(posting_date)s')
and name like '%(txt)s'
%(mcond)s
order by name desc
limit %(start)s, %(page_len)s""" % {'item_code': filters['item_code'],
'posting_date': filters['posting_date'], 'txt': "%%%s%%" % txt,
'mcond':get_match_cond(doctype, searchfield),'start': start,
'page_len': page_len})
'page_len': page_len})

View File

@ -152,7 +152,8 @@ class DocType(SellingController):
def validate_warehouse_user(self):
from stock.utils import validate_warehouse_user
warehouses = list(set([d.reserved_warehouse for d in self.doclist.get({"doctype": self.tname})]))
warehouses = list(set([d.reserved_warehouse for d in
self.doclist.get({"doctype": self.tname}) if d.reserved_warehouse]))
for w in warehouses:
validate_warehouse_user(w)

View File

@ -406,7 +406,7 @@ def import_data(dt, submit=False):
for doctype in dt:
print "Importing", doctype.replace("_", " "), "..."
webnotes.form_dict = {}
webnotes.form_dict = webnotes._dict()
if submit:
webnotes.form_dict["params"] = json.dumps({"_submit": 1})
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", doctype+".csv")

View File

@ -9,6 +9,23 @@ def make_demo_app():
utilities.demo.make_demo.make(reset=True)
def make_demo_user():
roles = ["Accounts Manager", "Analytics", "Expense Approver", "Accounts User",
"Leave Approver", "Blogger", "Customer", "Sales Manager", "Employee", "Support Manager",
"HR Manager", "HR User", "Maintenance Manager", "Maintenance User", "Material Manager",
"Material Master Manager", "Material User", "Partner", "Manufacturing Manager",
"Manufacturing User", "Projects User", "Purchase Manager", "Purchase Master Manager",
"Purchase User", "Quality Manager", "Report Manager", "Sales Master Manager",
"Sales User", "Supplier", "Support Team"]
def add_roles(bean):
for role in roles:
p.doclist.append({
"doctype": "UserRole",
"parentfield": "user_roles",
"role": role
})
# make demo user
if webnotes.conn.exists("Profile", "demo@erpnext.com"):
webnotes.delete_doc("Profile", "demo@erpnext.com")
@ -21,25 +38,31 @@ def make_demo_user():
p.doc.send_invite_email = 0
p.doc.new_password = "demo"
p.insert()
add_roles(p)
p.save()
for role in ("Accounts Manager", "Analytics", "Expense Approver", "Accounts User",
"Leave Approver", "Blogger", "Customer", "Sales Manager", "Employee", "Support Manager",
"HR Manager", "HR User", "Maintenance Manager", "Maintenance User", "Material Manager",
"Material Master Manager", "Material User", "Partner", "Manufacturing Manager",
"Manufacturing User", "Projects User", "Purchase Manager", "Purchase Master Manager",
"Purchase User", "Quality Manager", "Report Manager", "Sales Master Manager", "Sales User",
"Supplier", "Support Team"):
p.doclist.append({
"doctype": "UserRole",
"parentfield": "user_roles",
"role": role
})
# make system manager user
if webnotes.conn.exists("Profile", "admin@erpnext.com"):
webnotes.delete_doc("Profile", "admin@erpnext.com")
p = webnotes.new_bean("Profile")
p.doc.email = "admin@erpnext.com"
p.doc.first_name = "Admin"
p.doc.last_name = "User"
p.doc.enabled = 1
p.doc.user_type = "System User"
p.doc.send_invite_email = 0
p.doc.new_password = "admin010123"
p.insert()
roles.append("System Manager")
add_roles(p)
p.save()
# only read for newsletter
webnotes.conn.sql("""update `tabDocPerm` set `write`=0, `create`=0, `cancel`=0
where parent='Newsletter'""")
webnotes.conn.sql("""update `tabDocPerm` set `write`=0, `create`=0, `cancel`=0
where parent='Profile' and role='All'""")
webnotes.conn.commit()
@ -66,6 +89,7 @@ def make_demo_login_page():
p.insert()
webnotes.conn.set_value("Website Settings", None, "home_page", "demo-login")
webnotes.conn.set_value("Website Settings", None, "disable_signup", 1)
webnotes.conn.commit()
@ -77,6 +101,10 @@ def make_demo_on_login_script():
with open(os.path.join(os.path.dirname(__file__), "demo_control_panel.py"), "r") as dfile:
s.doc.script = dfile.read()
s.insert()
cp = webnotes.bean("Control Panel")
cp.doc.custom_startup_code = """wn.ui.toolbar.show_banner('You are using ERPNext Demo. To start your own ERPNext Trial, <a href="https://erpnext.com/pricing-and-signup" target="_blank">click here</a>')"""
cp.save()
webnotes.conn.commit()

View File

@ -55,6 +55,8 @@ class TransactionBase(StatusUpdater):
return self._party_type_and_name
def get_customer_defaults(self):
if not self.doc.customer: return {}
out = self.get_default_address_and_contact("customer")
customer = webnotes.doc("Customer", self.doc.customer)