mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-15 03:01:22 +00:00
style: format js files
This commit is contained in:
@@ -2,17 +2,17 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.ui.form.on("Authorization Rule", {
|
||||
refresh: function(frm) {
|
||||
refresh: function (frm) {
|
||||
frm.events.set_master_type(frm);
|
||||
},
|
||||
set_master_type: function(frm) {
|
||||
if(frm.doc.based_on==="Customerwise Discount") {
|
||||
set_master_type: function (frm) {
|
||||
if (frm.doc.based_on === "Customerwise Discount") {
|
||||
unhide_field("master_name");
|
||||
frm.set_value("customer_or_item", "Customer");
|
||||
} else if(frm.doc.based_on==="Itemwise Discount") {
|
||||
} else if (frm.doc.based_on === "Itemwise Discount") {
|
||||
unhide_field("master_name");
|
||||
frm.set_value("customer_or_item", "Item");
|
||||
} else if(frm.doc.based_on==="Item Group wise Discount") {
|
||||
} else if (frm.doc.based_on === "Item Group wise Discount") {
|
||||
unhide_field("master_name");
|
||||
frm.set_value("customer_or_item", "Item Group");
|
||||
} else {
|
||||
@@ -21,84 +21,74 @@ frappe.ui.form.on("Authorization Rule", {
|
||||
hide_field("master_name");
|
||||
}
|
||||
},
|
||||
based_on: function(frm) {
|
||||
based_on: function (frm) {
|
||||
frm.events.set_master_type(frm);
|
||||
if (frm.doc.based_on === 'Not Applicable') {
|
||||
if (frm.doc.based_on === "Not Applicable") {
|
||||
frm.set_value("value", 0);
|
||||
hide_field('value');
|
||||
hide_field("value");
|
||||
} else {
|
||||
unhide_field('value');
|
||||
unhide_field("value");
|
||||
}
|
||||
},
|
||||
transaction: function(frm) {
|
||||
unhide_field(['system_role', 'system_user', 'value', 'based_on']);
|
||||
hide_field(['to_emp', 'to_designation']);
|
||||
}
|
||||
})
|
||||
|
||||
transaction: function (frm) {
|
||||
unhide_field(["system_role", "system_user", "value", "based_on"]);
|
||||
hide_field(["to_emp", "to_designation"]);
|
||||
},
|
||||
});
|
||||
|
||||
// Settings Module
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
if (doc.based_on == 'Not Applicable')
|
||||
hide_field('value');
|
||||
else
|
||||
unhide_field('value');
|
||||
cur_frm.cscript.refresh = function (doc, cdt, cdn) {
|
||||
if (doc.based_on == "Not Applicable") hide_field("value");
|
||||
else unhide_field("value");
|
||||
|
||||
unhide_field(['system_role', 'system_user', 'value']);
|
||||
hide_field(['to_emp', 'to_designation']);
|
||||
}
|
||||
unhide_field(["system_role", "system_user", "value"]);
|
||||
hide_field(["to_emp", "to_designation"]);
|
||||
};
|
||||
|
||||
cur_frm.fields_dict.system_user.get_query = function(doc, cdt, cdn) {
|
||||
return { query:"frappe.core.doctype.user.user.user_query" }
|
||||
}
|
||||
cur_frm.fields_dict.system_user.get_query = function (doc, cdt, cdn) {
|
||||
return { query: "frappe.core.doctype.user.user.user_query" };
|
||||
};
|
||||
|
||||
cur_frm.fields_dict.approving_user.get_query = function(doc, cdt, cdn) {
|
||||
return { query:"frappe.core.doctype.user.user.user_query" }
|
||||
}
|
||||
cur_frm.fields_dict.approving_user.get_query = function (doc, cdt, cdn) {
|
||||
return { query: "frappe.core.doctype.user.user.user_query" };
|
||||
};
|
||||
|
||||
cur_frm.fields_dict['approving_role'].get_query = cur_frm.fields_dict['system_role'].get_query;
|
||||
cur_frm.fields_dict["approving_role"].get_query = cur_frm.fields_dict["system_role"].get_query;
|
||||
|
||||
// System Role Trigger
|
||||
// -----------------------
|
||||
cur_frm.fields_dict['system_role'].get_query = function(doc) {
|
||||
cur_frm.fields_dict["system_role"].get_query = function (doc) {
|
||||
return {
|
||||
filters:[
|
||||
['Role', 'name', 'not in', 'Administrator, Guest, All']
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
filters: [["Role", "name", "not in", "Administrator, Guest, All"]],
|
||||
};
|
||||
};
|
||||
|
||||
// Master Name Trigger
|
||||
// --------------------
|
||||
cur_frm.fields_dict['master_name'].get_query = function(doc) {
|
||||
if (doc.based_on == 'Customerwise Discount')
|
||||
cur_frm.fields_dict["master_name"].get_query = function (doc) {
|
||||
if (doc.based_on == "Customerwise Discount")
|
||||
return {
|
||||
doctype: "Customer",
|
||||
filters:[
|
||||
['Customer', 'docstatus', '!=', 2]
|
||||
]
|
||||
}
|
||||
else if (doc.based_on == 'Itemwise Discount')
|
||||
filters: [["Customer", "docstatus", "!=", 2]],
|
||||
};
|
||||
else if (doc.based_on == "Itemwise Discount")
|
||||
return {
|
||||
doctype: "Item",
|
||||
query: "erpnext.controllers.queries.item_query"
|
||||
}
|
||||
else if (doc.based_on==="Item Group wise Discount")
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
};
|
||||
else if (doc.based_on === "Item Group wise Discount")
|
||||
return {
|
||||
doctype: "Item Group",
|
||||
filters: {
|
||||
"is_group": 0
|
||||
}
|
||||
}
|
||||
is_group: 0,
|
||||
},
|
||||
};
|
||||
else
|
||||
return {
|
||||
filters: [
|
||||
['Item', 'name', '=', 'cheating done to avoid null']
|
||||
]
|
||||
}
|
||||
}
|
||||
filters: [["Item", "name", "=", "cheating done to avoid null"]],
|
||||
};
|
||||
};
|
||||
|
||||
cur_frm.fields_dict.to_emp.get_query = function(doc, cdt, cdn) {
|
||||
return { query: "erpnext.controllers.queries.employee_query" }
|
||||
}
|
||||
cur_frm.fields_dict.to_emp.get_query = function (doc, cdt, cdn) {
|
||||
return { query: "erpnext.controllers.queries.employee_query" };
|
||||
};
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Branch', {
|
||||
refresh: function(frm) {
|
||||
|
||||
}
|
||||
frappe.ui.form.on("Branch", {
|
||||
refresh: function (frm) {},
|
||||
});
|
||||
|
||||
@@ -1,71 +1,99 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.ui.form.on('Brand', {
|
||||
frappe.ui.form.on("Brand", {
|
||||
setup: (frm) => {
|
||||
frm.fields_dict["brand_defaults"].grid.get_field("default_warehouse").get_query = function(doc, cdt, cdn) {
|
||||
frm.fields_dict["brand_defaults"].grid.get_field("default_warehouse").get_query = function (
|
||||
doc,
|
||||
cdt,
|
||||
cdn
|
||||
) {
|
||||
const row = locals[cdt][cdn];
|
||||
return {
|
||||
filters: { company: row.company }
|
||||
}
|
||||
}
|
||||
|
||||
frm.fields_dict["brand_defaults"].grid.get_field("default_discount_account").get_query = function(doc, cdt, cdn) {
|
||||
const row = locals[cdt][cdn];
|
||||
return {
|
||||
filters: {
|
||||
'report_type': 'Profit and Loss',
|
||||
'company': row.company,
|
||||
"is_group": 0
|
||||
}
|
||||
filters: { company: row.company },
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
frm.fields_dict["brand_defaults"].grid.get_field("buying_cost_center").get_query = function(doc, cdt, cdn) {
|
||||
frm.fields_dict["brand_defaults"].grid.get_field("default_discount_account").get_query = function (
|
||||
doc,
|
||||
cdt,
|
||||
cdn
|
||||
) {
|
||||
const row = locals[cdt][cdn];
|
||||
return {
|
||||
filters: {
|
||||
"is_group": 0,
|
||||
"company": row.company
|
||||
}
|
||||
}
|
||||
}
|
||||
report_type: "Profit and Loss",
|
||||
company: row.company,
|
||||
is_group: 0,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
frm.fields_dict["brand_defaults"].grid.get_field("expense_account").get_query = function(doc, cdt, cdn) {
|
||||
frm.fields_dict["brand_defaults"].grid.get_field("buying_cost_center").get_query = function (
|
||||
doc,
|
||||
cdt,
|
||||
cdn
|
||||
) {
|
||||
const row = locals[cdt][cdn];
|
||||
return {
|
||||
filters: {
|
||||
is_group: 0,
|
||||
company: row.company,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
frm.fields_dict["brand_defaults"].grid.get_field("expense_account").get_query = function (
|
||||
doc,
|
||||
cdt,
|
||||
cdn
|
||||
) {
|
||||
const row = locals[cdt][cdn];
|
||||
return {
|
||||
query: "erpnext.controllers.queries.get_expense_account",
|
||||
filters: { company: row.company }
|
||||
}
|
||||
}
|
||||
|
||||
frm.fields_dict["brand_defaults"].grid.get_field("default_provisional_account").get_query = function(doc, cdt, cdn) {
|
||||
const row = locals[cdt][cdn];
|
||||
return {
|
||||
filters: {
|
||||
"company": row.company,
|
||||
"root_type": ["in", ["Liability", "Asset"]],
|
||||
"is_group": 0
|
||||
}
|
||||
filters: { company: row.company },
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
frm.fields_dict["brand_defaults"].grid.get_field("selling_cost_center").get_query = function(doc, cdt, cdn) {
|
||||
frm.fields_dict["brand_defaults"].grid.get_field("default_provisional_account").get_query = function (
|
||||
doc,
|
||||
cdt,
|
||||
cdn
|
||||
) {
|
||||
const row = locals[cdt][cdn];
|
||||
return {
|
||||
filters: {
|
||||
"is_group": 0,
|
||||
"company": row.company
|
||||
}
|
||||
}
|
||||
}
|
||||
company: row.company,
|
||||
root_type: ["in", ["Liability", "Asset"]],
|
||||
is_group: 0,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
frm.fields_dict["brand_defaults"].grid.get_field("income_account").get_query = function(doc, cdt, cdn) {
|
||||
frm.fields_dict["brand_defaults"].grid.get_field("selling_cost_center").get_query = function (
|
||||
doc,
|
||||
cdt,
|
||||
cdn
|
||||
) {
|
||||
const row = locals[cdt][cdn];
|
||||
return {
|
||||
filters: {
|
||||
is_group: 0,
|
||||
company: row.company,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
frm.fields_dict["brand_defaults"].grid.get_field("income_account").get_query = function (
|
||||
doc,
|
||||
cdt,
|
||||
cdn
|
||||
) {
|
||||
const row = locals[cdt][cdn];
|
||||
return {
|
||||
query: "erpnext.controllers.queries.get_income_account",
|
||||
filters: { company: row.company }
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
filters: { company: row.company },
|
||||
};
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -4,119 +4,146 @@
|
||||
frappe.provide("erpnext.company");
|
||||
|
||||
frappe.ui.form.on("Company", {
|
||||
onload: function(frm) {
|
||||
onload: function (frm) {
|
||||
if (frm.doc.__islocal && frm.doc.parent_company) {
|
||||
frappe.db.get_value('Company', frm.doc.parent_company, 'is_group', (r) => {
|
||||
frappe.db.get_value("Company", frm.doc.parent_company, "is_group", (r) => {
|
||||
if (!r.is_group) {
|
||||
frm.set_value('parent_company', '');
|
||||
frm.set_value("parent_company", "");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
frm.call('check_if_transactions_exist').then(r => {
|
||||
frm.toggle_enable("default_currency", (!r.message));
|
||||
frm.call("check_if_transactions_exist").then((r) => {
|
||||
frm.toggle_enable("default_currency", !r.message);
|
||||
});
|
||||
},
|
||||
setup: function(frm) {
|
||||
setup: function (frm) {
|
||||
frm.__rename_queue = "long";
|
||||
erpnext.company.setup_queries(frm);
|
||||
|
||||
frm.set_query("parent_company", function() {
|
||||
frm.set_query("parent_company", function () {
|
||||
return {
|
||||
filters: {"is_group": 1}
|
||||
}
|
||||
filters: { is_group: 1 },
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query("default_selling_terms", function() {
|
||||
frm.set_query("default_selling_terms", function () {
|
||||
return { filters: { selling: 1 } };
|
||||
});
|
||||
|
||||
frm.set_query("default_buying_terms", function() {
|
||||
frm.set_query("default_buying_terms", function () {
|
||||
return { filters: { buying: 1 } };
|
||||
});
|
||||
|
||||
frm.set_query("default_in_transit_warehouse", function() {
|
||||
frm.set_query("default_in_transit_warehouse", function () {
|
||||
return {
|
||||
filters:{
|
||||
'warehouse_type' : 'Transit',
|
||||
'is_group': 0,
|
||||
'company': frm.doc.company_name
|
||||
}
|
||||
filters: {
|
||||
warehouse_type: "Transit",
|
||||
is_group: 0,
|
||||
company: frm.doc.company_name,
|
||||
},
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
company_name: function(frm) {
|
||||
if(frm.doc.__islocal) {
|
||||
company_name: function (frm) {
|
||||
if (frm.doc.__islocal) {
|
||||
// add missing " " arg in split method
|
||||
let parts = frm.doc.company_name.split(" ");
|
||||
let abbr = $.map(parts, function (p) {
|
||||
return p? p.substr(0, 1) : null;
|
||||
return p ? p.substr(0, 1) : null;
|
||||
}).join("");
|
||||
frm.set_value("abbr", abbr);
|
||||
}
|
||||
},
|
||||
|
||||
parent_company: function(frm) {
|
||||
parent_company: function (frm) {
|
||||
var bool = frm.doc.parent_company ? true : false;
|
||||
frm.set_value('create_chart_of_accounts_based_on', bool ? "Existing Company" : "");
|
||||
frm.set_value('existing_company', bool ? frm.doc.parent_company : "");
|
||||
frm.set_value("create_chart_of_accounts_based_on", bool ? "Existing Company" : "");
|
||||
frm.set_value("existing_company", bool ? frm.doc.parent_company : "");
|
||||
disbale_coa_fields(frm, bool);
|
||||
},
|
||||
|
||||
date_of_commencement: function(frm) {
|
||||
if(frm.doc.date_of_commencement<frm.doc.date_of_incorporation)
|
||||
{
|
||||
date_of_commencement: function (frm) {
|
||||
if (frm.doc.date_of_commencement < frm.doc.date_of_incorporation) {
|
||||
frappe.throw(__("Date of Commencement should be greater than Date of Incorporation"));
|
||||
}
|
||||
if(!frm.doc.date_of_commencement){
|
||||
frm.doc.date_of_incorporation = ""
|
||||
if (!frm.doc.date_of_commencement) {
|
||||
frm.doc.date_of_incorporation = "";
|
||||
}
|
||||
},
|
||||
|
||||
refresh: function(frm) {
|
||||
frm.toggle_display('address_html', !frm.is_new());
|
||||
refresh: function (frm) {
|
||||
frm.toggle_display("address_html", !frm.is_new());
|
||||
|
||||
if (!frm.is_new()) {
|
||||
frm.doc.abbr && frm.set_df_property("abbr", "read_only", 1);
|
||||
disbale_coa_fields(frm);
|
||||
frappe.contacts.render_address_and_contact(frm);
|
||||
|
||||
if (frappe.perm.has_perm("Cost Center", 0, 'read')) {
|
||||
frm.add_custom_button(__('Cost Centers'), function() {
|
||||
frappe.set_route('Tree', 'Cost Center', {'company': frm.doc.name});
|
||||
}, __("View"));
|
||||
if (frappe.perm.has_perm("Cost Center", 0, "read")) {
|
||||
frm.add_custom_button(
|
||||
__("Cost Centers"),
|
||||
function () {
|
||||
frappe.set_route("Tree", "Cost Center", { company: frm.doc.name });
|
||||
},
|
||||
__("View")
|
||||
);
|
||||
}
|
||||
|
||||
if (frappe.perm.has_perm("Account", 0, 'read')) {
|
||||
frm.add_custom_button(__('Chart of Accounts'), function() {
|
||||
frappe.set_route('Tree', 'Account', {'company': frm.doc.name});
|
||||
}, __("View"));
|
||||
if (frappe.perm.has_perm("Account", 0, "read")) {
|
||||
frm.add_custom_button(
|
||||
__("Chart of Accounts"),
|
||||
function () {
|
||||
frappe.set_route("Tree", "Account", { company: frm.doc.name });
|
||||
},
|
||||
__("View")
|
||||
);
|
||||
}
|
||||
|
||||
if (frappe.perm.has_perm("Sales Taxes and Charges Template", 0, 'read')) {
|
||||
frm.add_custom_button(__('Sales Tax Template'), function() {
|
||||
frappe.set_route('List', 'Sales Taxes and Charges Template', {'company': frm.doc.name});
|
||||
}, __("View"));
|
||||
if (frappe.perm.has_perm("Sales Taxes and Charges Template", 0, "read")) {
|
||||
frm.add_custom_button(
|
||||
__("Sales Tax Template"),
|
||||
function () {
|
||||
frappe.set_route("List", "Sales Taxes and Charges Template", {
|
||||
company: frm.doc.name,
|
||||
});
|
||||
},
|
||||
__("View")
|
||||
);
|
||||
}
|
||||
|
||||
if (frappe.perm.has_perm("Purchase Taxes and Charges Template", 0, 'read')) {
|
||||
frm.add_custom_button(__('Purchase Tax Template'), function() {
|
||||
frappe.set_route('List', 'Purchase Taxes and Charges Template', {'company': frm.doc.name});
|
||||
}, __("View"));
|
||||
if (frappe.perm.has_perm("Purchase Taxes and Charges Template", 0, "read")) {
|
||||
frm.add_custom_button(
|
||||
__("Purchase Tax Template"),
|
||||
function () {
|
||||
frappe.set_route("List", "Purchase Taxes and Charges Template", {
|
||||
company: frm.doc.name,
|
||||
});
|
||||
},
|
||||
__("View")
|
||||
);
|
||||
}
|
||||
|
||||
if (frm.has_perm('write')) {
|
||||
frm.add_custom_button(__('Create Tax Template'), function() {
|
||||
frm.trigger("make_default_tax_template");
|
||||
}, __('Manage'));
|
||||
if (frm.has_perm("write")) {
|
||||
frm.add_custom_button(
|
||||
__("Create Tax Template"),
|
||||
function () {
|
||||
frm.trigger("make_default_tax_template");
|
||||
},
|
||||
__("Manage")
|
||||
);
|
||||
}
|
||||
|
||||
if (frappe.user.has_role('System Manager')) {
|
||||
if (frm.has_perm('write')) {
|
||||
frm.add_custom_button(__('Delete Transactions'), function() {
|
||||
frm.trigger("delete_company_transactions");
|
||||
}, __('Manage'));
|
||||
if (frappe.user.has_role("System Manager")) {
|
||||
if (frm.has_perm("write")) {
|
||||
frm.add_custom_button(
|
||||
__("Delete Transactions"),
|
||||
function () {
|
||||
frm.trigger("delete_company_transactions");
|
||||
},
|
||||
__("Manage")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,157 +151,168 @@ frappe.ui.form.on("Company", {
|
||||
erpnext.company.set_chart_of_accounts_options(frm.doc);
|
||||
},
|
||||
|
||||
make_default_tax_template: function(frm) {
|
||||
make_default_tax_template: function (frm) {
|
||||
frm.call({
|
||||
method: "create_default_tax_template",
|
||||
doc: frm.doc,
|
||||
freeze: true,
|
||||
callback: function() {
|
||||
callback: function () {
|
||||
frappe.msgprint(__("Default tax templates for sales, purchase and items are created."));
|
||||
}
|
||||
})
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
country: function(frm) {
|
||||
country: function (frm) {
|
||||
erpnext.company.set_chart_of_accounts_options(frm.doc);
|
||||
},
|
||||
|
||||
delete_company_transactions: function(frm) {
|
||||
delete_company_transactions: function (frm) {
|
||||
frappe.call({
|
||||
method: "erpnext.setup.doctype.company.company.is_deletion_job_running",
|
||||
args: {
|
||||
company: frm.doc.name
|
||||
company: frm.doc.name,
|
||||
},
|
||||
freeze: true,
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
frappe.verify_password(function() {
|
||||
var d = frappe.prompt({
|
||||
fieldtype:"Data",
|
||||
fieldname: "company_name",
|
||||
label: __("Please enter the company name to confirm"),
|
||||
reqd: 1,
|
||||
description: __("Please make sure you really want to delete all the transactions for this company. Your master data will remain as it is. This action cannot be undone.")
|
||||
},
|
||||
function(data) {
|
||||
if(data.company_name !== frm.doc.name) {
|
||||
frappe.msgprint(__("Company name not same"));
|
||||
return;
|
||||
}
|
||||
frappe.call({
|
||||
method: "erpnext.setup.doctype.company.company.create_transaction_deletion_request",
|
||||
args: {
|
||||
company: data.company_name
|
||||
},
|
||||
freeze: true,
|
||||
callback: function(r, rt) { },
|
||||
onerror: function() {
|
||||
frappe.msgprint(__("Wrong Password"));
|
||||
}
|
||||
});
|
||||
},
|
||||
__("Delete all the Transactions for this Company"), __("Delete")
|
||||
);
|
||||
callback: function (r) {
|
||||
if (!r.exc) {
|
||||
frappe.verify_password(function () {
|
||||
var d = frappe.prompt(
|
||||
{
|
||||
fieldtype: "Data",
|
||||
fieldname: "company_name",
|
||||
label: __("Please enter the company name to confirm"),
|
||||
reqd: 1,
|
||||
description: __(
|
||||
"Please make sure you really want to delete all the transactions for this company. Your master data will remain as it is. This action cannot be undone."
|
||||
),
|
||||
},
|
||||
function (data) {
|
||||
if (data.company_name !== frm.doc.name) {
|
||||
frappe.msgprint(__("Company name not same"));
|
||||
return;
|
||||
}
|
||||
frappe.call({
|
||||
method: "erpnext.setup.doctype.company.company.create_transaction_deletion_request",
|
||||
args: {
|
||||
company: data.company_name,
|
||||
},
|
||||
freeze: true,
|
||||
callback: function (r, rt) {},
|
||||
onerror: function () {
|
||||
frappe.msgprint(__("Wrong Password"));
|
||||
},
|
||||
});
|
||||
},
|
||||
__("Delete all the Transactions for this Company"),
|
||||
__("Delete")
|
||||
);
|
||||
d.get_primary_btn().addClass("btn-danger");
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
erpnext.company.set_chart_of_accounts_options = function(doc) {
|
||||
erpnext.company.set_chart_of_accounts_options = function (doc) {
|
||||
var selected_value = doc.chart_of_accounts;
|
||||
if(doc.country) {
|
||||
if (doc.country) {
|
||||
return frappe.call({
|
||||
method: "erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts.get_charts_for_country",
|
||||
args: {
|
||||
"country": doc.country,
|
||||
"with_standard": true
|
||||
country: doc.country,
|
||||
with_standard: true,
|
||||
},
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
callback: function (r) {
|
||||
if (!r.exc) {
|
||||
set_field_options("chart_of_accounts", [""].concat(r.message).join("\n"));
|
||||
if(in_list(r.message, selected_value))
|
||||
if (in_list(r.message, selected_value))
|
||||
cur_frm.set_value("chart_of_accounts", selected_value);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
erpnext.company.setup_queries = function(frm) {
|
||||
$.each([
|
||||
["default_bank_account", {"account_type": "Bank"}],
|
||||
["default_cash_account", {"account_type": "Cash"}],
|
||||
["default_receivable_account", { "root_type": "Asset", "account_type": "Receivable" }],
|
||||
["default_payable_account", { "root_type": "Liability", "account_type": "Payable" }],
|
||||
["default_expense_account", {"root_type": "Expense"}],
|
||||
["default_income_account", {"root_type": "Income"}],
|
||||
["round_off_account", {"root_type": "Expense"}],
|
||||
["write_off_account", {"root_type": "Expense"}],
|
||||
["default_deferred_expense_account", {}],
|
||||
["default_deferred_revenue_account", {}],
|
||||
["default_discount_account", {}],
|
||||
["discount_allowed_account", {"root_type": "Expense"}],
|
||||
["discount_received_account", {"root_type": "Income"}],
|
||||
["exchange_gain_loss_account", {"root_type": ["in", ["Expense", "Income"]]}],
|
||||
["unrealized_exchange_gain_loss_account", {"root_type": ["in", ["Expense", "Income"]]}],
|
||||
["accumulated_depreciation_account",
|
||||
{"root_type": "Asset", "account_type": "Accumulated Depreciation"}],
|
||||
["depreciation_expense_account", {"root_type": "Expense", "account_type": "Depreciation"}],
|
||||
["disposal_account", {"report_type": "Profit and Loss"}],
|
||||
["default_inventory_account", {"account_type": "Stock"}],
|
||||
["cost_center", {}],
|
||||
["round_off_cost_center", {}],
|
||||
["depreciation_cost_center", {}],
|
||||
["capital_work_in_progress_account", {"account_type": "Capital Work in Progress"}],
|
||||
["asset_received_but_not_billed", {"account_type": "Asset Received But Not Billed"}],
|
||||
["unrealized_profit_loss_account", {"root_type": ["in", ["Liability", "Asset"]]}],
|
||||
["default_provisional_account", {"root_type": ["in", ["Liability", "Asset"]]}],
|
||||
["default_advance_received_account", {"root_type": "Liability", "account_type": "Receivable"}],
|
||||
["default_advance_paid_account", {"root_type": "Asset", "account_type": "Payable"}],
|
||||
], function(i, v) {
|
||||
erpnext.company.set_custom_query(frm, v);
|
||||
});
|
||||
|
||||
if (frm.doc.enable_perpetual_inventory) {
|
||||
$.each([
|
||||
["stock_adjustment_account",
|
||||
{"root_type": "Expense", "account_type": "Stock Adjustment"}],
|
||||
["stock_received_but_not_billed",
|
||||
{"root_type": "Liability", "account_type": "Stock Received But Not Billed"}],
|
||||
["service_received_but_not_billed",
|
||||
{"root_type": "Liability", "account_type": "Service Received But Not Billed"}],
|
||||
|
||||
], function(i, v) {
|
||||
erpnext.company.set_custom_query(frm, v);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
erpnext.company.set_custom_query = function(frm, v) {
|
||||
erpnext.company.setup_queries = function (frm) {
|
||||
$.each(
|
||||
[
|
||||
["default_bank_account", { account_type: "Bank" }],
|
||||
["default_cash_account", { account_type: "Cash" }],
|
||||
["default_receivable_account", { root_type: "Asset", account_type: "Receivable" }],
|
||||
["default_payable_account", { root_type: "Liability", account_type: "Payable" }],
|
||||
["default_expense_account", { root_type: "Expense" }],
|
||||
["default_income_account", { root_type: "Income" }],
|
||||
["round_off_account", { root_type: "Expense" }],
|
||||
["write_off_account", { root_type: "Expense" }],
|
||||
["default_deferred_expense_account", {}],
|
||||
["default_deferred_revenue_account", {}],
|
||||
["default_discount_account", {}],
|
||||
["discount_allowed_account", { root_type: "Expense" }],
|
||||
["discount_received_account", { root_type: "Income" }],
|
||||
["exchange_gain_loss_account", { root_type: ["in", ["Expense", "Income"]] }],
|
||||
["unrealized_exchange_gain_loss_account", { root_type: ["in", ["Expense", "Income"]] }],
|
||||
[
|
||||
"accumulated_depreciation_account",
|
||||
{ root_type: "Asset", account_type: "Accumulated Depreciation" },
|
||||
],
|
||||
["depreciation_expense_account", { root_type: "Expense", account_type: "Depreciation" }],
|
||||
["disposal_account", { report_type: "Profit and Loss" }],
|
||||
["default_inventory_account", { account_type: "Stock" }],
|
||||
["cost_center", {}],
|
||||
["round_off_cost_center", {}],
|
||||
["depreciation_cost_center", {}],
|
||||
["capital_work_in_progress_account", { account_type: "Capital Work in Progress" }],
|
||||
["asset_received_but_not_billed", { account_type: "Asset Received But Not Billed" }],
|
||||
["unrealized_profit_loss_account", { root_type: ["in", ["Liability", "Asset"]] }],
|
||||
["default_provisional_account", { root_type: ["in", ["Liability", "Asset"]] }],
|
||||
["default_advance_received_account", { root_type: "Liability", account_type: "Receivable" }],
|
||||
["default_advance_paid_account", { root_type: "Asset", account_type: "Payable" }],
|
||||
],
|
||||
function (i, v) {
|
||||
erpnext.company.set_custom_query(frm, v);
|
||||
}
|
||||
);
|
||||
|
||||
if (frm.doc.enable_perpetual_inventory) {
|
||||
$.each(
|
||||
[
|
||||
["stock_adjustment_account", { root_type: "Expense", account_type: "Stock Adjustment" }],
|
||||
[
|
||||
"stock_received_but_not_billed",
|
||||
{ root_type: "Liability", account_type: "Stock Received But Not Billed" },
|
||||
],
|
||||
[
|
||||
"service_received_but_not_billed",
|
||||
{ root_type: "Liability", account_type: "Service Received But Not Billed" },
|
||||
],
|
||||
],
|
||||
function (i, v) {
|
||||
erpnext.company.set_custom_query(frm, v);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
erpnext.company.set_custom_query = function (frm, v) {
|
||||
var filters = {
|
||||
"company": frm.doc.name,
|
||||
"is_group": 0
|
||||
company: frm.doc.name,
|
||||
is_group: 0,
|
||||
};
|
||||
|
||||
for (var key in v[1]) {
|
||||
filters[key] = v[1][key];
|
||||
}
|
||||
|
||||
frm.set_query(v[0], function() {
|
||||
frm.set_query(v[0], function () {
|
||||
return {
|
||||
filters: filters
|
||||
}
|
||||
filters: filters,
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var disbale_coa_fields = function(frm, bool=true) {
|
||||
var disbale_coa_fields = function (frm, bool = true) {
|
||||
frm.set_df_property("create_chart_of_accounts_based_on", "read_only", bool);
|
||||
frm.set_df_property("chart_of_accounts", "read_only", bool);
|
||||
frm.set_df_property("existing_company", "read_only", bool);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
frappe.listview_settings['Company'] = {
|
||||
frappe.listview_settings["Company"] = {
|
||||
onload() {
|
||||
frappe.breadcrumbs.add('Accounts');
|
||||
frappe.breadcrumbs.add("Accounts");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
frappe.treeview_settings["Company"] = {
|
||||
ignore_fields:["parent_company"],
|
||||
get_tree_nodes: 'erpnext.setup.doctype.company.company.get_children',
|
||||
add_tree_node: 'erpnext.setup.doctype.company.company.add_node',
|
||||
ignore_fields: ["parent_company"],
|
||||
get_tree_nodes: "erpnext.setup.doctype.company.company.get_children",
|
||||
add_tree_node: "erpnext.setup.doctype.company.company.add_node",
|
||||
filters: [
|
||||
{
|
||||
fieldname: "company",
|
||||
fieldtype:"Link",
|
||||
fieldtype: "Link",
|
||||
options: "Company",
|
||||
label: __("Company"),
|
||||
get_query: function() {
|
||||
get_query: function () {
|
||||
return {
|
||||
filters: [["Company", 'is_group', '=', 1]]
|
||||
filters: [["Company", "is_group", "=", 1]],
|
||||
};
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
breadcrumb: "Setup",
|
||||
@@ -21,13 +21,13 @@ frappe.treeview_settings["Company"] = {
|
||||
menu_items: [
|
||||
{
|
||||
label: __("New Company"),
|
||||
action: function() {
|
||||
action: function () {
|
||||
frappe.new_doc("Company", true);
|
||||
},
|
||||
condition: 'frappe.boot.user.can_create.indexOf("Company") !== -1'
|
||||
}
|
||||
condition: 'frappe.boot.user.can_create.indexOf("Company") !== -1',
|
||||
},
|
||||
],
|
||||
onload: function(treeview) {
|
||||
onload: function (treeview) {
|
||||
treeview.make_tree();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2,29 +2,30 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
extend_cscript(cur_frm.cscript, {
|
||||
onload: function() {
|
||||
if(cur_frm.doc.__islocal) {
|
||||
onload: function () {
|
||||
if (cur_frm.doc.__islocal) {
|
||||
cur_frm.set_value("to_currency", frappe.defaults.get_global_default("currency"));
|
||||
}
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
refresh: function () {
|
||||
cur_frm.cscript.set_exchange_rate_label();
|
||||
},
|
||||
|
||||
from_currency: function() {
|
||||
from_currency: function () {
|
||||
cur_frm.cscript.set_exchange_rate_label();
|
||||
},
|
||||
|
||||
to_currency: function() {
|
||||
to_currency: function () {
|
||||
cur_frm.cscript.set_exchange_rate_label();
|
||||
},
|
||||
|
||||
set_exchange_rate_label: function() {
|
||||
if(cur_frm.doc.from_currency && cur_frm.doc.to_currency) {
|
||||
set_exchange_rate_label: function () {
|
||||
if (cur_frm.doc.from_currency && cur_frm.doc.to_currency) {
|
||||
var default_label = __(frappe.meta.docfield_map[cur_frm.doctype]["exchange_rate"].label);
|
||||
cur_frm.fields_dict.exchange_rate.set_label(default_label +
|
||||
repl(" (1 %(from_currency)s = [?] %(to_currency)s)", cur_frm.doc));
|
||||
cur_frm.fields_dict.exchange_rate.set_label(
|
||||
default_label + repl(" (1 %(from_currency)s = [?] %(to_currency)s)", cur_frm.doc)
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2,44 +2,44 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.ui.form.on("Customer Group", {
|
||||
setup: function(frm){
|
||||
frm.set_query('parent_customer_group', function (doc) {
|
||||
setup: function (frm) {
|
||||
frm.set_query("parent_customer_group", function (doc) {
|
||||
return {
|
||||
filters: {
|
||||
'is_group': 1,
|
||||
'name': ['!=', cur_frm.doc.customer_group_name]
|
||||
}
|
||||
}
|
||||
is_group: 1,
|
||||
name: ["!=", cur_frm.doc.customer_group_name],
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query('account', 'accounts', function (doc, cdt, cdn) {
|
||||
frm.set_query("account", "accounts", function (doc, cdt, cdn) {
|
||||
return {
|
||||
filters: {
|
||||
'root_type': 'Asset',
|
||||
"account_type": 'Receivable',
|
||||
"company": locals[cdt][cdn].company,
|
||||
"is_group": 0
|
||||
}
|
||||
}
|
||||
root_type: "Asset",
|
||||
account_type: "Receivable",
|
||||
company: locals[cdt][cdn].company,
|
||||
is_group: 0,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query('advance_account', 'accounts', function (doc, cdt, cdn) {
|
||||
frm.set_query("advance_account", "accounts", function (doc, cdt, cdn) {
|
||||
return {
|
||||
filters: {
|
||||
"root_type": 'Liability',
|
||||
"account_type": "Receivable",
|
||||
"company": locals[cdt][cdn].company,
|
||||
"is_group": 0
|
||||
}
|
||||
}
|
||||
root_type: "Liability",
|
||||
account_type: "Receivable",
|
||||
company: locals[cdt][cdn].company,
|
||||
is_group: 0,
|
||||
},
|
||||
};
|
||||
});
|
||||
},
|
||||
refresh: function(frm) {
|
||||
refresh: function (frm) {
|
||||
frm.trigger("set_root_readonly");
|
||||
},
|
||||
set_root_readonly: function(frm) {
|
||||
set_root_readonly: function (frm) {
|
||||
// read-only for root customer group
|
||||
if(!frm.doc.parent_customer_group && !frm.doc.__islocal) {
|
||||
if (!frm.doc.parent_customer_group && !frm.doc.__islocal) {
|
||||
frm.set_read_only();
|
||||
frm.set_intro(__("This is a root customer group and cannot be edited."));
|
||||
} else {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
frappe.treeview_settings["Customer Group"] = {
|
||||
ignore_fields:["parent_customer_group"]
|
||||
}
|
||||
ignore_fields: ["parent_customer_group"],
|
||||
};
|
||||
|
||||
@@ -2,21 +2,21 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on("Department", {
|
||||
onload: function(frm) {
|
||||
frm.set_query("parent_department", function() {
|
||||
return {"filters": [["Department", "is_group", "=", 1]]};
|
||||
onload: function (frm) {
|
||||
frm.set_query("parent_department", function () {
|
||||
return { filters: [["Department", "is_group", "=", 1]] };
|
||||
});
|
||||
},
|
||||
refresh: function(frm) {
|
||||
refresh: function (frm) {
|
||||
// read-only for root department
|
||||
if(!frm.doc.parent_department && !frm.is_new()) {
|
||||
if (!frm.doc.parent_department && !frm.is_new()) {
|
||||
frm.set_read_only();
|
||||
frm.set_intro(__("This is a root department and cannot be edited."));
|
||||
}
|
||||
},
|
||||
validate: function(frm) {
|
||||
if(frm.doc.name=="All Departments") {
|
||||
validate: function (frm) {
|
||||
if (frm.doc.name == "All Departments") {
|
||||
frappe.throw(__("You cannot edit root node."));
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
frappe.treeview_settings["Department"] = {
|
||||
ignore_fields:["parent_department"],
|
||||
get_tree_nodes: 'erpnext.setup.doctype.department.department.get_children',
|
||||
add_tree_node: 'erpnext.setup.doctype.department.department.add_node',
|
||||
ignore_fields: ["parent_department"],
|
||||
get_tree_nodes: "erpnext.setup.doctype.department.department.get_children",
|
||||
add_tree_node: "erpnext.setup.doctype.department.department.add_node",
|
||||
filters: [
|
||||
{
|
||||
fieldname: "company",
|
||||
fieldtype:"Link",
|
||||
fieldtype: "Link",
|
||||
options: "Company",
|
||||
label: __("Company"),
|
||||
},
|
||||
@@ -16,13 +16,13 @@ frappe.treeview_settings["Department"] = {
|
||||
menu_items: [
|
||||
{
|
||||
label: __("New Department"),
|
||||
action: function() {
|
||||
action: function () {
|
||||
frappe.new_doc("Department", true);
|
||||
},
|
||||
condition: 'frappe.boot.user.can_create.indexOf("Department") !== -1'
|
||||
}
|
||||
condition: 'frappe.boot.user.can_create.indexOf("Department") !== -1',
|
||||
},
|
||||
],
|
||||
onload: function(treeview) {
|
||||
onload: function (treeview) {
|
||||
treeview.make_tree();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Designation', {
|
||||
refresh: function(frm) {
|
||||
|
||||
}
|
||||
frappe.ui.form.on("Designation", {
|
||||
refresh: function (frm) {},
|
||||
});
|
||||
|
||||
@@ -2,35 +2,35 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on("Driver", {
|
||||
setup: function(frm) {
|
||||
frm.set_query("transporter", function() {
|
||||
setup: function (frm) {
|
||||
frm.set_query("transporter", function () {
|
||||
return {
|
||||
filters: {
|
||||
is_transporter: 1
|
||||
}
|
||||
is_transporter: 1,
|
||||
},
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
refresh: function(frm) {
|
||||
frm.set_query("address", function() {
|
||||
refresh: function (frm) {
|
||||
frm.set_query("address", function () {
|
||||
return {
|
||||
filters: {
|
||||
is_your_company_address: !frm.doc.transporter ? 1 : 0
|
||||
}
|
||||
is_your_company_address: !frm.doc.transporter ? 1 : 0,
|
||||
},
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
transporter: function(frm, cdt, cdn) {
|
||||
transporter: function (frm, cdt, cdn) {
|
||||
// this assumes that supplier's address has same title as supplier's name
|
||||
frappe.db
|
||||
.get_doc("Address", null, { address_title: frm.doc.transporter })
|
||||
.then(r => {
|
||||
.then((r) => {
|
||||
frappe.model.set_value(cdt, cdn, "address", r.name);
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2,30 +2,30 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.ui.form.on("Email Digest", {
|
||||
refresh: function(frm) {
|
||||
refresh: function (frm) {
|
||||
if (!frm.is_new()) {
|
||||
frm.add_custom_button(__('View Now'), function() {
|
||||
frm.add_custom_button(__("View Now"), function () {
|
||||
frappe.call({
|
||||
method: 'erpnext.setup.doctype.email_digest.email_digest.get_digest_msg',
|
||||
method: "erpnext.setup.doctype.email_digest.email_digest.get_digest_msg",
|
||||
args: {
|
||||
name: frm.doc.name
|
||||
name: frm.doc.name,
|
||||
},
|
||||
callback: function(r) {
|
||||
callback: function (r) {
|
||||
let d = new frappe.ui.Dialog({
|
||||
title: __('Email Digest: {0}', [frm.doc.name]),
|
||||
width: 800
|
||||
title: __("Email Digest: {0}", [frm.doc.name]),
|
||||
width: 800,
|
||||
});
|
||||
$(d.body).html(r.message);
|
||||
d.show();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
frm.add_custom_button(__('Send Now'), function() {
|
||||
return frm.call('send', null, () => {
|
||||
frappe.show_alert({ message: __("Message Sent"), indicator: 'green'});
|
||||
frm.add_custom_button(__("Send Now"), function () {
|
||||
return frm.call("send", null, () => {
|
||||
frappe.show_alert({ message: __("Message Sent"), indicator: "green" });
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -4,14 +4,15 @@
|
||||
frappe.provide("erpnext.setup");
|
||||
erpnext.setup.EmployeeController = class EmployeeController extends frappe.ui.form.Controller {
|
||||
setup() {
|
||||
this.frm.fields_dict.user_id.get_query = function(doc, cdt, cdn) {
|
||||
this.frm.fields_dict.user_id.get_query = function (doc, cdt, cdn) {
|
||||
return {
|
||||
query: "frappe.core.doctype.user.user.user_query",
|
||||
filters: {ignore_user_type: 1}
|
||||
}
|
||||
}
|
||||
this.frm.fields_dict.reports_to.get_query = function(doc, cdt, cdn) {
|
||||
return { query: "erpnext.controllers.queries.employee_query"} }
|
||||
filters: { ignore_user_type: 1 },
|
||||
};
|
||||
};
|
||||
this.frm.fields_dict.reports_to.get_query = function (doc, cdt, cdn) {
|
||||
return { query: "erpnext.controllers.queries.employee_query" };
|
||||
};
|
||||
}
|
||||
|
||||
refresh() {
|
||||
@@ -20,58 +21,59 @@ erpnext.setup.EmployeeController = class EmployeeController extends frappe.ui.fo
|
||||
|
||||
salutation() {
|
||||
if (this.frm.doc.salutation) {
|
||||
this.frm.set_value("gender", {
|
||||
"Mr": "Male",
|
||||
"Ms": "Female"
|
||||
}[this.frm.doc.salutation]);
|
||||
this.frm.set_value(
|
||||
"gender",
|
||||
{
|
||||
Mr: "Male",
|
||||
Ms: "Female",
|
||||
}[this.frm.doc.salutation]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
frappe.ui.form.on("Employee", {
|
||||
onload: function (frm) {
|
||||
frm.set_query("department", function() {
|
||||
frm.set_query("department", function () {
|
||||
return {
|
||||
"filters": {
|
||||
"company": frm.doc.company,
|
||||
}
|
||||
filters: {
|
||||
company: frm.doc.company,
|
||||
},
|
||||
};
|
||||
});
|
||||
},
|
||||
prefered_contact_email: function(frm) {
|
||||
prefered_contact_email: function (frm) {
|
||||
frm.events.update_contact(frm);
|
||||
},
|
||||
|
||||
personal_email: function(frm) {
|
||||
personal_email: function (frm) {
|
||||
frm.events.update_contact(frm);
|
||||
},
|
||||
|
||||
company_email: function(frm) {
|
||||
company_email: function (frm) {
|
||||
frm.events.update_contact(frm);
|
||||
},
|
||||
|
||||
user_id: function(frm) {
|
||||
user_id: function (frm) {
|
||||
frm.events.update_contact(frm);
|
||||
},
|
||||
|
||||
update_contact: function(frm) {
|
||||
var prefered_email_fieldname = frappe.model.scrub(frm.doc.prefered_contact_email) || 'user_id';
|
||||
frm.set_value("prefered_email",
|
||||
frm.fields_dict[prefered_email_fieldname].value);
|
||||
update_contact: function (frm) {
|
||||
var prefered_email_fieldname = frappe.model.scrub(frm.doc.prefered_contact_email) || "user_id";
|
||||
frm.set_value("prefered_email", frm.fields_dict[prefered_email_fieldname].value);
|
||||
},
|
||||
|
||||
status: function(frm) {
|
||||
status: function (frm) {
|
||||
return frm.call({
|
||||
method: "deactivate_sales_person",
|
||||
args: {
|
||||
employee: frm.doc.employee,
|
||||
status: frm.doc.status
|
||||
}
|
||||
status: frm.doc.status,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
create_user: function(frm) {
|
||||
create_user: function (frm) {
|
||||
if (!frm.doc.prefered_email) {
|
||||
frappe.throw(__("Please enter Preferred Contact Email"));
|
||||
}
|
||||
@@ -79,46 +81,53 @@ frappe.ui.form.on("Employee", {
|
||||
method: "erpnext.setup.doctype.employee.employee.create_user",
|
||||
args: {
|
||||
employee: frm.doc.name,
|
||||
email: frm.doc.prefered_email
|
||||
email: frm.doc.prefered_email,
|
||||
},
|
||||
freeze: true,
|
||||
freeze_message: __("Creating User..."),
|
||||
callback: function (r) {
|
||||
frm.reload_doc();
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
cur_frm.cscript = new erpnext.setup.EmployeeController({
|
||||
frm: cur_frm
|
||||
frm: cur_frm,
|
||||
});
|
||||
|
||||
|
||||
frappe.tour['Employee'] = [
|
||||
frappe.tour["Employee"] = [
|
||||
{
|
||||
fieldname: "first_name",
|
||||
title: "First Name",
|
||||
description: __("Enter First and Last name of Employee, based on Which Full Name will be updated. IN transactions, it will be Full Name which will be fetched.")
|
||||
description: __(
|
||||
"Enter First and Last name of Employee, based on Which Full Name will be updated. IN transactions, it will be Full Name which will be fetched."
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldname: "company",
|
||||
title: "Company",
|
||||
description: __("Select a Company this Employee belongs to.")
|
||||
description: __("Select a Company this Employee belongs to."),
|
||||
},
|
||||
{
|
||||
fieldname: "date_of_birth",
|
||||
title: "Date of Birth",
|
||||
description: __("Select Date of Birth. This will validate Employees age and prevent hiring of under-age staff.")
|
||||
description: __(
|
||||
"Select Date of Birth. This will validate Employees age and prevent hiring of under-age staff."
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldname: "date_of_joining",
|
||||
title: "Date of Joining",
|
||||
description: __("Select Date of joining. It will have impact on the first salary calculation, Leave allocation on pro-rata bases.")
|
||||
description: __(
|
||||
"Select Date of joining. It will have impact on the first salary calculation, Leave allocation on pro-rata bases."
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldname: "reports_to",
|
||||
title: "Reports To",
|
||||
description: __("Here, you can select a senior of this Employee. Based on this, Organization Chart will be populated.")
|
||||
description: __(
|
||||
"Here, you can select a senior of this Employee. Based on this, Organization Chart will be populated."
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
frappe.listview_settings['Employee'] = {
|
||||
add_fields: ["status", "branch", "department", "designation","image"],
|
||||
filters: [["status","=", "Active"]],
|
||||
get_indicator: function(doc) {
|
||||
frappe.listview_settings["Employee"] = {
|
||||
add_fields: ["status", "branch", "department", "designation", "image"],
|
||||
filters: [["status", "=", "Active"]],
|
||||
get_indicator: function (doc) {
|
||||
var indicator = [__(doc.status), frappe.utils.guess_colour(doc.status), "status,=," + doc.status];
|
||||
indicator[1] = {"Active": "green", "Inactive": "red", "Left": "gray", "Suspended": "orange"}[doc.status];
|
||||
indicator[1] = { Active: "green", Inactive: "red", Left: "gray", Suspended: "orange" }[doc.status];
|
||||
return indicator;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
frappe.treeview_settings['Employee'] = {
|
||||
frappe.treeview_settings["Employee"] = {
|
||||
get_tree_nodes: "erpnext.setup.doctype.employee.employee.get_children",
|
||||
filters: [
|
||||
{
|
||||
fieldname: "company",
|
||||
fieldtype:"Select",
|
||||
options: ['All Companies'].concat(erpnext.utils.get_tree_options("company")),
|
||||
fieldtype: "Select",
|
||||
options: ["All Companies"].concat(erpnext.utils.get_tree_options("company")),
|
||||
label: __("Company"),
|
||||
default: erpnext.utils.get_tree_default("company")
|
||||
}
|
||||
default: erpnext.utils.get_tree_default("company"),
|
||||
},
|
||||
],
|
||||
breadcrumb: "Hr",
|
||||
disable_add_node: true,
|
||||
@@ -15,22 +15,22 @@ frappe.treeview_settings['Employee'] = {
|
||||
toolbar: [
|
||||
{ toggle_btn: true },
|
||||
{
|
||||
label:__("Edit"),
|
||||
condition: function(node) {
|
||||
label: __("Edit"),
|
||||
condition: function (node) {
|
||||
return !node.is_root;
|
||||
},
|
||||
click: function(node) {
|
||||
click: function (node) {
|
||||
frappe.set_route("Form", "Employee", node.data.value);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
menu_items: [
|
||||
{
|
||||
label: __("New Employee"),
|
||||
action: function() {
|
||||
action: function () {
|
||||
frappe.new_doc("Employee", true);
|
||||
},
|
||||
condition: 'frappe.boot.user.can_create.indexOf("Employee") !== -1'
|
||||
}
|
||||
condition: 'frappe.boot.user.can_create.indexOf("Employee") !== -1',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Employee Group', {
|
||||
|
||||
});
|
||||
frappe.ui.form.on("Employee Group", {});
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.ui.form.on('Global Defaults', {
|
||||
onload: function(frm) {
|
||||
frm.trigger('get_distance_uoms');
|
||||
frappe.ui.form.on("Global Defaults", {
|
||||
onload: function (frm) {
|
||||
frm.trigger("get_distance_uoms");
|
||||
},
|
||||
validate: function(frm) {
|
||||
frm.call('get_defaults', null, r => {
|
||||
validate: function (frm) {
|
||||
frm.call("get_defaults", null, (r) => {
|
||||
frappe.sys_defaults = r.message;
|
||||
})
|
||||
});
|
||||
},
|
||||
get_distance_uoms: function (frm) {
|
||||
let units = [];
|
||||
@@ -17,16 +17,16 @@ frappe.ui.form.on('Global Defaults', {
|
||||
method: "frappe.client.get_list",
|
||||
args: {
|
||||
doctype: "UOM Conversion Factor",
|
||||
filters: { "category": __("Length") },
|
||||
filters: { category: __("Length") },
|
||||
fields: ["to_uom"],
|
||||
limit_page_length: 500
|
||||
limit_page_length: 500,
|
||||
},
|
||||
callback: function (r) {
|
||||
r.message.forEach(row => units.push(row.to_uom));
|
||||
}
|
||||
r.message.forEach((row) => units.push(row.to_uom));
|
||||
},
|
||||
});
|
||||
frm.set_query("default_distance_unit", function () {
|
||||
return { filters: { "name": ["IN", units] } };
|
||||
return { filters: { name: ["IN", units] } };
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on("Holiday List", {
|
||||
refresh: function(frm) {
|
||||
refresh: function (frm) {
|
||||
if (frm.doc.holidays) {
|
||||
frm.set_value("total_holidays", frm.doc.holidays.length);
|
||||
}
|
||||
|
||||
frm.call("get_supported_countries").then(r => {
|
||||
frm.call("get_supported_countries").then((r) => {
|
||||
frm.subdivisions_by_country = r.message.subdivisions_by_country;
|
||||
frm.fields_dict.country.set_data(
|
||||
r.message.countries.sort((a, b) => a.label.localeCompare(b.label))
|
||||
@@ -18,20 +18,20 @@ frappe.ui.form.on("Holiday List", {
|
||||
}
|
||||
});
|
||||
},
|
||||
from_date: function(frm) {
|
||||
from_date: function (frm) {
|
||||
if (frm.doc.from_date && !frm.doc.to_date) {
|
||||
var a_year_from_start = frappe.datetime.add_months(frm.doc.from_date, 12);
|
||||
frm.set_value("to_date", frappe.datetime.add_days(a_year_from_start, -1));
|
||||
}
|
||||
},
|
||||
country: function(frm) {
|
||||
country: function (frm) {
|
||||
frm.set_value("subdivision", "");
|
||||
|
||||
if (frm.doc.country) {
|
||||
frm.trigger("set_subdivisions");
|
||||
}
|
||||
},
|
||||
set_subdivisions: function(frm) {
|
||||
set_subdivisions: function (frm) {
|
||||
const subdivisions = [...frm.subdivisions_by_country[frm.doc.country]];
|
||||
if (subdivisions && subdivisions.length > 0) {
|
||||
frm.fields_dict.subdivision.set_data(subdivisions);
|
||||
@@ -67,11 +67,15 @@ frappe.tour["Holiday List"] = [
|
||||
{
|
||||
fieldname: "get_weekly_off_dates",
|
||||
title: "Add Holidays",
|
||||
description: __("Click on Add to Holidays. This will populate the holidays table with all the dates that fall on the selected weekly off. Repeat the process for populating the dates for all your weekly holidays"),
|
||||
description: __(
|
||||
"Click on Add to Holidays. This will populate the holidays table with all the dates that fall on the selected weekly off. Repeat the process for populating the dates for all your weekly holidays"
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldname: "holidays",
|
||||
title: "Holidays",
|
||||
description: __("Here, your weekly offs are pre-populated based on the previous selections. You can add more rows to also add public and national holidays individually.")
|
||||
description: __(
|
||||
"Here, your weekly offs are pre-populated based on the previous selections. You can add more rows to also add public and national holidays individually."
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
|
||||
frappe.views.calendar["Holiday List"] = {
|
||||
field_map: {
|
||||
"start": "holiday_date",
|
||||
"end": "holiday_date",
|
||||
"id": "name",
|
||||
"title": "description",
|
||||
"allDay": "allDay"
|
||||
start: "holiday_date",
|
||||
end: "holiday_date",
|
||||
id: "name",
|
||||
title: "description",
|
||||
allDay: "allDay",
|
||||
},
|
||||
order_by: `from_date`,
|
||||
get_events_method: "erpnext.setup.doctype.holiday_list.holiday_list.get_events",
|
||||
filters: [
|
||||
{
|
||||
'fieldtype': 'Link',
|
||||
'fieldname': 'holiday_list',
|
||||
'options': 'Holiday List',
|
||||
'label': __('Holiday List')
|
||||
}
|
||||
]
|
||||
}
|
||||
fieldtype: "Link",
|
||||
fieldname: "holiday_list",
|
||||
options: "Holiday List",
|
||||
label: __("Holiday List"),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -2,85 +2,102 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.ui.form.on("Item Group", {
|
||||
onload: function(frm) {
|
||||
onload: function (frm) {
|
||||
frm.list_route = "Tree/Item Group";
|
||||
|
||||
//get query select item group
|
||||
frm.fields_dict['parent_item_group'].get_query = function(doc,cdt,cdn) {
|
||||
return{
|
||||
filters:[
|
||||
['Item Group', 'is_group', '=', 1],
|
||||
['Item Group', 'name', '!=', doc.item_group_name]
|
||||
]
|
||||
}
|
||||
}
|
||||
frm.fields_dict['item_group_defaults'].grid.get_field("default_discount_account").get_query = function(doc, cdt, cdn) {
|
||||
const row = locals[cdt][cdn];
|
||||
frm.fields_dict["parent_item_group"].get_query = function (doc, cdt, cdn) {
|
||||
return {
|
||||
filters: {
|
||||
'report_type': 'Profit and Loss',
|
||||
'company': row.company,
|
||||
"is_group": 0
|
||||
}
|
||||
filters: [
|
||||
["Item Group", "is_group", "=", 1],
|
||||
["Item Group", "name", "!=", doc.item_group_name],
|
||||
],
|
||||
};
|
||||
}
|
||||
frm.fields_dict["item_group_defaults"].grid.get_field("expense_account").get_query = function(doc, cdt, cdn) {
|
||||
};
|
||||
frm.fields_dict["item_group_defaults"].grid.get_field("default_discount_account").get_query =
|
||||
function (doc, cdt, cdn) {
|
||||
const row = locals[cdt][cdn];
|
||||
return {
|
||||
filters: {
|
||||
report_type: "Profit and Loss",
|
||||
company: row.company,
|
||||
is_group: 0,
|
||||
},
|
||||
};
|
||||
};
|
||||
frm.fields_dict["item_group_defaults"].grid.get_field("expense_account").get_query = function (
|
||||
doc,
|
||||
cdt,
|
||||
cdn
|
||||
) {
|
||||
const row = locals[cdt][cdn];
|
||||
return {
|
||||
query: "erpnext.controllers.queries.get_expense_account",
|
||||
filters: { company: row.company }
|
||||
}
|
||||
}
|
||||
frm.fields_dict["item_group_defaults"].grid.get_field("income_account").get_query = function(doc, cdt, cdn) {
|
||||
filters: { company: row.company },
|
||||
};
|
||||
};
|
||||
frm.fields_dict["item_group_defaults"].grid.get_field("income_account").get_query = function (
|
||||
doc,
|
||||
cdt,
|
||||
cdn
|
||||
) {
|
||||
const row = locals[cdt][cdn];
|
||||
return {
|
||||
query: "erpnext.controllers.queries.get_income_account",
|
||||
filters: { company: row.company }
|
||||
}
|
||||
}
|
||||
filters: { company: row.company },
|
||||
};
|
||||
};
|
||||
|
||||
frm.fields_dict["item_group_defaults"].grid.get_field("buying_cost_center").get_query = function(doc, cdt, cdn) {
|
||||
frm.fields_dict["item_group_defaults"].grid.get_field("buying_cost_center").get_query = function (
|
||||
doc,
|
||||
cdt,
|
||||
cdn
|
||||
) {
|
||||
const row = locals[cdt][cdn];
|
||||
return {
|
||||
filters: {
|
||||
"is_group": 0,
|
||||
"company": row.company
|
||||
}
|
||||
}
|
||||
}
|
||||
is_group: 0,
|
||||
company: row.company,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
frm.fields_dict["item_group_defaults"].grid.get_field("selling_cost_center").get_query = function(doc, cdt, cdn) {
|
||||
frm.fields_dict["item_group_defaults"].grid.get_field("selling_cost_center").get_query = function (
|
||||
doc,
|
||||
cdt,
|
||||
cdn
|
||||
) {
|
||||
const row = locals[cdt][cdn];
|
||||
return {
|
||||
filters: {
|
||||
"is_group": 0,
|
||||
"company": row.company
|
||||
}
|
||||
}
|
||||
}
|
||||
is_group: 0,
|
||||
company: row.company,
|
||||
},
|
||||
};
|
||||
};
|
||||
},
|
||||
|
||||
refresh: function(frm) {
|
||||
refresh: function (frm) {
|
||||
frm.trigger("set_root_readonly");
|
||||
frm.add_custom_button(__("Item Group Tree"), function() {
|
||||
frm.add_custom_button(__("Item Group Tree"), function () {
|
||||
frappe.set_route("Tree", "Item Group");
|
||||
});
|
||||
|
||||
if(!frm.is_new()) {
|
||||
frm.add_custom_button(__("Items"), function() {
|
||||
frappe.set_route("List", "Item", {"item_group": frm.doc.name});
|
||||
if (!frm.is_new()) {
|
||||
frm.add_custom_button(__("Items"), function () {
|
||||
frappe.set_route("List", "Item", { item_group: frm.doc.name });
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
set_root_readonly: function(frm) {
|
||||
set_root_readonly: function (frm) {
|
||||
// read-only for root item group
|
||||
frm.set_intro("");
|
||||
if(!frm.doc.parent_item_group && !frm.doc.__islocal) {
|
||||
if (!frm.doc.parent_item_group && !frm.doc.__islocal) {
|
||||
frm.set_read_only();
|
||||
frm.set_intro(__("This is a root item group and cannot be edited."), true);
|
||||
}
|
||||
},
|
||||
|
||||
page_name: frappe.utils.warn_page_name_change
|
||||
page_name: frappe.utils.warn_page_name_change,
|
||||
});
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
frappe.treeview_settings["Item Group"] = {
|
||||
ignore_fields:["parent_item_group"]
|
||||
}
|
||||
ignore_fields: ["parent_item_group"],
|
||||
};
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// Copyright (c) 2016, Frappe Technologies and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Party Type', {
|
||||
setup: function(frm) {
|
||||
frm.fields_dict["party_type"].get_query = function(frm) {
|
||||
frappe.ui.form.on("Party Type", {
|
||||
setup: function (frm) {
|
||||
frm.fields_dict["party_type"].get_query = function (frm) {
|
||||
return {
|
||||
filters: {
|
||||
"istable": 0,
|
||||
"is_submittable": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
istable: 0,
|
||||
is_submittable: 0,
|
||||
},
|
||||
};
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
|
||||
//--------- ONLOAD -------------
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.onload = function (doc, cdt, cdn) {};
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
cur_frm.cscript.refresh = function (doc, cdt, cdn) {};
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
|
||||
//--------- ONLOAD -------------
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.onload = function (doc, cdt, cdn) {};
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
cur_frm.cscript.refresh = function (doc, cdt, cdn) {};
|
||||
|
||||
@@ -1,32 +1,31 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.ui.form.on('Sales Partner', {
|
||||
refresh: function(frm) {
|
||||
if(frm.doc.__islocal){
|
||||
hide_field(['address_html', 'contact_html', 'address_contacts']);
|
||||
frappe.ui.form.on("Sales Partner", {
|
||||
refresh: function (frm) {
|
||||
if (frm.doc.__islocal) {
|
||||
hide_field(["address_html", "contact_html", "address_contacts"]);
|
||||
frappe.contacts.clear_address_and_contact(frm);
|
||||
}
|
||||
else{
|
||||
unhide_field(['address_html', 'contact_html', 'address_contacts']);
|
||||
} else {
|
||||
unhide_field(["address_html", "contact_html", "address_contacts"]);
|
||||
frappe.contacts.render_address_and_contact(frm);
|
||||
}
|
||||
},
|
||||
|
||||
setup: function(frm) {
|
||||
frm.fields_dict["targets"].grid.get_field("distribution_id").get_query = function(doc, cdt, cdn){
|
||||
setup: function (frm) {
|
||||
frm.fields_dict["targets"].grid.get_field("distribution_id").get_query = function (doc, cdt, cdn) {
|
||||
var row = locals[cdt][cdn];
|
||||
return {
|
||||
filters: {
|
||||
'fiscal_year': row.fiscal_year
|
||||
}
|
||||
}
|
||||
fiscal_year: row.fiscal_year,
|
||||
},
|
||||
};
|
||||
};
|
||||
},
|
||||
referral_code:function(frm){
|
||||
referral_code: function (frm) {
|
||||
if (frm.doc.referral_code) {
|
||||
frm.doc.referral_code=frm.doc.referral_code.toUpperCase();
|
||||
frm.refresh_field('referral_code');
|
||||
frm.doc.referral_code = frm.doc.referral_code.toUpperCase();
|
||||
frm.refresh_field("referral_code");
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,56 +1,65 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.ui.form.on('Sales Person', {
|
||||
refresh: function(frm) {
|
||||
if(frm.doc.__onload && frm.doc.__onload.dashboard_info) {
|
||||
frappe.ui.form.on("Sales Person", {
|
||||
refresh: function (frm) {
|
||||
if (frm.doc.__onload && frm.doc.__onload.dashboard_info) {
|
||||
let info = frm.doc.__onload.dashboard_info;
|
||||
frm.dashboard.add_indicator(__('Total Contribution Amount Against Orders: {0}',
|
||||
[format_currency(info.allocated_amount_against_order, info.currency)]), 'blue');
|
||||
frm.dashboard.add_indicator(
|
||||
__("Total Contribution Amount Against Orders: {0}", [
|
||||
format_currency(info.allocated_amount_against_order, info.currency),
|
||||
]),
|
||||
"blue"
|
||||
);
|
||||
|
||||
frm.dashboard.add_indicator(__('Total Contribution Amount Against Invoices: {0}',
|
||||
[format_currency(info.allocated_amount_against_invoice, info.currency)]), 'blue');
|
||||
frm.dashboard.add_indicator(
|
||||
__("Total Contribution Amount Against Invoices: {0}", [
|
||||
format_currency(info.allocated_amount_against_invoice, info.currency),
|
||||
]),
|
||||
"blue"
|
||||
);
|
||||
}
|
||||
frm.trigger("set_root_readonly");
|
||||
},
|
||||
|
||||
setup: function(frm) {
|
||||
frm.fields_dict["targets"].grid.get_field("distribution_id").get_query = function(doc, cdt, cdn){
|
||||
setup: function (frm) {
|
||||
frm.fields_dict["targets"].grid.get_field("distribution_id").get_query = function (doc, cdt, cdn) {
|
||||
var row = locals[cdt][cdn];
|
||||
return {
|
||||
filters: {
|
||||
'fiscal_year': row.fiscal_year
|
||||
}
|
||||
}
|
||||
fiscal_year: row.fiscal_year,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
frm.make_methods = {
|
||||
'Sales Order': () => frappe.new_doc("Sales Order")
|
||||
.then(() => frm.add_child("sales_team", {"sales_person": frm.doc.name}))
|
||||
}
|
||||
"Sales Order": () =>
|
||||
frappe
|
||||
.new_doc("Sales Order")
|
||||
.then(() => frm.add_child("sales_team", { sales_person: frm.doc.name })),
|
||||
};
|
||||
},
|
||||
set_root_readonly: function(frm) {
|
||||
set_root_readonly: function (frm) {
|
||||
// read-only for root
|
||||
if(!frm.doc.parent_sales_person && !frm.doc.__islocal) {
|
||||
if (!frm.doc.parent_sales_person && !frm.doc.__islocal) {
|
||||
frm.set_read_only();
|
||||
frm.set_intro(__("This is a root sales person and cannot be edited."));
|
||||
} else {
|
||||
frm.set_intro(null);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
//get query select sales person
|
||||
cur_frm.fields_dict['parent_sales_person'].get_query = function(doc, cdt, cdn) {
|
||||
return{
|
||||
cur_frm.fields_dict["parent_sales_person"].get_query = function (doc, cdt, cdn) {
|
||||
return {
|
||||
filters: [
|
||||
['Sales Person', 'is_group', '=', 1],
|
||||
['Sales Person', 'name', '!=', doc.sales_person_name]
|
||||
]
|
||||
}
|
||||
}
|
||||
["Sales Person", "is_group", "=", 1],
|
||||
["Sales Person", "name", "!=", doc.sales_person_name],
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
cur_frm.fields_dict.employee.get_query = function(doc, cdt, cdn) {
|
||||
return { query: "erpnext.controllers.queries.employee_query" }
|
||||
}
|
||||
cur_frm.fields_dict.employee.get_query = function (doc, cdt, cdn) {
|
||||
return { query: "erpnext.controllers.queries.employee_query" };
|
||||
};
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
|
||||
frappe.treeview_settings["Sales Person"] = {
|
||||
fields: [
|
||||
{fieldtype:'Data', fieldname: 'sales_person_name',
|
||||
label:__('New Sales Person Name'), reqd:true},
|
||||
{fieldtype:'Link', fieldname:'employee',
|
||||
label:__('Employee'), options:'Employee',
|
||||
description: __("Please enter Employee Id of this sales person")},
|
||||
{fieldtype:'Check', fieldname:'is_group', label:__('Group Node'),
|
||||
description: __("Further nodes can be only created under 'Group' type nodes")}
|
||||
{ fieldtype: "Data", fieldname: "sales_person_name", label: __("New Sales Person Name"), reqd: true },
|
||||
{
|
||||
fieldtype: "Link",
|
||||
fieldname: "employee",
|
||||
label: __("Employee"),
|
||||
options: "Employee",
|
||||
description: __("Please enter Employee Id of this sales person"),
|
||||
},
|
||||
{
|
||||
fieldtype: "Check",
|
||||
fieldname: "is_group",
|
||||
label: __("Group Node"),
|
||||
description: __("Further nodes can be only created under 'Group' type nodes"),
|
||||
},
|
||||
],
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,48 +2,48 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on("Supplier Group", {
|
||||
setup: function(frm){
|
||||
frm.set_query('parent_supplier_group', function (doc) {
|
||||
setup: function (frm) {
|
||||
frm.set_query("parent_supplier_group", function (doc) {
|
||||
return {
|
||||
filters: {
|
||||
'is_group': 1,
|
||||
'name': ['!=', cur_frm.doc.supplier_group_name]
|
||||
}
|
||||
}
|
||||
is_group: 1,
|
||||
name: ["!=", cur_frm.doc.supplier_group_name],
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query('account', 'accounts', function (doc, cdt, cdn) {
|
||||
frm.set_query("account", "accounts", function (doc, cdt, cdn) {
|
||||
return {
|
||||
filters: {
|
||||
'root_type': 'Liability',
|
||||
'account_type': 'Payable',
|
||||
'company': locals[cdt][cdn].company,
|
||||
"is_group": 0
|
||||
}
|
||||
}
|
||||
root_type: "Liability",
|
||||
account_type: "Payable",
|
||||
company: locals[cdt][cdn].company,
|
||||
is_group: 0,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query('advance_account', 'accounts', function (doc, cdt, cdn) {
|
||||
frm.set_query("advance_account", "accounts", function (doc, cdt, cdn) {
|
||||
return {
|
||||
filters: {
|
||||
"root_type": 'Asset',
|
||||
"account_type": "Payable",
|
||||
"company": locals[cdt][cdn].company,
|
||||
"is_group": 0
|
||||
}
|
||||
}
|
||||
root_type: "Asset",
|
||||
account_type: "Payable",
|
||||
company: locals[cdt][cdn].company,
|
||||
is_group: 0,
|
||||
},
|
||||
};
|
||||
});
|
||||
},
|
||||
refresh: function(frm) {
|
||||
refresh: function (frm) {
|
||||
frm.set_intro(frm.doc.__islocal ? "" : __("There is nothing to edit."));
|
||||
frm.trigger("set_root_readonly");
|
||||
},
|
||||
set_root_readonly: function(frm) {
|
||||
if(!frm.doc.parent_supplier_group && !frm.doc.__islocal) {
|
||||
set_root_readonly: function (frm) {
|
||||
if (!frm.doc.parent_supplier_group && !frm.doc.__islocal) {
|
||||
frm.trigger("set_read_only");
|
||||
frm.set_intro(__("This is a root supplier group and cannot be edited."));
|
||||
} else {
|
||||
frm.set_intro(null);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
frappe.treeview_settings["Supplier Group"] = {
|
||||
breadcrumbs: "Buying",
|
||||
ignore_fields:["parent_supplier_group"]
|
||||
ignore_fields: ["parent_supplier_group"],
|
||||
};
|
||||
|
||||
@@ -2,37 +2,36 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.ui.form.on("Territory", {
|
||||
setup: function(frm) {
|
||||
frm.fields_dict["targets"].grid.get_field("distribution_id").get_query = function(doc, cdt, cdn){
|
||||
setup: function (frm) {
|
||||
frm.fields_dict["targets"].grid.get_field("distribution_id").get_query = function (doc, cdt, cdn) {
|
||||
var row = locals[cdt][cdn];
|
||||
return {
|
||||
filters: {
|
||||
'fiscal_year': row.fiscal_year
|
||||
}
|
||||
}
|
||||
fiscal_year: row.fiscal_year,
|
||||
},
|
||||
};
|
||||
};
|
||||
},
|
||||
refresh: function(frm) {
|
||||
refresh: function (frm) {
|
||||
frm.trigger("set_root_readonly");
|
||||
},
|
||||
set_root_readonly: function(frm) {
|
||||
set_root_readonly: function (frm) {
|
||||
// read-only for root territory
|
||||
if(!frm.doc.parent_territory && !frm.doc.__islocal) {
|
||||
if (!frm.doc.parent_territory && !frm.doc.__islocal) {
|
||||
frm.set_read_only();
|
||||
frm.set_intro(__("This is a root territory and cannot be edited."));
|
||||
} else {
|
||||
frm.set_intro(null);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
//get query select territory
|
||||
cur_frm.fields_dict['parent_territory'].get_query = function(doc,cdt,cdn) {
|
||||
return{
|
||||
filters:[
|
||||
['Territory', 'is_group', '=', 1],
|
||||
['Territory', 'name', '!=', doc.territory_name]
|
||||
]
|
||||
}
|
||||
}
|
||||
cur_frm.fields_dict["parent_territory"].get_query = function (doc, cdt, cdn) {
|
||||
return {
|
||||
filters: [
|
||||
["Territory", "is_group", "=", 1],
|
||||
["Territory", "name", "!=", doc.territory_name],
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
frappe.treeview_settings["Territory"] = {
|
||||
ignore_fields:["parent_territory"]
|
||||
}
|
||||
ignore_fields: ["parent_territory"],
|
||||
};
|
||||
|
||||
@@ -1,39 +1,38 @@
|
||||
// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Transaction Deletion Record', {
|
||||
onload: function(frm) {
|
||||
frappe.ui.form.on("Transaction Deletion Record", {
|
||||
onload: function (frm) {
|
||||
if (frm.doc.docstatus == 0) {
|
||||
let doctypes_to_be_ignored_array;
|
||||
frappe.call({
|
||||
method: 'erpnext.setup.doctype.transaction_deletion_record.transaction_deletion_record.get_doctypes_to_be_ignored',
|
||||
callback: function(r) {
|
||||
method: "erpnext.setup.doctype.transaction_deletion_record.transaction_deletion_record.get_doctypes_to_be_ignored",
|
||||
callback: function (r) {
|
||||
doctypes_to_be_ignored_array = r.message;
|
||||
populate_doctypes_to_be_ignored(doctypes_to_be_ignored_array, frm);
|
||||
frm.fields_dict['doctypes_to_be_ignored'].grid.set_column_disp('no_of_docs', false);
|
||||
frm.refresh_field('doctypes_to_be_ignored');
|
||||
}
|
||||
frm.fields_dict["doctypes_to_be_ignored"].grid.set_column_disp("no_of_docs", false);
|
||||
frm.refresh_field("doctypes_to_be_ignored");
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
frm.get_field('doctypes_to_be_ignored').grid.cannot_add_rows = true;
|
||||
frm.fields_dict['doctypes_to_be_ignored'].grid.set_column_disp('no_of_docs', false);
|
||||
frm.refresh_field('doctypes_to_be_ignored');
|
||||
frm.get_field("doctypes_to_be_ignored").grid.cannot_add_rows = true;
|
||||
frm.fields_dict["doctypes_to_be_ignored"].grid.set_column_disp("no_of_docs", false);
|
||||
frm.refresh_field("doctypes_to_be_ignored");
|
||||
},
|
||||
|
||||
refresh: function(frm) {
|
||||
frm.fields_dict['doctypes_to_be_ignored'].grid.set_column_disp('no_of_docs', false);
|
||||
frm.refresh_field('doctypes_to_be_ignored');
|
||||
}
|
||||
|
||||
refresh: function (frm) {
|
||||
frm.fields_dict["doctypes_to_be_ignored"].grid.set_column_disp("no_of_docs", false);
|
||||
frm.refresh_field("doctypes_to_be_ignored");
|
||||
},
|
||||
});
|
||||
|
||||
function populate_doctypes_to_be_ignored(doctypes_to_be_ignored_array, frm) {
|
||||
if (frm.doc.doctypes_to_be_ignored.length === 0) {
|
||||
var i;
|
||||
for (i = 0; i < doctypes_to_be_ignored_array.length; i++) {
|
||||
frm.add_child('doctypes_to_be_ignored', {
|
||||
doctype_name: doctypes_to_be_ignored_array[i]
|
||||
frm.add_child("doctypes_to_be_ignored", {
|
||||
doctype_name: doctypes_to_be_ignored_array[i],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.listview_settings['Transaction Deletion Record'] = {
|
||||
get_indicator: function(doc) {
|
||||
frappe.listview_settings["Transaction Deletion Record"] = {
|
||||
get_indicator: function (doc) {
|
||||
if (doc.docstatus == 0) {
|
||||
return [__("Draft"), "red"];
|
||||
} else {
|
||||
return [__("Completed"), "green"];
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
|
||||
//--------- ONLOAD -------------
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.onload = function (doc, cdt, cdn) {};
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
cur_frm.cscript.refresh = function (doc, cdt, cdn) {};
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('UOM Conversion Factor', {
|
||||
refresh: function() {
|
||||
|
||||
}
|
||||
frappe.ui.form.on("UOM Conversion Factor", {
|
||||
refresh: function () {},
|
||||
});
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Vehicle', {
|
||||
refresh: function(frm) {
|
||||
|
||||
}
|
||||
frappe.ui.form.on("Vehicle", {
|
||||
refresh: function (frm) {},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user