Resolve merge conflicts from enterprise_sprint branch

This commit is contained in:
Saurabh
2018-05-14 21:15:46 +05:30
463 changed files with 35469 additions and 5844 deletions

View File

@@ -18,6 +18,16 @@ frappe.ui.form.on("Company", {
}
},
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 = ""
}
},
refresh: function(frm) {
if(frm.doc.abbr && !frm.doc.__islocal) {
frm.set_df_property("abbr", "read_only", 1);
@@ -187,6 +197,7 @@ erpnext.company.setup_queries = function(frm) {
["round_off_account", {"root_type": "Expense"}],
["write_off_account", {"root_type": "Expense"}],
["exchange_gain_loss_account", {"root_type": "Expense"}],
["unrealized_exchange_gain_loss_account", {"root_type": "Expense"}],
["accumulated_depreciation_account",
{"root_type": "Asset", "account_type": "Accumulated Depreciation"}],
["depreciation_expense_account", {"root_type": "Expense", "account_type": "Depreciation"}],
@@ -196,6 +207,9 @@ erpnext.company.setup_queries = function(frm) {
["round_off_cost_center", {}],
["depreciation_cost_center", {}],
["default_employee_advance_account", {"root_type": "Asset"}],
["expenses_included_in_asset_valuation", {"account_type": "Expenses Included In Asset Valuation"}],
["capital_work_in_progress_account", {"account_type": "Capital Work in Progress"}],
["asset_received_but_not_billed", {"account_type": "Asset Received But Not Billed"}]
], function(i, v) {
erpnext.company.set_custom_query(frm, v);
});

File diff suppressed because it is too large Load Diff

View File

@@ -11,8 +11,11 @@ from frappe.cache_manager import clear_defaults_cache
from frappe.model.document import Document
from frappe.contacts.address_and_contact import load_address_and_contact
from frappe.utils.nestedset import NestedSet
class Company(NestedSet):
nsm_parent_field = 'parent_company'
class Company(Document):
def onload(self):
load_address_and_contact(self, "company")
self.get("__onload")["transactions_exist"] = self.check_if_transactions_exist()
@@ -42,8 +45,8 @@ class Company(Document):
self.abbr = self.abbr.strip()
if self.get('__islocal') and len(self.abbr) > 5:
frappe.throw(_("Abbreviation cannot have more than 5 characters"))
# if self.get('__islocal') and len(self.abbr) > 5:
# frappe.throw(_("Abbreviation cannot have more than 5 characters"))
if not self.abbr.strip():
frappe.throw(_("Abbreviation is mandatory"))
@@ -78,6 +81,7 @@ class Company(Document):
frappe.throw(_("Cannot change company's default currency, because there are existing transactions. Transactions must be cancelled to change the default currency."))
def on_update(self):
self.update_nsm_model()
if not frappe.db.sql("""select name from tabAccount
where company=%s and docstatus<2 limit 1""", self.name):
if not frappe.local.flags.ignore_chart_of_accounts:
@@ -165,6 +169,9 @@ class Company(Document):
self._set_default_account("round_off_account", "Round Off")
self._set_default_account("accumulated_depreciation_account", "Accumulated Depreciation")
self._set_default_account("depreciation_expense_account", "Depreciation")
self._set_default_account("capital_work_in_progress_account", "Capital Work in Progress")
self._set_default_account("asset_received_but_not_billed", "Asset Received But Not Billed")
self._set_default_account("expenses_included_in_asset_valuation", "Expenses Included In Asset Valuation")
if self.enable_perpetual_inventory:
self._set_default_account("stock_received_but_not_billed", "Stock Received But Not Billed")
@@ -276,10 +283,14 @@ class Company(Document):
def abbreviate(self):
self.abbr = ''.join([c[0].upper() for c in self.company_name.split()])
def update_nsm_model(self):
frappe.utils.nestedset.update_nsm(self)
def on_trash(self):
"""
Trash accounts and cost centers for this company if no gl entry exists
"""
self.update_nsm_model()
accounts = frappe.db.sql_list("select name from tabAccount where company=%s", self.name)
cost_centers = frappe.db.sql_list("select name from `tabCost Center` where company=%s", self.name)
warehouses = frappe.db.sql_list("select name from tabWarehouse where company=%s", self.name)
@@ -418,3 +429,32 @@ def cache_companies_monthly_sales_history():
for company in companies:
update_company_monthly_sales(company)
frappe.db.commit()
@frappe.whitelist()
def get_children(doctype, parent=None, company=None, is_root=False):
if parent == None or parent == "All Companies":
parent = ""
return frappe.db.sql("""
select
name as value,
is_group as expandable
from
`tab{doctype}` comp
where
ifnull(parent_company, "")="{parent}"
""".format(
doctype = frappe.db.escape(doctype),
parent=frappe.db.escape(parent)
), as_dict=1)
@frappe.whitelist()
def add_node():
from frappe.desk.treeview import make_tree_args
args = frappe.form_dict
args = make_tree_args(**args)
if args.parent_company == 'All Companies':
args.parent_company = None
frappe.get_doc(args).insert()

View File

@@ -0,0 +1,33 @@
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',
filters: [
{
fieldname: "company",
fieldtype:"Link",
options: "Company",
label: __("Company"),
get_query: function() {
return {
filters: [["Company", 'is_group', '=', 1]]
};
}
},
],
breadcrumb: "Setup",
root_label: "All Companies",
get_tree_root: false,
menu_items: [
{
label: __("New Company"),
action: function() {
frappe.new_doc("Company", true);
},
condition: 'frappe.boot.user.can_create.indexOf("Company") !== -1'
}
],
onload: function(treeview) {
treeview.make_tree();
}
};

View File

@@ -0,0 +1,37 @@
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
cur_frm.cscript.refresh = function(doc) {
cur_frm.set_intro(doc.__islocal ? "" : __("There is nothing to edit."));
cur_frm.cscript.set_root_readonly(doc);
};
cur_frm.cscript.set_root_readonly = function(doc) {
// read-only for root customer group
if(!doc.parent_supplier_group) {
cur_frm.set_read_only();
cur_frm.set_intro(__("This is a root supplier group and cannot be edited."));
} else {
cur_frm.set_intro(null);
}
};
// get query select Customer Group
cur_frm.fields_dict['parent_supplier_group'].get_query = function() {
return {
filters: {
'is_group': 1
}
};
};
cur_frm.fields_dict['accounts'].grid.get_field('account').get_query = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
return {
filters: {
'account_type': 'Payable',
'company': d.company,
"is_group": 0
}
};
};

