Merge branch 'develop' into issue_25414
This commit is contained in:
commit
5604dccdb6
@ -824,29 +824,6 @@ frappe.ui.form.on('Sales Invoice', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Healthcare
|
|
||||||
patient: function(frm) {
|
|
||||||
if (frappe.boot.active_domains.includes("Healthcare")){
|
|
||||||
if(frm.doc.patient){
|
|
||||||
frappe.call({
|
|
||||||
method: "frappe.client.get_value",
|
|
||||||
args:{
|
|
||||||
doctype: "Patient",
|
|
||||||
filters: {
|
|
||||||
"name": frm.doc.patient
|
|
||||||
},
|
|
||||||
fieldname: "customer"
|
|
||||||
},
|
|
||||||
callback:function(r) {
|
|
||||||
if(r && r.message.customer){
|
|
||||||
frm.set_value("customer", r.message.customer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
project: function(frm) {
|
project: function(frm) {
|
||||||
if (frm.doc.project) {
|
if (frm.doc.project) {
|
||||||
frm.events.add_timesheet_data(frm, {
|
frm.events.add_timesheet_data(frm, {
|
||||||
@ -976,25 +953,6 @@ frappe.ui.form.on('Sales Invoice', {
|
|||||||
if (frm.doc.is_debit_note) {
|
if (frm.doc.is_debit_note) {
|
||||||
frm.set_df_property('return_against', 'label', __('Adjustment Against'));
|
frm.set_df_property('return_against', 'label', __('Adjustment Against'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frappe.boot.active_domains.includes("Healthcare")) {
|
|
||||||
frm.set_df_property("patient", "hidden", 0);
|
|
||||||
frm.set_df_property("patient_name", "hidden", 0);
|
|
||||||
frm.set_df_property("ref_practitioner", "hidden", 0);
|
|
||||||
if (cint(frm.doc.docstatus==0) && cur_frm.page.current_view_name!=="pos" && !frm.doc.is_return) {
|
|
||||||
frm.add_custom_button(__('Healthcare Services'), function() {
|
|
||||||
get_healthcare_services_to_invoice(frm);
|
|
||||||
},__("Get Items From"));
|
|
||||||
frm.add_custom_button(__('Prescriptions'), function() {
|
|
||||||
get_drugs_to_invoice(frm);
|
|
||||||
},__("Get Items From"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
frm.set_df_property("patient", "hidden", 1);
|
|
||||||
frm.set_df_property("patient_name", "hidden", 1);
|
|
||||||
frm.set_df_property("ref_practitioner", "hidden", 1);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
create_invoice_discounting: function(frm) {
|
create_invoice_discounting: function(frm) {
|
||||||
|
@ -80,13 +80,6 @@ calendars = [
|
|||||||
"Holiday List",
|
"Holiday List",
|
||||||
]
|
]
|
||||||
|
|
||||||
domains = {
|
|
||||||
"Distribution": "erpnext.domains.distribution",
|
|
||||||
"Manufacturing": "erpnext.domains.manufacturing",
|
|
||||||
"Retail": "erpnext.domains.retail",
|
|
||||||
"Services": "erpnext.domains.services",
|
|
||||||
}
|
|
||||||
|
|
||||||
website_generators = ["Item Group", "Website Item", "BOM", "Sales Partner", "Job Opening"]
|
website_generators = ["Item Group", "Website Item", "BOM", "Sales Partner", "Job Opening"]
|
||||||
|
|
||||||
website_context = {
|
website_context = {
|
||||||
|
@ -3,11 +3,6 @@
|
|||||||
|
|
||||||
frappe.ui.form.on(cur_frm.doctype, {
|
frappe.ui.form.on(cur_frm.doctype, {
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
if (!frappe.boot.active_domains.includes("Non Profit")) {
|
|
||||||
frm.set_df_property('applicant_type', 'options', ['Employee', 'Customer']);
|
|
||||||
frm.refresh_field('applicant_type');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (['Loan Disbursement', 'Loan Repayment', 'Loan Interest Accrual', 'Loan Write Off'].includes(frm.doc.doctype)
|
if (['Loan Disbursement', 'Loan Repayment', 'Loan Interest Accrual', 'Loan Write Off'].includes(frm.doc.doctype)
|
||||||
&& frm.doc.docstatus > 0) {
|
&& frm.doc.docstatus > 0) {
|
||||||
|
|
||||||
|
@ -12,36 +12,6 @@ frappe.setup.on("before_load", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
erpnext.setup.slides_settings = [
|
erpnext.setup.slides_settings = [
|
||||||
{
|
|
||||||
// Domain
|
|
||||||
name: 'domain',
|
|
||||||
title: __('Select your Domains'),
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
fieldname: 'domains',
|
|
||||||
label: __('Domains'),
|
|
||||||
fieldtype: 'MultiCheck',
|
|
||||||
options: [
|
|
||||||
{ "label": __("Distribution"), "value": "Distribution" },
|
|
||||||
{ "label": __("Manufacturing"), "value": "Manufacturing" },
|
|
||||||
{ "label": __("Retail"), "value": "Retail" },
|
|
||||||
{ "label": __("Services"), "value": "Services" },
|
|
||||||
{ "label": __("Healthcare (beta)"), "value": "Healthcare" },
|
|
||||||
{ "label": __("Non Profit (beta)"), "value": "Non Profit" }
|
|
||||||
], reqd: 1
|
|
||||||
},
|
|
||||||
],
|
|
||||||
// help: __('Select the nature of your business.'),
|
|
||||||
validate: function () {
|
|
||||||
if (this.values.domains.length === 0) {
|
|
||||||
frappe.msgprint(__("Please select at least one domain."));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
frappe.setup.domains = this.values.domains;
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Brand
|
// Brand
|
||||||
name: 'brand',
|
name: 'brand',
|
||||||
|
@ -147,9 +147,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "domain",
|
"fieldname": "domain",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Data",
|
||||||
"label": "Domain",
|
"label": "Domain"
|
||||||
"options": "Domain"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "parent_company",
|
"fieldname": "parent_company",
|
||||||
@ -748,7 +747,7 @@
|
|||||||
"image_field": "company_logo",
|
"image_field": "company_logo",
|
||||||
"is_tree": 1,
|
"is_tree": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-01-25 10:33:16.826067",
|
"modified": "2022-04-27 10:33:16.826067",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Setup",
|
"module": "Setup",
|
||||||
"name": "Company",
|
"name": "Company",
|
||||||
|
@ -30,7 +30,6 @@ def create_fiscal_year_and_company(args):
|
|||||||
"country": args.get("country"),
|
"country": args.get("country"),
|
||||||
"create_chart_of_accounts_based_on": "Standard Template",
|
"create_chart_of_accounts_based_on": "Standard Template",
|
||||||
"chart_of_accounts": args.get("chart_of_accounts"),
|
"chart_of_accounts": args.get("chart_of_accounts"),
|
||||||
"domain": args.get("domains")[0],
|
|
||||||
}
|
}
|
||||||
).insert()
|
).insert()
|
||||||
|
|
||||||
|
@ -26,9 +26,6 @@ def set_default_settings(args):
|
|||||||
system_settings.email_footer_address = args.get("company_name")
|
system_settings.email_footer_address = args.get("company_name")
|
||||||
system_settings.save()
|
system_settings.save()
|
||||||
|
|
||||||
domain_settings = frappe.get_single("Domain Settings")
|
|
||||||
domain_settings.set_active_domains(args.get("domains"))
|
|
||||||
|
|
||||||
stock_settings = frappe.get_doc("Stock Settings")
|
stock_settings = frappe.get_doc("Stock Settings")
|
||||||
stock_settings.item_naming_by = "Item Code"
|
stock_settings.item_naming_by = "Item Code"
|
||||||
stock_settings.valuation_method = "FIFO"
|
stock_settings.valuation_method = "FIFO"
|
||||||
|
@ -43,13 +43,6 @@ default_sales_partner_type = [
|
|||||||
|
|
||||||
def install(country=None):
|
def install(country=None):
|
||||||
records = [
|
records = [
|
||||||
# domains
|
|
||||||
{"doctype": "Domain", "domain": "Distribution"},
|
|
||||||
{"doctype": "Domain", "domain": "Manufacturing"},
|
|
||||||
{"doctype": "Domain", "domain": "Retail"},
|
|
||||||
{"doctype": "Domain", "domain": "Services"},
|
|
||||||
{"doctype": "Domain", "domain": "Healthcare"},
|
|
||||||
{"doctype": "Domain", "domain": "Non Profit"},
|
|
||||||
# ensure at least an empty Address Template exists for this Country
|
# ensure at least an empty Address Template exists for this Country
|
||||||
{"doctype": "Address Template", "country": country},
|
{"doctype": "Address Template", "country": country},
|
||||||
# item group
|
# item group
|
||||||
@ -789,7 +782,6 @@ def install_defaults(args=None):
|
|||||||
frappe.db.set_value("Stock Settings", None, "email_footer_address", args.get("company_name"))
|
frappe.db.set_value("Stock Settings", None, "email_footer_address", args.get("company_name"))
|
||||||
|
|
||||||
set_global_defaults(args)
|
set_global_defaults(args)
|
||||||
set_active_domains(args)
|
|
||||||
update_stock_settings()
|
update_stock_settings()
|
||||||
update_shopping_cart_settings(args)
|
update_shopping_cart_settings(args)
|
||||||
|
|
||||||
@ -813,10 +805,6 @@ def set_global_defaults(args):
|
|||||||
global_defaults.save()
|
global_defaults.save()
|
||||||
|
|
||||||
|
|
||||||
def set_active_domains(args):
|
|
||||||
frappe.get_single("Domain Settings").set_active_domains(args.get("domains"))
|
|
||||||
|
|
||||||
|
|
||||||
def update_stock_settings():
|
def update_stock_settings():
|
||||||
stock_settings = frappe.get_doc("Stock Settings")
|
stock_settings = frappe.get_doc("Stock Settings")
|
||||||
stock_settings.item_naming_by = "Item Code"
|
stock_settings.item_naming_by = "Item Code"
|
||||||
|
@ -36,7 +36,6 @@ def get_setup_stages(args=None):
|
|||||||
"tasks": [
|
"tasks": [
|
||||||
{"fn": setup_defaults, "args": args, "fail_msg": _("Failed to setup defaults")},
|
{"fn": setup_defaults, "args": args, "fail_msg": _("Failed to setup defaults")},
|
||||||
{"fn": stage_four, "args": args, "fail_msg": _("Failed to create website")},
|
{"fn": stage_four, "args": args, "fail_msg": _("Failed to create website")},
|
||||||
{"fn": set_active_domains, "args": args, "fail_msg": _("Failed to add Domain")},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -84,8 +83,3 @@ def setup_complete(args=None):
|
|||||||
setup_defaults(args)
|
setup_defaults(args)
|
||||||
stage_four(args)
|
stage_four(args)
|
||||||
fin(args)
|
fin(args)
|
||||||
|
|
||||||
|
|
||||||
def set_active_domains(args):
|
|
||||||
domain_settings = frappe.get_single("Domain Settings")
|
|
||||||
domain_settings.set_active_domains(args.get("domains"))
|
|
||||||
|
@ -33,10 +33,8 @@ def before_tests():
|
|||||||
"email": "test@erpnext.com",
|
"email": "test@erpnext.com",
|
||||||
"password": "test",
|
"password": "test",
|
||||||
"chart_of_accounts": "Standard",
|
"chart_of_accounts": "Standard",
|
||||||
"domains": ["Manufacturing"],
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
_enable_all_domains()
|
|
||||||
|
|
||||||
frappe.db.sql("delete from `tabLeave Allocation`")
|
frappe.db.sql("delete from `tabLeave Allocation`")
|
||||||
frappe.db.sql("delete from `tabLeave Application`")
|
frappe.db.sql("delete from `tabLeave Application`")
|
||||||
@ -131,17 +129,9 @@ def format_ces_api(data, param):
|
|||||||
|
|
||||||
def enable_all_roles_and_domains():
|
def enable_all_roles_and_domains():
|
||||||
"""enable all roles and domain for testing"""
|
"""enable all roles and domain for testing"""
|
||||||
_enable_all_domains()
|
|
||||||
_enable_all_roles_for_admin()
|
_enable_all_roles_for_admin()
|
||||||
|
|
||||||
|
|
||||||
def _enable_all_domains():
|
|
||||||
domains = frappe.get_all("Domain", pluck="name")
|
|
||||||
if not domains:
|
|
||||||
return
|
|
||||||
frappe.get_single("Domain Settings").set_active_domains(domains)
|
|
||||||
|
|
||||||
|
|
||||||
def _enable_all_roles_for_admin():
|
def _enable_all_roles_for_admin():
|
||||||
from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to
|
from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to
|
||||||
|
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
Disease
|
|
||||||
Crop
|
|
||||||
Crop Cycle
|
|
||||||
Soil Texture
|
|
@ -1,152 +0,0 @@
|
|||||||
import os
|
|
||||||
import time
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
import frappe
|
|
||||||
import requests
|
|
||||||
|
|
||||||
from erpnext.erpnext_integrations.connectors.woocommerce_connection import order
|
|
||||||
|
|
||||||
|
|
||||||
class TestWoocommerce(unittest.TestCase):
|
|
||||||
def setUp(self):
|
|
||||||
|
|
||||||
woo_settings = frappe.get_doc("Woocommerce Settings")
|
|
||||||
if not woo_settings.secret:
|
|
||||||
woo_settings.secret = "ec434676aa1de0e502389f515c38f89f653119ab35e9117c7a79e576"
|
|
||||||
woo_settings.woocommerce_server_url = "https://woocommerce.mntechnique.com/"
|
|
||||||
woo_settings.api_consumer_key = "ck_fd43ff5756a6abafd95fadb6677100ce95a758a1"
|
|
||||||
woo_settings.api_consumer_secret = "cs_94360a1ad7bef7fa420a40cf284f7b3e0788454e"
|
|
||||||
woo_settings.enable_sync = 1
|
|
||||||
woo_settings.company = "_Test Company"
|
|
||||||
woo_settings.tax_account = "Sales Expenses - _TC"
|
|
||||||
woo_settings.f_n_f_account = "Expenses - _TC"
|
|
||||||
woo_settings.creation_user = "Administrator"
|
|
||||||
woo_settings.save(ignore_permissions=True)
|
|
||||||
|
|
||||||
def test_sales_order_for_woocommerce(self):
|
|
||||||
frappe.flags.woocomm_test_order_data = {
|
|
||||||
"id": 75,
|
|
||||||
"parent_id": 0,
|
|
||||||
"number": "74",
|
|
||||||
"order_key": "wc_order_5aa1281c2dacb",
|
|
||||||
"created_via": "checkout",
|
|
||||||
"version": "3.3.3",
|
|
||||||
"status": "processing",
|
|
||||||
"currency": "INR",
|
|
||||||
"date_created": "2018-03-08T12:10:04",
|
|
||||||
"date_created_gmt": "2018-03-08T12:10:04",
|
|
||||||
"date_modified": "2018-03-08T12:10:04",
|
|
||||||
"date_modified_gmt": "2018-03-08T12:10:04",
|
|
||||||
"discount_total": "0.00",
|
|
||||||
"discount_tax": "0.00",
|
|
||||||
"shipping_total": "150.00",
|
|
||||||
"shipping_tax": "0.00",
|
|
||||||
"cart_tax": "0.00",
|
|
||||||
"total": "649.00",
|
|
||||||
"total_tax": "0.00",
|
|
||||||
"prices_include_tax": False,
|
|
||||||
"customer_id": 12,
|
|
||||||
"customer_ip_address": "103.54.99.5",
|
|
||||||
"customer_user_agent": "mozilla\\/5.0 (x11; linux x86_64) applewebkit\\/537.36 (khtml, like gecko) chrome\\/64.0.3282.186 safari\\/537.36",
|
|
||||||
"customer_note": "",
|
|
||||||
"billing": {
|
|
||||||
"first_name": "Tony",
|
|
||||||
"last_name": "Stark",
|
|
||||||
"company": "_Test Company",
|
|
||||||
"address_1": "Mumbai",
|
|
||||||
"address_2": "",
|
|
||||||
"city": "Dadar",
|
|
||||||
"state": "MH",
|
|
||||||
"postcode": "123",
|
|
||||||
"country": "IN",
|
|
||||||
"email": "tony@gmail.com",
|
|
||||||
"phone": "123457890",
|
|
||||||
},
|
|
||||||
"shipping": {
|
|
||||||
"first_name": "Tony",
|
|
||||||
"last_name": "Stark",
|
|
||||||
"company": "",
|
|
||||||
"address_1": "Mumbai",
|
|
||||||
"address_2": "",
|
|
||||||
"city": "Dadar",
|
|
||||||
"state": "MH",
|
|
||||||
"postcode": "123",
|
|
||||||
"country": "IN",
|
|
||||||
},
|
|
||||||
"payment_method": "cod",
|
|
||||||
"payment_method_title": "Cash on delivery",
|
|
||||||
"transaction_id": "",
|
|
||||||
"date_paid": "",
|
|
||||||
"date_paid_gmt": "",
|
|
||||||
"date_completed": "",
|
|
||||||
"date_completed_gmt": "",
|
|
||||||
"cart_hash": "8e76b020d5790066496f244860c4703f",
|
|
||||||
"meta_data": [],
|
|
||||||
"line_items": [
|
|
||||||
{
|
|
||||||
"id": 80,
|
|
||||||
"name": "Marvel",
|
|
||||||
"product_id": 56,
|
|
||||||
"variation_id": 0,
|
|
||||||
"quantity": 1,
|
|
||||||
"tax_class": "",
|
|
||||||
"subtotal": "499.00",
|
|
||||||
"subtotal_tax": "0.00",
|
|
||||||
"total": "499.00",
|
|
||||||
"total_tax": "0.00",
|
|
||||||
"taxes": [],
|
|
||||||
"meta_data": [],
|
|
||||||
"sku": "",
|
|
||||||
"price": 499,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tax_lines": [],
|
|
||||||
"shipping_lines": [
|
|
||||||
{
|
|
||||||
"id": 81,
|
|
||||||
"method_title": "Flat rate",
|
|
||||||
"method_id": "flat_rate:1",
|
|
||||||
"total": "150.00",
|
|
||||||
"total_tax": "0.00",
|
|
||||||
"taxes": [],
|
|
||||||
"meta_data": [{"id": 623, "key": "Items", "value": "Marvel × 1"}],
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"fee_lines": [],
|
|
||||||
"coupon_lines": [],
|
|
||||||
"refunds": [],
|
|
||||||
}
|
|
||||||
order()
|
|
||||||
|
|
||||||
self.assertTrue(frappe.get_value("Customer", {"woocommerce_email": "tony@gmail.com"}))
|
|
||||||
self.assertTrue(frappe.get_value("Item", {"woocommerce_id": 56}))
|
|
||||||
self.assertTrue(frappe.get_value("Sales Order", {"woocommerce_id": 75}))
|
|
||||||
frappe.flags.woocomm_test_order_data = {}
|
|
||||||
|
|
||||||
|
|
||||||
def emulate_request():
|
|
||||||
# Emulate Woocommerce Request
|
|
||||||
headers = {
|
|
||||||
"X-Wc-Webhook-Event": "created",
|
|
||||||
"X-Wc-Webhook-Signature": "h1SjzQMPwd68MF5bficeFq20/RkQeRLsb9AVCUz/rLs=",
|
|
||||||
}
|
|
||||||
# Emulate Request Data
|
|
||||||
data = """{"id":74,"parent_id":0,"number":"74","order_key":"wc_order_5aa1281c2dacb","created_via":"checkout","version":"3.3.3","status":"processing","currency":"INR","date_created":"2018-03-08T12:10:04","date_created_gmt":"2018-03-08T12:10:04","date_modified":"2018-03-08T12:10:04","date_modified_gmt":"2018-03-08T12:10:04","discount_total":"0.00","discount_tax":"0.00","shipping_total":"150.00","shipping_tax":"0.00","cart_tax":"0.00","total":"649.00","total_tax":"0.00","prices_include_tax":false,"customer_id":12,"customer_ip_address":"103.54.99.5","customer_user_agent":"mozilla\\/5.0 (x11; linux x86_64) applewebkit\\/537.36 (khtml, like gecko) chrome\\/64.0.3282.186 safari\\/537.36","customer_note":"","billing":{"first_name":"Tony","last_name":"Stark","company":"Woocommerce","address_1":"Mumbai","address_2":"","city":"Dadar","state":"MH","postcode":"123","country":"IN","email":"tony@gmail.com","phone":"123457890"},"shipping":{"first_name":"Tony","last_name":"Stark","company":"","address_1":"Mumbai","address_2":"","city":"Dadar","state":"MH","postcode":"123","country":"IN"},"payment_method":"cod","payment_method_title":"Cash on delivery","transaction_id":"","date_paid":null,"date_paid_gmt":null,"date_completed":null,"date_completed_gmt":null,"cart_hash":"8e76b020d5790066496f244860c4703f","meta_data":[],"line_items":[{"id":80,"name":"Marvel","product_id":56,"variation_id":0,"quantity":1,"tax_class":"","subtotal":"499.00","subtotal_tax":"0.00","total":"499.00","total_tax":"0.00","taxes":[],"meta_data":[],"sku":"","price":499}],"tax_lines":[],"shipping_lines":[{"id":81,"method_title":"Flat rate","method_id":"flat_rate:1","total":"150.00","total_tax":"0.00","taxes":[],"meta_data":[{"id":623,"key":"Items","value":"Marvel × 1"}]}],"fee_lines":[],"coupon_lines":[],"refunds":[]}"""
|
|
||||||
|
|
||||||
# Build URL
|
|
||||||
port = frappe.get_site_config().webserver_port or "8000"
|
|
||||||
|
|
||||||
if os.environ.get("CI"):
|
|
||||||
host = "localhost"
|
|
||||||
else:
|
|
||||||
host = frappe.local.site
|
|
||||||
|
|
||||||
url = "http://{site}:{port}/api/method/erpnext.erpnext_integrations.connectors.woocommerce_connection.order".format(
|
|
||||||
site=host, port=port
|
|
||||||
)
|
|
||||||
|
|
||||||
r = requests.post(url=url, headers=headers, data=data)
|
|
||||||
|
|
||||||
time.sleep(5)
|
|
||||||
return r
|
|
@ -1,21 +0,0 @@
|
|||||||
import frappe
|
|
||||||
|
|
||||||
from erpnext.bulk_transaction.doctype.bulk_transaction_logger.test_bulk_transaction_logger import (
|
|
||||||
create_company,
|
|
||||||
create_customer,
|
|
||||||
create_item,
|
|
||||||
create_so,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
|
||||||
def create_records():
|
|
||||||
create_company()
|
|
||||||
create_customer()
|
|
||||||
create_item()
|
|
||||||
|
|
||||||
gd = frappe.get_doc("Global Defaults")
|
|
||||||
gd.set("default_company", "Test Bulk")
|
|
||||||
gd.save()
|
|
||||||
frappe.clear_cache()
|
|
||||||
create_so()
|
|
@ -1,75 +0,0 @@
|
|||||||
import frappe
|
|
||||||
from frappe.utils import getdate
|
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
|
||||||
def create_employee_records():
|
|
||||||
create_company()
|
|
||||||
create_missing_designation()
|
|
||||||
|
|
||||||
frappe.db.sql("DELETE FROM tabEmployee WHERE company='Test Org Chart'")
|
|
||||||
|
|
||||||
emp1 = create_employee("Test Employee 1", "CEO")
|
|
||||||
emp2 = create_employee("Test Employee 2", "CTO")
|
|
||||||
emp3 = create_employee("Test Employee 3", "Head of Marketing and Sales", emp1)
|
|
||||||
emp4 = create_employee("Test Employee 4", "Project Manager", emp2)
|
|
||||||
emp5 = create_employee("Test Employee 5", "Engineer", emp2)
|
|
||||||
emp6 = create_employee("Test Employee 6", "Analyst", emp3)
|
|
||||||
emp7 = create_employee("Test Employee 7", "Software Developer", emp4)
|
|
||||||
|
|
||||||
employees = [emp1, emp2, emp3, emp4, emp5, emp6, emp7]
|
|
||||||
return employees
|
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
|
||||||
def get_employee_records():
|
|
||||||
return frappe.db.get_list(
|
|
||||||
"Employee", filters={"company": "Test Org Chart"}, pluck="name", order_by="name"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def create_company():
|
|
||||||
company = frappe.db.exists("Company", "Test Org Chart")
|
|
||||||
if not company:
|
|
||||||
company = (
|
|
||||||
frappe.get_doc(
|
|
||||||
{
|
|
||||||
"doctype": "Company",
|
|
||||||
"company_name": "Test Org Chart",
|
|
||||||
"country": "India",
|
|
||||||
"default_currency": "INR",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.insert()
|
|
||||||
.name
|
|
||||||
)
|
|
||||||
|
|
||||||
return company
|
|
||||||
|
|
||||||
|
|
||||||
def create_employee(first_name, designation, reports_to=None):
|
|
||||||
employee = frappe.db.exists("Employee", {"first_name": first_name, "designation": designation})
|
|
||||||
if not employee:
|
|
||||||
employee = (
|
|
||||||
frappe.get_doc(
|
|
||||||
{
|
|
||||||
"doctype": "Employee",
|
|
||||||
"first_name": first_name,
|
|
||||||
"company": "Test Org Chart",
|
|
||||||
"gender": "Female",
|
|
||||||
"date_of_birth": getdate("08-12-1998"),
|
|
||||||
"date_of_joining": getdate("01-01-2021"),
|
|
||||||
"designation": designation,
|
|
||||||
"reports_to": reports_to,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.insert()
|
|
||||||
.name
|
|
||||||
)
|
|
||||||
|
|
||||||
return employee
|
|
||||||
|
|
||||||
|
|
||||||
def create_missing_designation():
|
|
||||||
if not frappe.db.exists("Designation", "CTO"):
|
|
||||||
frappe.get_doc({"doctype": "Designation", "designation_name": "CTO"}).insert()
|
|
Loading…
x
Reference in New Issue
Block a user