本文整理汇总了Python中frappe.new_doc方法的典型用法代码示例。如果您正苦于以下问题:Python frappe.new_doc方法的具体用法?Python frappe.new_doc怎么用?Python frappe.new_doc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类frappe
的用法示例。
在下文中一共展示了frappe.new_doc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import new_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()
示例2: create_company
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import new_doc [as 别名]
def create_company(company_name, country, default_currency, chart_of_accounts, forked_from=None):
frappe.local.flags.allow_unverified_charts = True
company = frappe.new_doc("Company")
company.country = country
company.default_currency = default_currency
company.chart_of_accounts = chart_of_accounts
company.abbr = random_string(3)
company.forked = 1
company.forked_from = forked_from
numbered_company_name = append_number_if_name_exists("Company", company_name)
company.company_name = numbered_company_name
company.name = numbered_company_name
company.flags.ignore_permissions = True
company.insert(ignore_permissions=True)
if frappe.local.message_log:
frappe.local.message_log = []
frappe.local.flags.allow_unverified_charts = False
return company.name
示例3: make_sample
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import new_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
示例4: get_bom_operation
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import new_doc [as 别名]
def get_bom_operation(bom, qty):
bom_doc = frappe.get_doc("BOM", bom)
atime = 0
cost = 0
num_operators = 0
operations = []
if bom_doc.with_operations:
for op in bom_doc.operations:
atime = atime + op.time_in_mins
cost = cost + op.operating_cost
num_operators = num_operators + 1
operations.append(op.operation)
doc = frappe.new_doc("BOM Costing Operations")
doc.minutes = atime
doc.num_operators = num_operators
doc.total_cost = cost * qty
doc.bom = bom_doc.name
doc.sort_name = bom.lower()
doc.operations = ", ".join(filter(None, operations))
doc.idx = None
return doc
示例5: setup_charts
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import new_doc [as 别名]
def setup_charts(delete_existing=True):
frappe.local.flags.allow_unverified_charts = True
# delete
if delete_existing:
for company in frappe.get_all("Company"):
if company.name not in ("Wind Power LLC", "Test Company"):
print "deleting {0}".format(company.name)
frappe.delete_doc("Company", company.name)
frappe.db.commit()
print "-"*40
for country in frappe.get_all("Country", fields=["name", "code"]):
charts = get_charts_for_country(country.name)
for i, chart in enumerate(charts):
if (chart != "Standard" or country.name == "United States"):
if not frappe.db.exists("Company", chart):
print chart.encode('utf-8')
company = frappe.new_doc("Company")
company.company_name = chart
company.country = country.name
company.chart_of_accounts = chart
company.abbr = country.code + str(i+1)
company.default_currency = "USD"
company.insert()
frappe.db.commit()
示例6: enqueue_disable_user_message
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import new_doc [as 别名]
def enqueue_disable_user_message(access_token):
message = frappe.new_doc("Hub Outgoing Message")
message.type = "CLIENT-DISABLE"
message.method = "disable_and_suspend_hub_user"
receiver_user = frappe.get_doc("Hub User", {"access_token": access_token})
message.receiver_site = receiver_user.site_name
message.save(ignore_permissions=True)
return 1
示例7: bulk_clone
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import new_doc [as 别名]
def bulk_clone(name):
source_plant = frappe.get_doc("Plant", name)
if source_plant.qty > 1:
warehouse = frappe.get_doc("Warehouse", source_plant.get("warehouse"))
location = frappe.get_value("BioTrack Settings", None, "location")
remaining_qty = source_plant.qty - 1
result = biotrackthc_call("plant_new", {
"room": warehouse.external_id,
"quantity": remaining_qty,
"strain": source_plant.strain,
"source": source_plant.item_code,
"mother": cint(source_plant.get("is_mother")),
"location": location
})
for barcode in result.get("barcode_id"):
plant = frappe.new_doc("Plant")
plant.update({
"barcode": barcode,
"item_group": source_plant.item_group,
"source": source_plant.item_code,
"strain": source_plant.strain,
"warehouse": source_plant.warehouse,
"state": source_plant.state,
"birthdate": now(),
})
plant.save()
# save directly with sql to avoid mistimestamp check
frappe.db.set_value("Plant", source_plant.name, "qty", 1, update_modified=False)
frappe.publish_realtime("list_update", {"doctype": "Plant"})
示例8: sync_warehouse
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import new_doc [as 别名]
def sync_warehouse(biotrack_data):
name = frappe.get_value(
'Warehouse', {
'external_id': biotrack_data.get('roomid')
}
)
if name:
warehouse = frappe.get_doc('Warehouse', name)
if not (frappe.flags.force_sync or False) and warehouse.external_transaction_id == biotrack_data.get(
"transactionid"):
return False
else:
warehouse = frappe.new_doc('Warehouse')
account = frappe.get_value("BioTrack Settings", None, "inventory_room_parent_account")
warehouse.update({
'company': get_default_company(),
"create_account_under": account,
'external_id': biotrack_data.get('roomid'),
})
warehouse.update({
"warehouse_name": biotrack_data.get("name"),
"external_transaction_id": biotrack_data.get("transactionid"),
"quarantine": biotrack_data.get("quarantine") or 0,
"disabled": biotrack_data.get("deleted"),
})
warehouse.save(ignore_permissions=True)
frappe.db.commit()
return True
示例9: new_item
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import new_doc [as 别名]
def new_item(item_name, item_group, strain, actual_qty, default_warehouse, plant=None):
item_group = frappe.get_doc("Item Group", item_group)
location = frappe.get_value("BioTrack Settings", None, "location")
call_data = {
"invtype": item_group.external_id,
"quantity": actual_qty,
"strain": strain,
}
if plant:
call_data["source_id"] = plant
data = biotrackthc_call("inventory_new", data={
"data": call_data,
"location": location
})
barcode = data['barcode_id'][0]
item = frappe.new_doc("Item")
item.update({
"item_name": item_name,
"item_code": barcode,
"barcode": barcode,
"item_group": item_group.name,
"default_warehouse": default_warehouse,
"strain": strain,
"plant": plant,
"stock_uom": "Gram",
"is_stock_item": 1,
"actual_qty": actual_qty,
})
item.insert()
make_stock_entry(item_code=barcode, target=default_warehouse, qty=actual_qty)
return item
示例10: execute
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import new_doc [as 别名]
def execute():
# new doctype "Plant Room" added, need to sync model first
frappe.model.sync.sync_all(verbose=True)
for name in frappe.get_all("Warehouse", {"warehouse_type": "Plant Room"}):
warehouse = frappe.get_doc("Warehouse", name)
doc = frappe.new_doc("Plant Room")
doc.update({
"plant_room_name": warehouse.get("warehouse_name"),
"company": warehouse.get("company"),
})
doc.save()
frappe.db.sql(
"UPDATE tabPlant SET plant_room=%(plant_room)s WHERE warehouse=%(warehouse)s",
{
"plant_room": doc.get("name"),
"warehouse": warehouse.get("name"),
}
)
frappe.db.sql(
"DELETE FROM tabWarehouse WHERE warehouse_type=%(warehouse_type)s",
{
"warehouse_type": "Plant Room",
}
)
frappe.delete_doc_if_exists("Custom Field", "Warehouse-warehouse_type")
示例11: create_Item
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import new_doc [as 别名]
def create_Item(quickbooks_obj):
""" Fetch Item data from QuickBooks and store in ERPNEXT """
item = None
quickbooks_item_list = []
item_query = """SELECT * FROM Item"""
fetch_item_qb = quickbooks_obj.query(item_query)
qb_item = fetch_item_qb['QueryResponse']
try:
item = frappe.new_doc("Item")
for fields in qb_item['Item']:
if not frappe.db.get_value("Item", {"quickbooks_item_id": str(fields.get('Id'))}, "name"):
item.quickbooks_item_id = cstr(fields.get('Id'))
item.quickbooks_item_synctoken = cstr(fields.get('SyncToken'))
item.item_code = cstr(fields.get('Name')) or cstr(fields.get('Id'))
item.item_name = cstr(fields.get('Name'))
item.is_stock_item = False if qb_item.get('Type') == 'NonInventory' or qb_item.get('Type') == 'Service' else True
item.is_fixed_asset = True if qb_item.get('Type') == 'NonInventory' else False
item.stock_uom = _("Nos")
item.item_group = _("Consumable")
item.disabled = True if fields.get('Active') == 'True' else False
item.barcode = fields.get('Sku') if fields.get('Sku') else ''
item.description = fields.get('Description') if fields.get('Description') else fields.get('Name')
quickbooks_item_list.append(str(fields.get('Id')))
item.insert()
except Exception, e:
if e.args[0] and e.args[0].startswith("402"):
raise e
return item
示例12: create_Employee
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import new_doc [as 别名]
def create_Employee(quickbooks_obj):
""" Fetch Employee data from QuickBooks and store in ERPNEXT """
employee = None
quickbooks_employee_list = []
employee_query = """SELECT Id, DisplayName, PrimaryPhone, Gender, PrimaryEmailAddr, BirthDate, HiredDate, ReleasedDate FROM Employee"""
qb_employee = quickbooks_obj.query(employee_query)
get_qb_employee = qb_employee['QueryResponse']['Employee']
try:
employee = frappe.new_doc("Employee")
for fields in get_qb_employee:
if not frappe.db.get_value("Employee", {"quickbooks_emp_id": str(fields.get('Id'))}, "name"):
employee.employee_name = fields.get('DisplayName')
employee.quickbooks_emp_id = str(fields.get('Id'))
employee.date_of_joining = fields.get('HiredDate') if fields.get('HiredDate') else strftime("%Y-%m-%d")
employee.date_of_birth = fields.get('BirthDate') if fields.get('BirthDate') else "2016-04-01"
employee.gender = fields.get('Gender') if fields.get('Gender') else "Male"
employee.cell_number =fields['Mobile'].get('FreeFormNumber','') if fields.get('Mobile') else ''
employee.personal_email =fields['PrimaryEmailAddr'].get('Address','') if fields.get('PrimaryEmailAddr') else ''
employee.insert()
quickbooks_employee_list.append(str(fields.get('Id')))
except Exception, e:
if e.args[0] and e.args[0].startswith("402"):
raise e
return quickbooks_employee_list
示例13: create_journal_entry
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import new_doc [as 别名]
def create_journal_entry(qb_journal_entry, quickbooks_journal_entry_list=[]):
""" store JournalEntry data in ERPNEXT """
journal = None
qb_journal_entry_id = ''
if qb_journal_entry.get('Id'):
qb_journal_entry_id = "JE" + qb_journal_entry.get('Id')
try:
if not frappe.db.get_value("Journal Entry", {"quickbooks_journal_entry_id": qb_journal_entry_id}, "name"):
journal = frappe.new_doc("Journal Entry")
journal.quickbooks_journal_entry_id = qb_journal_entry_id
journal.voucher_type = _("Journal Entry")
journal.naming_series = "JE-Quickbooks-"
journal.posting_date = qb_journal_entry.get('TxnDate')
get_journal_entry_account(journal,qb_journal_entry)
journal.cheque_no ="dummy check"
journal.cheque_date =qb_journal_entry.get('TxnDate')
journal.flags.ignore_mandatory = True
journal.save()
journal.submit()
frappe.db.commit()
quickbooks_journal_entry_list.append(journal.quickbooks_journal_entry_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_journal_entry", message=frappe.get_traceback(),
request_data=qb_journal_entry, exception=True)
return quickbooks_journal_entry_list
示例14: get_purchase_item
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import new_doc [as 别名]
def get_purchase_item(item_code,qty):
doc = frappe.new_doc("BOM Costing Purchased Item")
doc.item = item_code
doc.sort_name = item_code.lower()
doc.supplier = frappe.get_value("Item",doc.item,"default_supplier")
doc.price_list = frappe.get_value("Item",doc.item,"default_supplier")
doc.currency = frappe.get_value("Supplier", doc.supplier,"default_currency")
doc.description = frappe.get_value("Item",doc.item,"description")
doc.item_name= frappe.get_value("Item",doc.item,"item_name")
doc.qty_per_asm= qty
doc.idx = None
return doc
示例15: install_fixtures
# 需要导入模块: import frappe [as 别名]
# 或者: from frappe import new_doc [as 别名]
def install_fixtures():
records = [
{
'doctype': 'Item Group',
'item_group_name': 'WA State Classifications',
'is_group': 1,
'parent_item_group': _('All Item Groups'),
},
]
for r in records:
doc = frappe.new_doc(r.get("doctype"))
doc.update(r)
try:
doc.insert(ignore_permissions=True)
except frappe.DuplicateEntryError, e:
# pass DuplicateEntryError and continue
if e.args and e.args[0] == doc.doctype and e.args[1] == doc.name:
# make sure DuplicateEntryError is for the exact same doc and not a related doc
pass
else:
raise
frappe.db.commit()
from .inventory_types import item_groups_data
for data in item_groups_data:
if not frappe.db.exists("Item Group", data):
doc = frappe.new_doc("Item Group")
data["parent_item_group"] = "WA State Classifications"
data["is_group"] = 0
doc.update(data)
doc.insert()
frappe.db.commit()
company = get_default_company()
bio_settings = frappe.get_doc("BioTrack Settings")
bio_settings.inventory_room_parent_account = frappe.get_value("Account",
{"company": company, "account_name": "Stock Assets"})
bio_settings.flags.ignore_mandatory = True
bio_settings.save()
traceability = frappe.get_doc("Traceability Settings")
traceability.default_uom = "Gram"
traceability.save()