View File

@@ -3,7 +3,7 @@
"allow_guest_to_view": 0,
"allow_import": 1,
"allow_rename": 1,
"autoname": "field:supplier_type",
"autoname": "field:supplier_group_name",
"beta": 0,
"creation": "2013-01-10 16:34:24",
"custom": 0,
@@ -18,16 +18,16 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "supplier_type",
"fieldname": "supplier_group_name",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Supplier Type",
"label": "Supplier Group Name",
"length": 0,
"no_copy": 0,
"oldfieldname": "supplier_type",
@@ -41,8 +41,72 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
"columns": 0,
"fieldname": "parent_supplier_group",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Parent Supplier Group",
"length": 0,
"no_copy": 0,
"options": "Supplier Group",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
"columns": 0,
"fieldname": "is_group",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Is Group",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
@@ -71,6 +135,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@@ -102,6 +167,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@@ -131,6 +197,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@@ -163,6 +230,101 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "lft",
"fieldtype": "Int",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "lft",
"length": 0,
"no_copy": 1,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 1,
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "rgt",
"fieldtype": "Int",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "rgt",
"length": 0,
"no_copy": 1,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 1,
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "old_parent",
"fieldtype": "Link",
"hidden": 1,
"ignore_user_permissions": 1,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Old Parent",
"length": 0,
"no_copy": 1,
"options": "Supplier Group",
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 1,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
@@ -177,15 +339,14 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-09-04 18:54:10.093500",
"modified": "2018-04-20 00:54:48.724120",
"modified_by": "Administrator",
"module": "Setup",
"name": "Supplier Type",
"name": "Supplier Group",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 0,
"delete": 0,
@@ -205,7 +366,6 @@
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 0,
"delete": 0,
@@ -225,7 +385,6 @@
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
@@ -245,7 +404,6 @@
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 0,
"delete": 0,
@@ -265,7 +423,6 @@
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 0,
"delete": 0,
@@ -285,7 +442,6 @@
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 0,
"delete": 0,

View File

