本文整理汇总了Python中webnotes._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: validate_uom_is_integer
def validate_uom_is_integer(doclist, uom_field, qty_fields):
if isinstance(qty_fields, basestring):
qty_fields = [qty_fields]
integer_uoms = filter(
lambda uom: webnotes.conn.get_value("UOM", uom, "must_be_whole_number") or None,
doclist.get_distinct_values(uom_field),
)
if not integer_uoms:
return
for d in doclist:
if d.fields.get(uom_field) in integer_uoms:
for f in qty_fields:
if d.fields.get(f):
if cint(d.fields[f]) != d.fields[f]:
webnotes.msgprint(
_("For UOM")
+ " '"
+ d.fields[uom_field]
+ "': "
+ _("Quantity cannot be a fraction.")
+ " "
+ _("In Row")
+ ": "
+ str(d.idx),
raise_exception=UOMMustBeIntegerError,
)
开发者ID:unixcrh,项目名称:erpnext,代码行数:29,代码来源:transaction_base.py
示例2: run
def run(report_name, filters=None):
report = webnotes.doc("Report", report_name)
if filters and isinstance(filters, basestring):
filters = json.loads(filters)
if not webnotes.has_permission(report.ref_doctype, "report"):
webnotes.msgprint(_("Must have report permission to access this report."),
raise_exception=True)
if report.report_type=="Query Report":
if not report.query:
webnotes.msgprint(_("Must specify a Query to run"), raise_exception=True)
if not report.query.lower().startswith("select"):
webnotes.msgprint(_("Query must be a SELECT"), raise_exception=True)
result = [list(t) for t in webnotes.conn.sql(report.query, filters)]
columns = [c[0] for c in webnotes.conn.get_description()]
else:
method_name = scrub(webnotes.conn.get_value("DocType", report.ref_doctype, "module")) \
+ ".report." + scrub(report.name) + "." + scrub(report.name) + ".execute"
columns, result = webnotes.get_method(method_name)(filters or {})
result = get_filtered_data(report.ref_doctype, columns, result)
if cint(report.add_total_row) and result:
result = add_total_row(result, columns)
return {
"result": result,
"columns": columns
}
开发者ID:ricardomomm,项目名称:wnframework,代码行数:34,代码来源:query_report.py
示例3: validate_max_discount
def validate_max_discount(self):
for d in self.doclist.get({"parentfield": self.fname}):
discount = flt(webnotes.conn.get_value("Item", d.item_code, "max_discount"))
if discount and flt(d.adj_rate) > discount:
webnotes.throw(_("You cannot give more than ") + cstr(discount) + "% " +
_("discount on Item Code") + ": " + cstr(d.item_code))
开发者ID:Jdfkat,项目名称:erpnext,代码行数:7,代码来源:selling_controller.py
示例4: check_value
def check_value(self, ref_dt, ref_dn, ref_item_dn, val, item_code):
ref_val = webnotes.conn.get_value(ref_dt + " Item", ref_item_dn, "export_rate")
if flt(ref_val, 2) != flt(val, 2):
msgprint(
_("Rate is not matching with ") + ref_dt + ": " + ref_dn + _(" for item: ") + item_code,
raise_exception=True,
)
开发者ID:rohitw1991,项目名称:erpnext,代码行数:7,代码来源:sales_invoice.py
示例5: _get_message
def _get_message(url=False):
if url:
name = get_url_to_form(self.doc.doctype, self.doc.name)
else:
name = self.doc.name
return (_("Leave Application") + ": %s - %s") % (name, _(status))
开发者ID:gangadhar-kadam,项目名称:erpnext,代码行数:7,代码来源:leave_application.py
示例6: place_order
def place_order():
quotation = _get_cart_quotation()
quotation.doc.company = webnotes.conn.get_value("Shopping Cart Settings", None, "company")
controller = quotation.make_controller()
for fieldname in ["customer_address", "shipping_address_name"]:
if not quotation.doc.fields.get(fieldname):
msgprint(_("Please select a") + " " + _(controller.meta.get_label(fieldname)), raise_exception=True)
quotation.ignore_permissions = True
quotation.submit()
if quotation.doc.lead:
# company used to create customer accounts
webnotes.defaults.set_user_default("company", quotation.doc.company)
from selling.doctype.quotation.quotation import _make_sales_order
sales_order = webnotes.bean(_make_sales_order(quotation.doc.name, ignore_permissions=True))
for item in sales_order.doclist.get({"parentfield": "sales_order_details"}):
item.reserved_warehouse = webnotes.conn.get_value("Item", item.item_code, "website_warehouse") or None
sales_order.ignore_permissions = True
sales_order.insert()
sales_order.submit()
webnotes._response.set_cookie("cart_count", "")
return sales_order.doc.name
开发者ID:aproxp,项目名称:erpnext,代码行数:26,代码来源:cart.py
示例7: run
def run(report_name):
report = webnotes.doc("Report", report_name)
if not webnotes.has_permission(report.ref_doctype, "report"):
webnotes.msgprint(_("Must have report permission to access this report."),
raise_exception=True)
if report.report_type=="Query Report":
if not report.query:
webnotes.msgprint(_("Must specify a Query to run"), raise_exception=True)
if not report.query.lower().startswith("select"):
webnotes.msgprint(_("Query must be a SELECT"), raise_exception=True)
result = [list(t) for t in webnotes.conn.sql(report.query)]
columns = [c[0] for c in webnotes.conn.get_description()]
else:
from webnotes.modules import scrub
method_name = scrub(webnotes.conn.get_value("DocType", report.ref_doctype, "module")) \
+ ".report." + scrub(report.name) + "." + scrub(report.name) + ".execute"
columns, result = webnotes.get_method(method_name)()
return {
"result": result,
"columns": columns
}
开发者ID:jacara,项目名称:erpclone,代码行数:27,代码来源:query_report.py
示例8: upload
def upload(select_doctype=None, rows=None):
from webnotes.utils.datautils import read_csv_content_from_uploaded_file
from webnotes.modules import scrub
from webnotes.model.rename_doc import rename_doc
if not select_doctype:
select_doctype = webnotes.form_dict.select_doctype
if not rows:
rows = read_csv_content_from_uploaded_file()
if not rows:
webnotes.msgprint(_("Please select a valid csv file with data."))
raise Exception
if len(rows) > 500:
webnotes.msgprint(_("Max 500 rows only."))
raise Exception
rename_log = []
for row in rows:
if len(row) > 2:
try:
if rename_doc(select_doctype, row[0], row[1]):
rename_log.append(_("Successful: ") + row[0] + " -> " + row[1])
webnotes.conn.commit()
else:
rename_log.append(_("Ignored: ") + row[0] + " -> " + row[1])
except Exception, e:
rename_log.append("<span style='color: RED'>" + \
_("Failed: ") + row[0] + " -> " + row[1] + "</span>")
rename_log.append("<span style='margin-left: 20px;'>" + repr(e) + "</span>")
开发者ID:gangadhar-kadam,项目名称:erpnext,代码行数:31,代码来源:rename_tool.py
示例9: update_last_purchase_rate
def update_last_purchase_rate(self, obj, is_submit):
"""updates last_purchase_rate in item table for each item"""
import webnotes.utils
this_purchase_date = webnotes.utils.getdate(obj.doc.fields.get('posting_date') or obj.doc.fields.get('transaction_date'))
for d in getlist(obj.doclist,obj.fname):
# get last purchase details
last_purchase_details = get_last_purchase_details(d.item_code, obj.doc.name)
# compare last purchase date and this transaction's date
last_purchase_rate = None
if last_purchase_details and \
(last_purchase_details.purchase_date > this_purchase_date):
last_purchase_rate = last_purchase_details['purchase_rate']
elif is_submit == 1:
# even if this transaction is the latest one, it should be submitted
# for it to be considered for latest purchase rate
if flt(d.conversion_factor):
last_purchase_rate = flt(d.purchase_rate) / flt(d.conversion_factor)
else:
msgprint(_("Row ") + cstr(d.idx) + ": " +
_("UOM Conversion Factor is mandatory"), raise_exception=1)
# update last purchsae rate
if last_purchase_rate:
webnotes.conn.sql("update `tabItem` set last_purchase_rate = %s where name = %s",
(flt(last_purchase_rate),d.item_code))
开发者ID:Jdfkat,项目名称:erpnext,代码行数:28,代码来源:purchase_common.py
示例10: 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
示例11: validate_filters
def validate_filters(filters, account_details):
if account_details and account_details.group_or_ledger == "Ledger" \
and filters.get("group_by") == "Group by Account":
webnotes.throw(_("Can not filter based on Account, if grouped by Account"))
if filters.get("voucher_no") and filters.get("group_by") == "Group by Voucher":
webnotes.throw(_("Can not filter based on Voucher No, if grouped by Voucher"))
开发者ID:Anirudh887,项目名称:erpnext,代码行数:7,代码来源:general_ledger.py
示例12: validate_data
def validate_data(self):
if not self.doc.reconciliation_json:
return
data = json.loads(self.doc.reconciliation_json)
# strip out extra columns (if any)
data = [row[:4] for row in data]
if self.head_row not in data:
msgprint(_("""Wrong Template: Unable to find head row."""),
raise_exception=1)
# remove the help part and save the json
if data.index(self.head_row) != 0:
data = data[data.index(self.head_row):]
self.doc.reconciliation_json = json.dumps(data)
def _get_msg(row_num, msg):
return _("Row # ") + ("%d: " % (row_num+2)) + _(msg)
self.validation_messages = []
item_warehouse_combinations = []
# validate no of rows
rows = data[data.index(self.head_row)+1:]
if len(rows) > 100:
msgprint(_("""Sorry! We can only allow upto 100 rows for Stock Reconciliation."""),
raise_exception=True)
for row_num, row in enumerate(rows):
# find duplicates
if [row[0], row[1]] in item_warehouse_combinations:
self.validation_messages.append(_get_msg(row_num, "Duplicate entry"))
else:
item_warehouse_combinations.append([row[0], row[1]])
self.validate_item(row[0], row_num)
# note: warehouse will be validated through link validation
# if both not specified
if row[2] == "" :
self.validation_messages.append(_get_msg(row_num,
"Please specify Quantity "))
# do not allow negative quantity
if flt(row[2]) < 0:
self.validation_messages.append(_get_msg(row_num,
"Negative Quantity is not allowed"))
# do not allow negative valuation
#if flt(row[3]) < 0:
# self.validation_messages.append(_get_msg(row_num,
# "Negative Valuation Rate is not allowed"))
# throw all validation messages
if self.validation_messages:
for msg in self.validation_messages:
msgprint(msg)
raise webnotes.ValidationError
开发者ID:Tejal011089,项目名称:med2-app,代码行数:60,代码来源:stock_reconciliation.py
示例13: validate_warehouse
def validate_warehouse(self):
if not self.doc.fields.get("__islocal"):
item_code, warehouse = webnotes.conn.get_value("Serial No", self.doc.name, ["item_code", "warehouse"])
if item_code != self.doc.item_code:
webnotes.throw(_("Item Code cannot be changed for Serial No."), SerialNoCannotCannotChangeError)
if not self.via_stock_ledger and warehouse != self.doc.warehouse:
webnotes.throw(_("Warehouse cannot be changed for Serial No."), SerialNoCannotCannotChangeError)
开发者ID:saurabh6790,项目名称:aimobilize,代码行数:7,代码来源:serial_no.py
示例14: validate
def validate(self):
if self.doc.buying_or_selling not in ["Buying", "Selling"]:
msgprint(_(self.meta.get_label("buying_or_selling")) + " " + _("must be one of") + " " +
comma_or(["Buying", "Selling"]), raise_exception=True)
# at least one territory
self.validate_table_has_rows("valid_for_territories")
开发者ID:cocoy,项目名称:erpnext,代码行数:7,代码来源:price_list.py
示例15: update_completed_qty
def update_completed_qty(controller, caller_method):
if controller.doc.doctype == "Stock Entry":
material_request_map = {}
for d in controller.doclist.get({"parentfield": "mtn_details"}):
if d.material_request:
if d.material_request not in material_request_map:
material_request_map[d.material_request] = []
material_request_map[d.material_request].append(d.material_request_item)
for mr_name, mr_items in material_request_map.items():
mr_obj = webnotes.get_obj("Material Request", mr_name, with_children=1)
mr_doctype = webnotes.get_doctype("Material Request")
if mr_obj.doc.status in ["Stopped", "Cancelled"]:
msgprint(
_("Material Request")
+ ": %s, " % mr_obj.doc.name
+ _(mr_doctype.get_label("status"))
+ " = %s. " % _(mr_obj.doc.status)
+ _("Cannot continue."),
raise_exception=webnotes.InvalidStatusError,
)
_update_requested_qty(controller, mr_obj, mr_items)
# update ordered percentage and qty
mr_obj.update_completed_qty(mr_items)
开发者ID:bindscha,项目名称:erpnext-fork,代码行数:28,代码来源:material_request.py
示例16: validate_account_head
def validate_account_head(self):
debit_or_credit, is_pl_account = webnotes.conn.get_value("Account",
self.doc.closing_account_head, ["debit_or_credit", "is_pl_account"])
if debit_or_credit != 'Credit' or is_pl_account != 'No':
webnotes.throw(_("Account") + ": " + self.doc.closing_account_head +
_("must be a Liability account"))
开发者ID:Anirudh887,项目名称:erpnext,代码行数:7,代码来源:period_closing_voucher.py
示例17: update_outstanding_amt
def update_outstanding_amt(self):
# get final outstanding amt
bal = flt(sql("""select sum(debit) - sum(credit) from `tabGL Entry`
where against_voucher=%s and against_voucher_type=%s
and ifnull(is_cancelled,'No') = 'No'""",
(self.doc.against_voucher, self.doc.against_voucher_type))[0][0] or 0.0)
if self.doc.against_voucher_type == 'Purchase Invoice':
bal = -bal
elif self.doc.against_voucher_type == "Journal Voucher":
against_voucher_amount = flt(webnotes.conn.sql("""select sum(debit) - sum(credit)
from `tabGL Entry` where voucher_type = 'Journal Voucher' and voucher_no = %s
and account = %s""", (self.doc.against_voucher, self.doc.account))[0][0])
bal = against_voucher_amount + bal
if against_voucher_amount < 0:
bal = -bal
# Validation : Outstanding can not be negative
if bal < 0 and self.doc.is_cancelled == 'No':
msgprint(_("Outstanding for Voucher ") + self.doc.against_voucher +
_(" will become ") + fmt_money(bal) + _(". Outstanding cannot be less than zero. \
Please match exact outstanding."), raise_exception=1)
# Update outstanding amt on against voucher
if self.doc.against_voucher_type in ["Sales Invoice", "Purchase Invoice"]:
sql("update `tab%s` set outstanding_amount=%s where name='%s'"%
(self.doc.against_voucher_type, bal, self.doc.against_voucher))
开发者ID:gangadhar-kadam,项目名称:church-erpnext,代码行数:29,代码来源:gl_entry.py
示例18: check_if_latest
def check_if_latest(self, method="save"):
from webnotes.model.meta import is_single
conflict = False
if not cint(self.doc.fields.get('__islocal')):
if is_single(self.doc.doctype):
modified = webnotes.conn.get_value(self.doc.doctype, self.doc.name, "modified")
if isinstance(modified, list):
modified = modified[0]
if cstr(modified) and cstr(modified) != cstr(self.doc.modified):
conflict = True
else:
tmp = webnotes.conn.sql("""select modified, docstatus from `tab%s`
where name="%s" for update"""
% (self.doc.doctype, self.doc.name), as_dict=True)
if not tmp:
webnotes.msgprint("""This record does not exist. Please refresh.""", raise_exception=1)
modified = cstr(tmp[0].modified)
if modified and modified != cstr(self.doc.modified):
conflict = True
self.check_docstatus_transition(tmp[0].docstatus, method)
if conflict:
webnotes.msgprint(_("Error: Document has been modified after you have opened it") \
+ (" (%s, %s). " % (modified, self.doc.modified)) \
+ _("Please refresh to get the latest document."), raise_exception=TimestampMismatchError)
开发者ID:Halfnhav,项目名称:wnframework,代码行数:29,代码来源:bean.py
示例19: validate_production_order_against_so
def validate_production_order_against_so(self):
# already ordered qty
ordered_qty_against_so = webnotes.conn.sql("""select sum(qty) from `tabProduction Order`
where production_item = %s and sales_order = %s and docstatus < 2 and name != %s""",
(self.doc.production_item, self.doc.sales_order, self.doc.name))[0][0]
total_qty = flt(ordered_qty_against_so) + flt(self.doc.qty)
# get qty from Sales Order Item table
so_item_qty = webnotes.conn.sql("""select sum(qty) from `tabSales Order Item`
where parent = %s and item_code = %s""",
(self.doc.sales_order, self.doc.production_item))[0][0]
# get qty from Packing Item table
dnpi_qty = webnotes.conn.sql("""select sum(qty) from `tabPacked Item`
where parent = %s and parenttype = 'Sales Order' and item_code = %s""",
(self.doc.sales_order, self.doc.production_item))[0][0]
# total qty in SO
so_qty = flt(so_item_qty) + flt(dnpi_qty)
if total_qty > so_qty:
webnotes.throw(_("Total production order qty for item") + ": " +
cstr(self.doc.production_item) + _(" against sales order") + ": " +
cstr(self.doc.sales_order) + _(" will be ") + cstr(total_qty) + ", " +
_("which is greater than sales order qty ") + "(" + cstr(so_qty) + ")" +
_("Please reduce qty."), exc=OverProductionError)
开发者ID:Anirudh887,项目名称:erpnext,代码行数:25,代码来源:production_order.py
示例20: update_outstanding_amt
def update_outstanding_amt(account, against_voucher_type, against_voucher, on_cancel=False):
# get final outstanding amt
bal = flt(webnotes.conn.sql("""select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
from `tabGL Entry`
where against_voucher_type=%s and against_voucher=%s and account = %s""",
(against_voucher_type, against_voucher, account))[0][0] or 0.0)
if against_voucher_type == 'Purchase Invoice':
bal = -bal
elif against_voucher_type == "Journal Voucher":
against_voucher_amount = flt(webnotes.conn.sql("""
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
from `tabGL Entry` where voucher_type = 'Journal Voucher' and voucher_no = %s
and account = %s and ifnull(against_voucher, '') = ''""",
(against_voucher, account))[0][0])
bal = against_voucher_amount + bal
if against_voucher_amount < 0:
bal = -bal
# Validation : Outstanding can not be negative
if bal < 0 and not on_cancel:
webnotes.throw(_("Outstanding for Voucher ") + against_voucher + _(" will become ") +
fmt_money(bal) + _(". Outstanding cannot be less than zero. \
Please match exact outstanding."))
# Update outstanding amt on against voucher
if against_voucher_type in ["Sales Invoice", "Purchase Invoice"]:
webnotes.conn.sql("update `tab%s` set outstanding_amount=%s where name='%s'" %
(against_voucher_type, bal, against_voucher))
开发者ID:saurabh6790,项目名称:medsyn-app1,代码行数:29,代码来源:gl_entry.py
注:本文中的webnotes._函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论