當前位置: 首頁>>代碼示例>>Python>>正文


Python frappe.get_doc方法代碼示例

本文整理匯總了Python中frappe.get_doc方法的典型用法代碼示例。如果您正苦於以下問題:Python frappe.get_doc方法的具體用法?Python frappe.get_doc怎麽用?Python frappe.get_doc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在frappe的用法示例。


在下文中一共展示了frappe.get_doc方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: execute

# 需要導入模塊: import frappe [as 別名]
# 或者: from frappe import get_doc [as 別名]
def execute():
	service_name="BioTrack"
	if frappe.db.exists("Integration Service", service_name):
		integration_service = frappe.get_doc("Integration Service", service_name)
	else:
		integration_service = frappe.new_doc("Integration Service")
		integration_service.service = service_name

	integration_service.enabled = 1
	integration_service.flags.ignore_mandatory = True
	integration_service.save(ignore_permissions=True)

	settings = frappe.get_doc("BioTrack Settings")
	if not settings.synchronization:
		settings.synchronization = "All"

	if not settings.sync_frequency:
		settings.sync_frequency = "Daily"

	settings.flags.ignore_mandatory = True
	settings.save() 
開發者ID:webonyx,項目名稱:erpnext_biotrack,代碼行數:23,代碼來源:migrate_integration_service.py

示例2: validate_price_list_currency

# 需要導入模塊: import frappe [as 別名]
# 或者: from frappe import get_doc [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)) 
開發者ID:frappe,項目名稱:razorpay_integration,代碼行數:18,代碼來源:utils.py

示例3: confirm_payment

# 需要導入模塊: import frappe [as 別名]
# 或者: from frappe import get_doc [as 別名]
def confirm_payment(doc, api_key, api_secret, is_sandbox=False):
	"""
		An authorization is performed when user’s payment details are successfully authenticated by the bank.
		The money is deducted from the customer’s account, but will not be transferred to the merchant’s account
		until it is explicitly captured by merchant.
	"""
	if is_sandbox and doc.sanbox_response:
		resp = doc.sanbox_response
	else:
		resp = get_request("https://api.razorpay.com/v1/payments/{0}".format(doc.name),
			auth=frappe._dict({"api_key": api_key, "api_secret": api_secret}))

	if resp.get("status") == "authorized":
		doc.db_set('status', 'Authorized')
		doc.run_method('on_payment_authorized')

		if doc.reference_doctype and doc.reference_docname:
			ref = frappe.get_doc(doc.reference_doctype, doc.reference_docname)
			ref.run_method('on_payment_authorized')

		doc.flags.status_changed_to = "Authorized" 
開發者ID:frappe,項目名稱:razorpay_integration,代碼行數:23,代碼來源:razorpay_payment.py

示例4: update_account

# 需要導入模塊: import frappe [as 別名]
# 或者: from frappe import get_doc [as 別名]
def update_account(args=None):
	frappe.local.flags.allow_unverified_charts = True
	if not args:
		args = frappe.local.form_dict
		args.pop("cmd")
	if not args.get("account_type"):
		args.account_type = None
	args.is_group = cint(args.is_group)
	account = frappe.get_doc("Account", args.name)
	account.update(args)
	account.flags.ignore_permissions = True
	if args.get("is_root"):
		account.flags.ignore_mandatory = True

	account.save()

	frappe.local.flags.allow_unverified_charts = False 
開發者ID:frappe,項目名稱:chart_of_accounts_builder,代碼行數:19,代碼來源:utils.py

示例5: add_testing_results

# 需要導入模塊: import frappe [as 別名]
# 或者: from frappe import get_doc [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") 
開發者ID:nataliamm,項目名稱:erpnext-warranty-management,代碼行數:22,代碼來源:warranty_request.py

示例6: add_repairing_results