@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.utils.nestedset import NestedSet
class SupplierGroup(NestedSet):
nsm_parent_field = 'parent_supplier_group';
def update_nsm_model(self):
frappe.utils.nestedset.update_nsm(self)
def on_update(self):
self.update_nsm_model()
self.validate_one_root()
def on_trash(self):
self.update_nsm_model()

View File

@@ -0,0 +1,3 @@
frappe.treeview_settings["Supplier Group"] = {
ignore_fields:["parent_supplier_group"]
};

View File

@@ -0,0 +1,7 @@
[
{
"doctype": "Supplier Group",
"supplier_group_name": "_Test Supplier Group"
}
]

View File

@@ -2,15 +2,15 @@
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Supplier Type", function (assert) {
QUnit.test("test: Supplier Group", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(1);
frappe.run_serially([
// insert a new Supplier Type
() => frappe.tests.make('Supplier Type', [
// insert a new Supplier Group
() => frappe.tests.make('Supplier Group', [
// values to be set
{key: 'value'}
]),

View File

@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
import frappe
test_records = frappe.get_test_records('Supplier Group')

View File

@@ -1 +0,0 @@
Supplier classification.

View File

@@ -1,17 +0,0 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
cur_frm.cscript.refresh = function(doc) {
cur_frm.set_intro(doc.__islocal ? "" : __("There is nothing to edit."))
}
cur_frm.fields_dict['accounts'].grid.get_field('account').get_query = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
return {
filters: {
'account_type': 'Payable',
'company': d.company,
"is_group": 0
}
}
}

View File

@@ -1,10 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class SupplierType(Document):
pass

View File

@@ -1,6 +0,0 @@
[
{
"doctype": "Supplier Type",
"supplier_type": "_Test Supplier Type"
}
]

View File

@@ -1,7 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
test_records = frappe.get_test_records('Supplier Type')

View File

@@ -147,14 +147,15 @@ def install(country=None):
{'doctype': 'Customer Group', 'customer_group_name': _('Non Profit'), 'is_group': 0, 'parent_customer_group': _('All Customer Groups')},
{'doctype': 'Customer Group', 'customer_group_name': _('Government'), 'is_group': 0, 'parent_customer_group': _('All Customer Groups')},
# supplier type
{'doctype': 'Supplier Type', 'supplier_type': _('Services')},
{'doctype': 'Supplier Type', 'supplier_type': _('Local')},
{'doctype': 'Supplier Type', 'supplier_type': _('Raw Material')},
{'doctype': 'Supplier Type', 'supplier_type': _('Electrical')},
{'doctype': 'Supplier Type', 'supplier_type': _('Hardware')},
{'doctype': 'Supplier Type', 'supplier_type': _('Pharmaceutical')},
{'doctype': 'Supplier Type', 'supplier_type': _('Distributor')},
# supplier group
{'doctype': 'Supplier Group', 'supplier_group_name': _('All Supplier Groups'), 'is_group': 1, 'name': _('All Supplier Groups'), 'parent_supplier_group': ''},
{'doctype': 'Supplier Group', 'supplier_group_name': _('Services'), 'is_group': 0, 'parent_supplier_group': _('All Supplier Groups')},
{'doctype': 'Supplier Group', 'supplier_group_name': _('Local'), 'is_group': 0, 'parent_supplier_group': _('All Supplier Groups')},
{'doctype': 'Supplier Group', 'supplier_group_name': _('Raw Material'), 'is_group': 0, 'parent_supplier_group': _('All Supplier Groups')},
{'doctype': 'Supplier Group', 'supplier_group_name': _('Electrical'), 'is_group': 0, 'parent_supplier_group': _('All Supplier Groups')},
{'doctype': 'Supplier Group', 'supplier_group_name': _('Hardware'), 'is_group': 0, 'parent_supplier_group': _('All Supplier Groups')},
{'doctype': 'Supplier Group', 'supplier_group_name': _('Pharmaceutical'), 'is_group': 0, 'parent_supplier_group': _('All Supplier Groups')},
{'doctype': 'Supplier Group', 'supplier_group_name': _('Distributor'), 'is_group': 0, 'parent_supplier_group': _('All Supplier Groups')},
# Sales Person
{'doctype': 'Sales Person', 'sales_person_name': _('Sales Team'), 'is_group': 1, "parent_sales_person": ""},