本文整理汇总了Python中frappe._属性的典型用法代码示例。如果您正苦于以下问题:Python frappe._属性的具体用法?Python frappe._怎么用?Python frappe._使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类frappe
的用法示例。
在下文中一共展示了frappe._属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validate_price_list_currency
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import _ [as 别名]
def validate_price_list_currency(doc, method):
'''Called from Shopping Cart Settings hook'''
if doc.enabled and doc.enable_checkout:
if not doc.payment_gateway_account:
doc.enable_checkout = 0
return
payment_gateway_account = frappe.get_doc("Payment Gateway Account", doc.payment_gateway_account)
if payment_gateway_account.payment_gateway=="Razorpay":
price_list_currency = frappe.db.get_value("Price List", doc.price_list, "currency")
validate_transaction_currency(price_list_currency)
if price_list_currency != payment_gateway_account.currency:
frappe.throw(_("Currency '{0}' of Price List '{1}' should be same as the Currency '{2}' of Payment Gateway Account '{3}'").format(price_list_currency, doc.price_list, payment_gateway_account.currency, payment_gateway_account.name))
示例2: validate_account_types
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import _ [as 别名]
def validate_account_types(company):
account_types_for_ledger = ["Cost of Goods Sold", "Depreciation", "Expenses Included In Valuation",
"Fixed Asset", "Payable", "Receivable", "Stock Adjustment", "Stock Received But Not Billed"]
for account_type in account_types_for_ledger:
if not frappe.db.get_value("Account",
{"company": company, "account_type": account_type, "is_group": 0}):
frappe.throw(_("Please identify / create {0} Account (Ledger)").format(account_type))
account_types_for_group = ["Bank", "Cash", "Stock"]
for account_type in account_types_for_group:
if not frappe.db.get_value("Account",
{"company": company, "account_type": account_type, "is_group": 1}):
frappe.throw(_("Please identify / create {0} Account (Group)").format(account_type))
示例3: add_testing_results
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import _ [as 别名]
def add_testing_results(name, testing_results, is_testing_rejected=None):
if frappe.db.get_value("Warranty Request", name, "is_testing_completed"):
frappe.throw("Testing is already completed.")
frappe.db.set_value("Warranty Request", name, "is_testing_completed", 1)
update_status("Warranty Request", name, "Testing Completed")
frappe.db.set_value("Warranty Request Purposes", {"parent": name}, "testing_results", testing_results)
doc_warranty_request = frappe.get_doc("Warranty Request", name)
doc_warranty_request.add_comment("Comment", _("Testing Item has been completed"))
frappe.msgprint("Testing Item has been completed.")
if is_testing_rejected:
frappe.db.set_value("Warranty Request", name, "is_testing_rejected", 1)
dn = make_delivery_note(name)
dn.insert()
frappe.db.set_value("Warranty Request", name, "delivery_note", dn.name)
update_status("Warranty Request", name, "Closed")
frappe.msgprint("Delivery Note %s was created automatically" % dn.name)
warranty_claim = frappe.db.get_value("Warranty Request", name, "warranty_claim")
if warranty_claim:
update_status("Warranty Claim", warranty_claim, frappe.db.get_value("Warranty Request", name, "status"))
frappe.clear_cache(doctype="Warranty Request")
示例4: make_sample
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import _ [as 别名]
def make_sample(item, sample_size):
if frappe.db.exists("Quality Inspection", {"item_code": item.item_code}):
doc = frappe.get_doc("Quality Inspection", {"item_code": item.item_code})
else:
doc = frappe.new_doc("Quality Inspection")
doc.update({
"item_code": item.item_code,
"item_name": item.item_name,
"inspection_type": _("In Process"),
"sample_size": flt(sample_size),
"inspected_by": "Administrator",
"barcode": item.sample_id
})
return doc
示例5: detect_group
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import _ [as 别名]
def detect_group(biotrack_customer):
producer, processor, retail, medical = [
int(biotrack_customer.get('producer')),
int(biotrack_customer.get('processor')),
int(biotrack_customer.get('retail')),
int(biotrack_customer.get('medical')),
]
name = None
if producer and processor:
name = _('Producer/Processor')
elif retail and medical:
name = _('Retailer/Medical')
elif producer:
name = _('Producer')
elif processor:
name = _('Processor')
elif retail:
name = _('Retailer')
if name:
return get_or_create_group(name)
示例6: sync_qa_lab
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import _ [as 别名]
def sync_qa_lab(biotrack_lab):
license_no = biotrack_lab.get("location")
supplier_name = str(biotrack_lab.get("name")).strip()
name = frappe.get_value("Supplier", {"license_no": license_no})
if not name:
doc = frappe.get_doc({
"doctype": "Supplier",
"supplier_name": supplier_name,
"supplier_type": _("Lab & Scientific"),
"license_no": license_no,
})
try:
doc.save()
except frappe.exceptions.DuplicateEntryError as ex:
doc.set("supplier_name", "{} - {}".format(supplier_name, license_no))
doc.save()
else:
doc = frappe.get_doc("Supplier", name)
map_address(doc, biotrack_lab)
frappe.db.commit()
示例7: on_conversion
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import _ [as 别名]
def on_conversion(doc, method):
qty = 0
data = []
for entry in doc.get("items"):
bio_barcode = frappe.get_value("Item", entry.item_code, "bio_barcode")
if not bio_barcode:
frappe.throw(_("{0} is not a BioTrack Item. Consider to select BioTrack items only or turn off BioTrack sync-up").format(entry.item_code))
data.append({
"barcodeid": bio_barcode,
"remove_quantity": entry.qty,
"remove_quantity_uom": "g",
})
qty += entry.qty
if doc.conversion == 'Create Lot':
_create_lot(doc, data)
else:
_create_product(doc, data)
示例8: sync_erp_items_to_quickbooks
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import _ [as 别名]
def sync_erp_items_to_quickbooks():
Item_list = []
for erp_item in erp_item_data():
try:
if erp_item:
create_erp_item_to_quickbooks(erp_item, Item_list)
else:
raise _("Item does not exist in ERPNext")
except Exception, e:
if e.args[0] and e.args[0].startswith("402"):
raise e
else:
make_quickbooks_log(title=e.message, status="Error", method="sync_erp_items_to_quickbooks", message=frappe.get_traceback(),
request_data=erp_item, exception=True)
results = batch_create(Item_list)
return results
示例9: sync_erp_customers_to_quickbooks
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import _ [as 别名]
def sync_erp_customers_to_quickbooks():
"""Sync ERPNext Customer to QuickBooks"""
Customer_list = []
for erp_cust in erp_customer_data():
try:
if erp_cust:
create_erp_customer_to_quickbooks(erp_cust, Customer_list)
else:
raise _("Customer does not exist in ERPNext")
except Exception, e:
if e.args[0] and e.args[0].startswith("402"):
raise e
else:
make_quickbooks_log(title=e.message, status="Error", method="sync_erp_customers_to_quickbooks", message=frappe.get_traceback(),
request_data=erp_cust, exception=True)
results = batch_create(Customer_list)
return results
示例10: create_Supplier
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import _ [as 别名]
def create_Supplier(qb_supplier, quickbooks_supplier_list):
""" store in ERPNEXT """
supplier = None
try:
supplier = frappe.get_doc({
"doctype": "Supplier",
"quickbooks_supp_id": str(qb_supplier.get('Id')) if qb_supplier.get('Id') else str(qb_supplier.get('value')),
"supplier_name" : str(qb_supplier.get('DisplayName')) if qb_supplier.get('DisplayName') else str(qb_supplier.get('name')),
"supplier_type" : _("Distributor"),
"default_currency" : qb_supplier['CurrencyRef'].get('value','') if qb_supplier.get('CurrencyRef') else '',
}).insert()
if supplier and qb_supplier.get('BillAddr'):
create_supplier_address(supplier, qb_supplier.get("BillAddr"))
frappe.db.commit()
quickbooks_supplier_list.append(supplier.quickbooks_supp_id)
except Exception, e:
if e.args[0] and e.args[0].startswith("402"):
raise e
else:
make_quickbooks_log(title=e.message, status="Error", method="create_Supplier", message=frappe.get_traceback(),
request_data=qb_supplier, exception=True)
return quickbooks_supplier_list
示例11: sync_erp_suppliers_to_quickbooks
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import _ [as 别名]
def sync_erp_suppliers_to_quickbooks():
Supplier_list = []
for erp_supplier in erp_supplier_data():
try:
if erp_supplier:
create_erp_suppliers_to_quickbooks(erp_supplier, Supplier_list)
else:
raise _("Supplier does not exist in ERPNext")
except Exception, e:
if e.args[0] and e.args[0].startswith("402"):
raise e
else:
make_quickbooks_log(title=e.message, status="Error", method="sync_erp_suppliers", message=frappe.get_traceback(),
request_data=erp_supplier, exception=True)
results = batch_create(Supplier_list)
return results
示例12: sync_erp_employees_to_quickbooks
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import _ [as 别名]
def sync_erp_employees_to_quickbooks():
Employee_list = []
for erp_employee in erp_employee_data():
try:
if erp_employee:
create_erp_employee_to_quickbooks(erp_employee, Employee_list)
else:
raise _("Employee does not exist in ERPNext")
except Exception, e:
if e.args[0] and e.args[0].startswith("402"):
raise e
else:
make_quickbooks_log(title=e.message, status="Error", method="sync_erp_employees_to_quickbooks", message=frappe.get_traceback(),
request_data=erp_employee, exception=True)
results = batch_create(Employee_list)
return results
示例13: sync_erp_sales_invoices_to_quickbooks
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import _ [as 别名]
def sync_erp_sales_invoices_to_quickbooks():
"""Sync ERPNext Invoice to QuickBooks"""
Sales_invoice_list = []
for erp_sales_invoice in erp_sales_invoice_data():
try:
if erp_sales_invoice:
create_erp_sales_invoice_to_quickbooks(erp_sales_invoice, Sales_invoice_list)
else:
raise _("Sales invoice does not exist in ERPNext")
except Exception, e:
if e.args[0] and e.args[0].startswith("402"):
raise e
else:
make_quickbooks_log(title=e.message, status="Error", method="sync_erp_sales_invoices_to_quickbooks", message=frappe.get_traceback(),
request_data=erp_sales_invoice, exception=True)
results = batch_create(Sales_invoice_list)
return results
示例14: sync_erp_accounts_to_quickbooks
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import _ [as 别名]
def sync_erp_accounts_to_quickbooks():
Account_list = []
for erp_account in erp_account_data():
try:
if erp_account:
create_erp_account_to_quickbooks(erp_account, Account_list)
else:
raise _("Account does not exist in ERPNext")
except Exception, e:
if e.args[0] and e.args[0].startswith("402"):
raise e
else:
make_quickbooks_log(title=e.message, status="Error", method="sync_erp_accounts_to_quickbooks", message=frappe.get_traceback(),
request_data=erp_account, exception=True)
results = batch_create(Account_list)
return results
示例15: copy_pricing_rule_from_previous_revision
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import _ [as 别名]
def copy_pricing_rule_from_previous_revision(base_item_code, current_rev):
"""This function adds all the items to pricing rules"""
new_code = str(base_item_code) + "_" + str(int(current_rev))
args = {
"item_code": str(base_item_code) + "_" + str(int(current_rev)-1),
"transaction_type": "buying"
}
args = frappe._dict(args)
frappe.msgprint(_("Copying Pricing Rules for " + args.item_code))
pr_result = get_pricing_rules(args)
pr_result = frappe.db.sql("""SELECT * FROM `tabPricing Rule` WHERE item_code=%(item_code)s ORDER by priority desc, name desc""", args , as_dict=1)
for rule in pr_result:
frappe.msgprint("Copying rule: " + str(rule.name))
pr_title = new_code + "-" + rule.supplier + "-" + str(rule.min_qty)
new_rule = frappe.get_doc({"doctype":"Pricing Rule", "min_qty": rule.min_qty, "apply_on": rule.apply_on, "item_code": new_code, "priority": rule.priority, "buying": rule.buying, "applicable_for": rule.applicable_for, "company": rule.company, "price_or_discount": rule.price_or_discount, "price": rule.price, "supplier": rule.supplier, "title": pr_title, "from_supplier_quotation": rule.from_supplier_quotation })
new_rule.insert()