# 需要導入模塊: import frappe [as 別名]
# 或者: from frappe import get_doc [as 別名]
def add_repairing_results(name, repairing_results, is_item_to_be_replaced=None):
    if frappe.db.get_value("Warranty Request", name, "is_repairing_completed"):
        frappe.throw("Repairing is already completed")
    frappe.db.set_value("Warranty Request", name, "is_repairing_completed", 1)
    update_status("Warranty Request", name, "Repairing Completed")
    frappe.db.set_value("Warranty Request", name, "resolution_date", now_datetime())
    frappe.db.set_value("Warranty Request Purposes", {"parent": name}, "work_done", repairing_results)
    warranty_claim = frappe.db.get_value("Warranty Request", name, "warranty_claim")
    if warranty_claim:
        update_status("Warranty Claim", warranty_claim, "Repairing Completed")
    doc_warranty_request = frappe.get_doc("Warranty Request", name)
    doc_warranty_request.add_comment("Comment", _("Repairing Item has been completed"))
    if is_item_to_be_replaced:
        frappe.db.set_value("Warranty Request", name, "is_item_to_be_replaced", 1)
        so = make_sales_order(name)
        so.insert()
        frappe.db.set_value("Warranty Request", name, "sales_order", so.name)
        update_status("Warranty Request", name, "Closed")
        frappe.msgprint("sales Order %s was created automatically" % so.name)
    frappe.clear_cache(doctype="Warranty Request") 
開發者ID:nataliamm,項目名稱:erpnext-warranty-management,代碼行數:22,代碼來源:warranty_request.py

示例7: collect_item

# 需要導入模塊: import frappe [as 別名]
# 或者: from frappe import get_doc [as 別名]
def collect_item(self, item_group_filter, qty, properties=None):
		item_group = frappe.get_doc("Item Group", item_group_filter)
		strain = self.get_strain()

		default_properties = frappe._dict({
			"item_name": " ".join([strain, item_group.item_group_name]),
			"item_code": generate_item_code(),
			"item_group": item_group.name,
			"default_warehouse": self.target_warehouse,
			"strain": strain,
			"stock_uom": "Gram",
			"is_stock_item": 1,
			"plant_entry": self.name,
		})

		if isinstance(properties, dict):
			default_properties.update(properties)

		return make_item(properties=default_properties, qty=qty) 
開發者ID:webonyx,項目名稱:erpnext_biotrack,代碼行數:21,代碼來源:plant_entry.py

示例8: syn_samples

# 需要導入模塊: import frappe [as 別名]
# 或者: from frappe import get_doc [as 別名]
def syn_samples(samples):
	for inventory in samples:
		parent_ids = inventory.get("parentid") or []
		if not parent_ids:
			continue

		item_code = parent_ids[0]
		values = get_item_values(item_code, ["name", "test_result", "item_name"])
		if values:
			name, test_result, item_name = values
			if test_result:
				continue # already synced

			item = frappe.get_doc("Item", name)
			item.sample_id = inventory.get("barcode")
			item.save()

			quality_inspection = make_sample(item, inventory.get("remaining_quantity"))
			quality_inspection.flags.ignore_mandatory = True
			quality_inspection.save()

			frappe.db.commit()

		else:
			continue # not found related item 
開發者ID:webonyx,項目名稱:erpnext_biotrack,代碼行數:27,代碼來源:inventory.py

示例9: log_invalid_item

# 需要導入模塊: import frappe [as 別名]
# 或者: from frappe import get_doc [as 別名]
def log_invalid_item(item):
	frappe.db.sql("""delete from `tabCommunication`
					where
						reference_doctype=%s and reference_name=%s
						and communication_type='Comment'
						and comment_type='Cancelled'""", ("Item", item.name))

	frappe.get_doc({
		"doctype": "Communication",
		"communication_type": "Comment",
		"comment_type": "Cancelled",
		"reference_doctype": "Item",
		"reference_name": item.name,
		"subject": item.item_name,
		"full_name": get_fullname(item.owner),
		"reference_owner": item.owner,
		# "link_doctype": "Item",
		# "link_name": item.name
	}).insert(ignore_permissions=True) 
開發者ID:webonyx,項目名稱:erpnext_biotrack,代碼行數:21,代碼來源:inventory.py

示例10: make_sample

