本文整理汇总了Python中webnotes.utils.now函数的典型用法代码示例。如果您正苦于以下问题:Python now函数的具体用法?Python now怎么用?Python now使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了now函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: update_status
def update_status(self):
status = webnotes.conn.get_value("Support Ticket", self.doc.name, "status")
if self.doc.status!="Open" and status =="Open" and not self.doc.first_responded_on:
self.doc.first_responded_on = now()
if self.doc.status=="Closed" and status !="Closed":
self.doc.resolution_date = now()
if self.doc.status=="Open" and status !="Open":
self.doc.resolution_date = ""
开发者ID:Tejal011089,项目名称:Medsyn2_app,代码行数:8,代码来源:support_ticket.py
示例2: backup
def backup(site=None, with_files=False, verbose=True, backup_path_db=None, backup_path_files=None):
from webnotes.utils.backups import scheduled_backup
webnotes.connect(site=site)
odb = scheduled_backup(ignore_files=not with_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files)
if verbose:
from webnotes.utils import now
print "database backup taken -", odb.backup_path_db, "- on", now()
if with_files:
print "files backup taken -", odb.backup_path_files, "- on", now()
webnotes.destroy()
return odb
开发者ID:Halfnhav,项目名称:wnframework,代码行数:11,代码来源:wnf.py
示例3: remove_against_link_from_jv
def remove_against_link_from_jv(ref_type, ref_no, against_field):
webnotes.conn.sql("""update `tabJournal Voucher Detail` set `%s`=null,
modified=%s, modified_by=%s
where `%s`=%s and docstatus < 2""" % (against_field, "%s", "%s", against_field, "%s"),
(now(), webnotes.session.user, ref_no))
webnotes.conn.sql("""update `tabGL Entry`
set against_voucher_type=null, against_voucher=null,
modified=%s, modified_by=%s
where against_voucher_type=%s and against_voucher=%s
and voucher_no != ifnull(against_voucher, '')""",
(now(), webnotes.session.user, ref_type, ref_no))
开发者ID:CarlosAnt,项目名称:erpnext,代码行数:12,代码来源:utils.py
示例4: send_message
def send_message(subject="Website Query", message="", sender=""):
if not message:
webnotes.response["message"] = "Please write something"
return
if not sender:
webnotes.response["message"] = "Email Id Required"
return
# guest method, cap max writes per hour
if (
webnotes.conn.sql(
"""select count(*) from `tabCommunication`
where TIMEDIFF(%s, modified) < '01:00:00'""",
now(),
)[0][0]
> max_communications_per_hour
):
webnotes.response[
"message"
] = "Sorry: we believe we have received an unreasonably high number of requests of this kind. Please try later"
return
# send email
forward_to_email = webnotes.conn.get_value("Contact Us Settings", None, "forward_to_email")
if forward_to_email:
from webnotes.utils.email_lib import sendmail
sendmail(forward_to_email, sender, message, subject)
webnotes.response.status = "okay"
return True
开发者ID:nabinhait,项目名称:frappe,代码行数:33,代码来源:contact.py
示例5: update_user_limit
def update_user_limit(site_name , max_users, _type='POST'):
from webnotes.model.doc import Document
from webnotes.utils import now
site_name = get_site_name(site_name)
site_details = webnotes.conn.sql("select database_name, database_password from `tabSite Details` where name = '%s'"%(site_name))
if site_details:
import MySQLdb
try:
myDB = MySQLdb.connect(user="%s"%site_details[0][0], passwd="%s"%site_details[0][1], db="%s"%site_details[0][0])
cHandler = myDB.cursor()
cHandler.execute("update tabSingles set value = '%s' where field='max_users' and doctype = 'Global Defaults'"%max_users)
cHandler.execute("commit")
myDB.close()
d = Document("Site Log")
d.site_name =site_name
d.date_time = now()
d.purpose = 'Max User Setting'
d.max_users = max_users
d.save()
webnotes.conn.sql("commit")
return {"status":"200", 'name':d.name}
except Exception as inst:
return {"status":"417", "error":inst}
开发者ID:saurabh6790,项目名称:omnisys-lib,代码行数:26,代码来源:site_details.py
示例6: update_packed_qty
def update_packed_qty(self, event=''):
"""
Updates packed qty for all items
"""
if event not in ['submit', 'cancel']:
raise Exception('update_packed_quantity can only be called on submit or cancel')
# Get Delivery Note Items, Item Quantity Dict and No. of Cases for this Packing slip
dn_details, ps_item_qty, no_of_cases = self.get_details_for_packing()
for item in dn_details:
new_packed_qty = flt(item['packed_qty'])
if (new_packed_qty < 0) or (new_packed_qty > flt(item['qty'])):
webnotes.msgprint("Invalid new packed quantity for item %s. \
Please try again or contact [email protected]" % item['item_code'], raise_exception=1)
delivery_note_item = webnotes.conn.get_value("Delivery Note Item", {
"parent": self.doc.delivery_note, "item_code": item["item_code"]})
webnotes.conn.sql("""\
UPDATE `tabDelivery Note Item`
SET packed_qty = %s
WHERE parent = %s AND item_code = %s""",
(new_packed_qty, self.doc.delivery_note, item['item_code']))
webnotes.conn.set_value("Delivery Note", self.doc.delivery_note,
"modified", now())
开发者ID:AminfiBerlin,项目名称:erpnext,代码行数:26,代码来源:packing_slip.py
示例7: create_production_order
def create_production_order(self,company, fy, pp_detail = '', pro_detail = ''):
pro_lbl = {'production_item': 0, 'description': 1, 'qty' : 2, 'stock_uom' : 3, 'bom_no': 4, 'consider_sa_items': 5}
default_values = { 'transaction_date' : now(),
'origin' : pp_detail and 'MRP' or 'Direct',
'wip_warehouse' : 'MB1-Stores',
'status' : 'Draft',
'company' : company,
'fiscal_year' : fy }
pro_list, count = pp_detail and pp_detail or pro_detail, 0
while (count < len(pro_list)):
pro_doc = Document('Production Order')
for key in pro_lbl.keys():
pro_doc.fields[key] = pro_list[count][pro_lbl[key]]
for key in default_values:
pro_doc.fields[key] = default_values[key]
pro_doc.save(new = 1)
pro_list[count] = pro_doc.name
# This was for adding raw materials in pro detail and get sa items
#sa_list = get_obj('Porduction Order', pro_doc.name, with_children = 1).get_purchase_item( get_sa_items = 1, add_child= 1)
#for sa_item in sa_list:
# pro_list.append(sa_item)
count = count + 1
return pro_list
开发者ID:Morphnus-IT-Solutions,项目名称:trimos,代码行数:31,代码来源:production_control.py
示例8: send_message
def send_message(subject="Website Query", message="", sender="", status="Open"):
if not message:
webnotes.response["message"] = "Please write something"
return
if not sender:
webnotes.response["message"] = "Email Id Required"
return
# make lead / communication
from selling.doctype.lead.get_leads import add_sales_communication
add_sales_communication(subject or "Website Query", message, sender, sender, mail=None, status=status)
# guest method, cap max writes per hour
if (
webnotes.conn.sql(
"""select count(*) from `tabCommunication`
where TIMEDIFF(%s, modified) < '01:00:00'""",
now(),
)[0][0]
> max_communications_per_hour
):
webnotes.response[
"message"
] = "Sorry: we believe we have received an unreasonably high number of requests of this kind. Please try later"
return
webnotes.response["message"] = "Thank You"
开发者ID:kritinline,项目名称:erpnext,代码行数:29,代码来源:contact.py
示例9: update_add_node
def update_add_node(doctype, name, parent, parent_field):
"""
insert a new node
"""
from webnotes.utils import now
n = now()
# get the last sibling of the parent
if parent:
right = webnotes.conn.sql("select rgt from `tab%s` where name='%s'" % (doctype, parent))[0][0]
else: # root
right = webnotes.conn.sql("select ifnull(max(rgt),0)+1 from `tab%s` where ifnull(`%s`,'') =''" % (doctype, parent_field))[0][0]
right = right or 1
# update all on the right
webnotes.conn.sql("update `tab%s` set rgt = rgt+2, modified='%s' where rgt >= %s" %(doctype,n,right))
webnotes.conn.sql("update `tab%s` set lft = lft+2, modified='%s' where lft >= %s" %(doctype,n,right))
# update index of new node
if webnotes.conn.sql("select * from `tab%s` where lft=%s or rgt=%s"% (doctype, right, right+1)):
webnotes.msgprint("Nested set error. Please send mail to support")
raise Exception
webnotes.conn.sql("update `tab%s` set lft=%s, rgt=%s, modified='%s' where name='%s'" % (doctype,right,right+1,n,name))
return right
开发者ID:frank1638,项目名称:wnframework,代码行数:25,代码来源:nestedset.py
示例10: rebuild_node
def rebuild_node(doctype, parent, left, parent_field, cnt = 0):
"""
reset lft, rgt and recursive call for all children
"""
from webnotes.utils import now
n = now()
# the right value of this node is the left value + 1
right = left+1
# get all children of this node
result = webnotes.conn.sql("SELECT name FROM `tab%s` WHERE `%s`='%s'" % (doctype, parent_field, parent))
for r in result:
right = rebuild_node(doctype, r[0], right, parent_field, cnt)
# we've got the left value, and now that we've processed
# the children of this node we also know the right value
webnotes.conn.sql("UPDATE `tab%s` SET lft=%s, rgt=%s, modified='%s' WHERE name='%s'" % (doctype,left,right,n,parent))
# commit after every 100
cnt += 1
if cnt % 100 == 0:
cnt = 0
webnotes.conn.sql("commit")
webnotes.conn.sql("start transaction")
#return the right value of this node + 1
return right+1
开发者ID:Vichagserp,项目名称:cimworks,代码行数:28,代码来源:nestedset.py
示例11: set_value
def set_value(self, dt, dn, field, val, modified=None, modified_by=None):
from webnotes.utils import now
if dn and dt!=dn:
self.sql("""update `tab%s` set `%s`=%s, modified=%s, modified_by=%s
where name=%s""" % (dt, field, "%s", "%s", "%s", "%s"),
(val, modified or now(), modified_by or webnotes.session["user"], dn))
else:
if self.sql("select value from tabSingles where field=%s and doctype=%s", (field, dt)):
self.sql("""update tabSingles set value=%s where field=%s and doctype=%s""",
(val, field, dt))
else:
self.sql("""insert into tabSingles(doctype, field, value)
values (%s, %s, %s)""", (dt, field, val, ))
if field!="modified":
self.set_value(dt, dn, "modified", modified or now())
开发者ID:saurabh6790,项目名称:pow-lib,代码行数:16,代码来源:db.py
示例12: set_as_cancel
def set_as_cancel(voucher_type, voucher_no):
webnotes.conn.sql(
"""update `tabGL Entry` set is_cancelled='Yes',
modified=%s, modified_by=%s
where voucher_type=%s and voucher_no=%s""",
(now(), webnotes.session.user, voucher_type, voucher_no),
)
开发者ID:rohitw1991,项目名称:latestadberp,代码行数:7,代码来源:general_ledger.py
示例13: update_stock
def update_stock(self, values, is_amended = 'No'):
for v in values:
sle_id, valid_serial_nos = '', ''
# get serial nos
if v.get("serial_no", "").strip():
valid_serial_nos = get_valid_serial_nos(v["serial_no"],
v['actual_qty'], v['item_code'])
v["serial_no"] = valid_serial_nos and "\n".join(valid_serial_nos) or ""
# reverse quantities for cancel
if v.get('is_cancelled') == 'Yes':
v['actual_qty'] = -flt(v['actual_qty'])
# cancel matching entry
webnotes.conn.sql("""update `tabStock Ledger Entry` set is_cancelled='Yes',
modified=%s, modified_by=%s
where voucher_no=%s and voucher_type=%s""",
(now(), webnotes.session.user, v['voucher_no'], v['voucher_type']))
if v.get("actual_qty"):
sle_id = self.make_entry(v)
args = v.copy()
args.update({
"sle_id": sle_id,
"is_amended": is_amended
})
get_obj('Warehouse', v["warehouse"]).update_bin(args)
开发者ID:BillTheBest,项目名称:erpnext,代码行数:28,代码来源:stock_ledger.py
示例14: sign_up
def sign_up(email, full_name):
profile = webnotes.conn.get("Profile", {"email": email})
if profile:
if profile.disabled:
return _("Registered but disabled.")
else:
return _("Already Registered")
else:
if (
webnotes.conn.sql(
"""select count(*) from tabProfile where
TIMEDIFF(%s, modified) > '1:00:00' """,
now(),
)[0][0]
> 200
):
raise Exception, "Too Many New Profiles"
from webnotes.utils import random_string
profile = webnotes.bean(
{
"doctype": "Profile",
"email": email,
"first_name": full_name,
"enabled": 1,
"new_password": random_string(10),
"user_type": "Website User",
}
)
profile.ignore_permissions = True
profile.insert()
return _("Registration Details Emailed.")
开发者ID:saurabh6790,项目名称:med_lib_rels,代码行数:32,代码来源:profile.py
示例15: activate_deactivate
def activate_deactivate(site_name , is_active, _type='POST'):
# return "hi"
from webnotes.model.doc import Document
from webnotes.utils import now
site_details = webnotes.conn.sql("select database_name, database_password from `tabSite Details` where name = '%s'"%(site_name))
# return site_details
if site_details:
import MySQLdb
try:
myDB = MySQLdb.connect(user="%s"%site_details[0][0], passwd="%s"%site_details[0][1], db="%s"%site_details[0][0])
cHandler = myDB.cursor()
cHandler.execute("update tabSingles set value = '%s' where field='is_active' and doctype = 'Global Defaults'"%is_active)
cHandler.execute("commit")
myDB.close()
d = Document("Site Log")
d.site_name =site_name
d.is_active = is_active
d.date_time = now()
d.save()
webnotes.conn.sql("commit")
return {"status":"200", 'name':d.name}
except Exception as inst:
return {"status":"417", "error":inst}
else:
return{"status":"404", "Error":"Site Not Fount"}
开发者ID:saurabh6790,项目名称:omn-lib,代码行数:27,代码来源:site_details.py
示例16: get_context
def get_context():
"""generate rss feed"""
host = get_request_site_address()
blog_list = webnotes.conn.sql("""\
select page_name as name, published_on, modified, title, content from `tabBlog Post`
where ifnull(published,0)=1
order by published_on desc limit 20""", as_dict=1)
for blog in blog_list:
blog.link = urllib.quote(host + '/' + blog.name + '.html')
blog.content = escape_html(blog.content or "")
if blog_list:
modified = max((blog['modified'] for blog in blog_list))
else:
modified = now()
ws = webnotes.doc('Website Settings', 'Website Settings')
context = {
'title': ws.title_prefix,
'description': ws.description or ((ws.title_prefix or "") + ' Blog'),
'modified': modified,
'items': blog_list,
'link': host + '/blog'
}
webnotes.response.content_type = "text/xml"
# print context
return context
开发者ID:ricardomomm,项目名称:wnframework,代码行数:33,代码来源:rss.py
示例17: __init__
def __init__(self, content):
import email, email.utils
import datetime
# print 'content start'
# print content
# print 'content end'
self.mail = email.message_from_string(content)
self.text_content = ''
self.html_content = ''
self.attachments = []
self.parse()
self.set_content_and_type()
self.set_subject()
self.from_email = extract_email_id(self.mail["From"])
self.from_real_name = email.utils.parseaddr(self.mail["From"])[0]
if self.mail["Date"]:
utc = time.mktime(email.utils.parsedate(self.mail["Date"]))
utc_dt = datetime.datetime.utcfromtimestamp(utc)
self.date = convert_utc_to_user_timezone(utc_dt).strftime('%Y-%m-%d %H:%M:%S')
else:
self.date = now()
开发者ID:gangadhar-kadam,项目名称:prjlib,代码行数:25,代码来源:receive2.py
示例18: scheduled_backup
def scheduled_backup(older_than=6, ignore_files=False):
"""this function is called from scheduler
deletes backups older than 7 days
takes backup"""
odb = new_backup(older_than, ignore_files)
from webnotes.utils import now
print "backup taken -", odb.backup_path_db, "- on", now()
开发者ID:bperretti,项目名称:wnframework-bperretti,代码行数:8,代码来源:backups.py
示例19: change_modified_of_parent
def change_modified_of_parent(self):
if webnotes.in_import:
return
parent_list = webnotes.conn.sql("""SELECT parent
from tabDocField where fieldtype="Table" and options="%s" """ % self.doc.name)
for p in parent_list:
webnotes.conn.sql('''UPDATE tabDocType SET modified="%s"
WHERE `name`="%s"''' % (now(), p[0]))
开发者ID:rohitw1991,项目名称:latestadbwnf,代码行数:8,代码来源:doctype.py
示例20: update_followers
def update_followers(dt=None, dn=None, subject=None, update_by=None, doc=None):
"Updates the timestamp and subject in follower table (for feed generation)"
from webnotes.utils import now
webnotes.conn.sql("update tabFollower set modified=%s, subject=%s, modified_by=%s where doc_type=%s and doc_name=%s", \
(now(),
subject or doc.fields.get('subject'), \
update_by or webnotes.session['user'],\
dt or doc.doctype,
dn or doc.name))
开发者ID:Vichagserp,项目名称:cimworks,代码行数:9,代码来源:follow.py
注:本文中的webnotes.utils.now函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论