# 需要導入模塊: import frappe [as 別名]
# 或者: from frappe import get_doc [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 
開發者ID:webonyx,項目名稱:erpnext_biotrack,代碼行數:19,代碼來源:qa_sample.py

示例11: sync

# 需要導入模塊: import frappe [as 別名]
# 或者: from frappe import get_doc [as 別名]
def sync():
    synced_list = []
    for biotrack_room in get_biotrack_inventory_rooms():
        if sync_warehouse(biotrack_room):
            synced_list.append(biotrack_room)

    # Bulk Inventory room
    if not frappe.db.exists('Warehouse', {'warehouse_name': default_stock_warehouse_name}):
        under_account = frappe.get_value('BioTrack Settings', None, 'inventory_room_parent_account')
        warehouse = frappe.get_doc({
            'doctype': 'Warehouse',
            'company': get_default_company(),
            'warehouse_name': default_stock_warehouse_name,
            'create_account_under': under_account
        })

        warehouse.insert(ignore_permissions=True)
        frappe.db.commit()

    return len(synced_list) 
開發者ID:webonyx,項目名稱:erpnext_biotrack,代碼行數:22,代碼來源:inventory_room.py

示例12: sync_qa_lab

# 需要導入模塊: import frappe [as 別名]
# 或者: from frappe import get_doc [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() 
開發者ID:webonyx,項目名稱:erpnext_biotrack,代碼行數:26,代碼來源:qa_lab.py

示例13: before_submit

# 需要導入模塊: import frappe [as 別名]
# 或者: from frappe import get_doc [as 別名]
def before_submit(doc, method):
	"""BioTrack sync up: inventory_new or inventory_adjust"""
	if doc.purpose == "Material Issue" and not doc.conversion:
		for item_entry in doc.get("items"):
			item = frappe.get_doc("Item", item_entry.item_code)
			if is_bio_item(item):
				if not item_entry.t_warehouse:
					_inventory_adjust(item, remove_quantity=item_entry.qty)
				# else:
					# inventory split and inventory_move

	elif doc.purpose == "Material Receipt":
		for item_entry in doc.get("items"):
			item = frappe.get_doc("Item", item_entry.item_code)

			if is_bio_item(item):
				_inventory_adjust(item, additional_quantity=item_entry.qty)

			# only sync up marijuana item
			elif item.is_marijuana_item:
				_inventory_new(item, item_entry.qty) 
開發者ID:webonyx,項目名稱:erpnext_biotrack,代碼行數:23,代碼來源:stock_entry.py

示例14: convert_on_submit

# 需要導入模塊: import frappe [as 別名]
# 或者: from frappe import get_doc [as 別名]
def convert_on_submit(plant_entry, barcodeid):
	res = None
	try:
		res = call("plant_convert_to_inventory", {
			"barcodeid": barcodeid
		})
	except BioTrackClientError as e:
		frappe.throw(cstr(e.message), title="BioTrackTHC sync up failed")

	if res:
		plant_entry.bio_transaction = res.get("transactionid")
		items = plant_entry.items or {}
		for name in items:
			item = items[name]
			if not item.barcode:
				plant = frappe.get_doc("Plant", name)
				if is_bio_plant(plant):
					item.barcode = plant.get("bio_barcode")
					item.bio_barcode = plant.get("bio_barcode")
					item.save() 
開發者ID:webonyx,項目名稱:erpnext_biotrack,代碼行數:22,代碼來源:plant_entry.py

示例15: item_test_result_lookup

# 需要導入模塊: import frappe [as 別名]
# 或者: from frappe import get_doc [as 別名]
def item_test_result_lookup(name):
	item = frappe.get_doc("Item", name)

	if not item.parent_item or item.test_result:
		data = {
			"test_result": item.test_result
		}

		for parameter in item.get("quality_parameters") or []:
			data[parameter.specification] = parameter.value

		if data.get("Total") or None:
			data["potency"] = data.get("Total")

		return data

	if item.parent_item:
		return item_test_result_lookup({"name": item.parent_item}) 
開發者ID:webonyx,項目名稱:erpnext_biotrack,代碼行數:20,代碼來源:item_utils.py


注:本文中的frappe.get_doc方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。