[fixes] change is group to check box
This commit is contained in:
parent
99892c7ce7
commit
93d68ac0c2
@ -95,7 +95,7 @@ class Account(Document):
|
||||
if self.check_gle_exists():
|
||||
throw(_("Account with existing transaction cannot be converted to ledger"))
|
||||
elif self.is_group:
|
||||
if self.account_type:
|
||||
if self.account_type and not self.flags.exclude_account_type_check:
|
||||
throw(_("Cannot covert to Group because Account Type is selected."))
|
||||
elif self.check_if_child_exists():
|
||||
throw(_("Account with child nodes cannot be set as ledger"))
|
||||
@ -139,7 +139,7 @@ class Account(Document):
|
||||
def convert_ledger_to_group(self):
|
||||
if self.check_gle_exists():
|
||||
throw(_("Account with existing transaction can not be converted to group."))
|
||||
elif self.account_type:
|
||||
elif self.account_type and not self.flags.exclude_account_type_check:
|
||||
throw(_("Cannot covert to Group because Account Type is selected."))
|
||||
else:
|
||||
self.is_group = 1
|
||||
|
@ -15,7 +15,7 @@ def execute():
|
||||
|
||||
def set_parent_to_warehouses(warehouse, company):
|
||||
warehouse = frappe.get_doc("Warehouse", warehouse.name)
|
||||
warehouse.is_group = "Yes" if warehouse.is_group == "Yes" else "No"
|
||||
warehouse.is_group = warehouse.is_group
|
||||
|
||||
if not warehouse.parent_warehouse and warehouse.name != "{0} - {1}".format(_("All Warehouses"), company.abbr):
|
||||
warehouse.parent_warehouse = "{0} - {1}".format(_("All Warehouses"), company.abbr)
|
||||
@ -42,7 +42,7 @@ def create_default_warehouse_group(company):
|
||||
frappe.get_doc({
|
||||
"doctype": "Warehouse",
|
||||
"warehouse_name": _("All Warehouses"),
|
||||
"is_group": "Yes",
|
||||
"is_group": 1,
|
||||
"company": company.name,
|
||||
"parent_warehouse": ""
|
||||
}).insert(ignore_permissions=True)
|
@ -2,5 +2,5 @@ import frappe
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc("stock", "doctype", "warehouse")
|
||||
|
||||
frappe.db.sql("""update tabWarehouse set is_group = if (is_group="Yes", 1, 0)""")
|
||||
frappe.db.sql("""update tabWarehouse
|
||||
set is_group = if ((ifnull(is_group, "No") = "Yes" or ifnull(is_group, 0) = 1), 1, 0)""")
|
@ -73,7 +73,7 @@ $.extend(erpnext.queries, {
|
||||
return {
|
||||
filters: [
|
||||
["Warehouse", "company", "in", ["", cstr(doc.company)]],
|
||||
["Warehouse", "is_group", "=", "No"]
|
||||
["Warehouse", "is_group", "=",0]
|
||||
|
||||
]
|
||||
}
|
||||
|
@ -88,10 +88,10 @@ class Company(Document):
|
||||
|
||||
def create_default_warehouses(self):
|
||||
for wh_detail in [
|
||||
{"warehouse_name": _("All Warehouses"), "is_group": "Yes"},
|
||||
{"warehouse_name": _("Stores"), "is_group": "No"},
|
||||
{"warehouse_name": _("Work In Progress"), "is_group": "No"},
|
||||
{"warehouse_name": _("Finished Goods"), "is_group": "No"}]:
|
||||
{"warehouse_name": _("All Warehouses"), "is_group": 1},
|
||||
{"warehouse_name": _("Stores"), "is_group": 0},
|
||||
{"warehouse_name": _("Work In Progress"), "is_group": 0},
|
||||
{"warehouse_name": _("Finished Goods"), "is_group": 0}]:
|
||||
|
||||
if not frappe.db.exists("Warehouse", "{0} - {1}".format(wh_detail["warehouse_name"], self.abbr)):
|
||||
stock_group = frappe.db.get_value("Account", {"account_type": "Stock",
|
||||
@ -103,7 +103,7 @@ class Company(Document):
|
||||
"is_group": wh_detail["is_group"],
|
||||
"company": self.name,
|
||||
"parent_warehouse": "{0} - {1}".format(_("All Warehouses"), self.abbr) \
|
||||
if wh_detail["is_group"] == "No" else "",
|
||||
if not wh_detail["is_group"] else "",
|
||||
"create_account_under": stock_group
|
||||
})
|
||||
warehouse.flags.ignore_permissions = True
|
||||
|
@ -163,13 +163,13 @@ $.extend(erpnext.item, {
|
||||
|
||||
frm.fields_dict['default_warehouse'].get_query = function(doc) {
|
||||
return {
|
||||
filters: { "is_group": "No" }
|
||||
filters: { "is_group": 0 }
|
||||
}
|
||||
}
|
||||
|
||||
frm.fields_dict.reorder_levels.grid.get_field("warehouse_group").get_query = function(doc, cdt, cdn) {
|
||||
return {
|
||||
filters: { "is_group": "Yes" }
|
||||
filters: { "is_group": 1 }
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ $.extend(erpnext.item, {
|
||||
var d = locals[cdt][cdn];
|
||||
return {
|
||||
filters: {
|
||||
"is_group": "No",
|
||||
"is_group": 0,
|
||||
"parent_warehouse": d.warehouse_group
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ def set_valuation_method(item_code, valuation_method):
|
||||
frappe.db.set_value("Item", item_code, "valuation_method", valuation_method)
|
||||
|
||||
for warehouse in frappe.get_all("Warehouse", filters={"company": "_Test Company"}, fields=["name", "is_group"]):
|
||||
if warehouse.is_group == "No":
|
||||
if not warehouse.is_group:
|
||||
update_entries_after({
|
||||
"item_code": item_code,
|
||||
"warehouse": warehouse.name
|
||||
|
@ -4,67 +4,67 @@
|
||||
"create_account_under": "Stock Assets - _TC",
|
||||
"doctype": "Warehouse",
|
||||
"warehouse_name": "_Test Warehouse",
|
||||
"is_group": "No"
|
||||
"is_group": 0
|
||||
},
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"create_account_under": "Stock Assets - _TC",
|
||||
"doctype": "Warehouse",
|
||||
"warehouse_name": "_Test Warehouse",
|
||||
"is_group": "No"
|
||||
"is_group": 0
|
||||
},
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"create_account_under": "Fixed Assets - _TC",
|
||||
"doctype": "Warehouse",
|
||||
"warehouse_name": "_Test Warehouse 1",
|
||||
"is_group": "No"
|
||||
"is_group": 0
|
||||
},
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"create_account_under": "Fixed Assets - _TC",
|
||||
"doctype": "Warehouse",
|
||||
"warehouse_name": "_Test Warehouse 2",
|
||||
"is_group": "No"
|
||||
"is_group": 0
|
||||
},
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"create_account_under": "Stock Assets - _TC",
|
||||
"doctype": "Warehouse",
|
||||
"warehouse_name": "_Test Rejected Warehouse",
|
||||
"is_group": "No"
|
||||
"is_group": 0
|
||||
},
|
||||
{
|
||||
"company": "_Test Company 1",
|
||||
"create_account_under": "Stock Assets - _TC1",
|
||||
"doctype": "Warehouse",
|
||||
"warehouse_name": "_Test Warehouse 2",
|
||||
"is_group": "No"
|
||||
"is_group": 0
|
||||
},
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"doctype": "Warehouse",
|
||||
"warehouse_name": "_Test Warehouse No Account",
|
||||
"is_group": "No"
|
||||
"is_group": 0
|
||||
},
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"doctype": "Warehouse",
|
||||
"warehouse_name": "_Test Warehouse Group",
|
||||
"is_group": "Yes"
|
||||
"is_group": 1
|
||||
},
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"doctype": "Warehouse",
|
||||
"warehouse_name": "_Test Warehouse Group-C1",
|
||||
"is_group": "No",
|
||||
"is_group": 0,
|
||||
"parent_warehouse": "_Test Warehouse Group - _TC"
|
||||
},
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"doctype": "Warehouse",
|
||||
"warehouse_name": "_Test Warehouse Group-C2",
|
||||
"is_group": "No",
|
||||
"is_group": 0,
|
||||
"parent_warehouse": "_Test Warehouse Group - _TC"
|
||||
}
|
||||
]
|
||||
|
@ -10,7 +10,7 @@ test_records = frappe.get_test_records('Warehouse')
|
||||
class TestWarehouse(unittest.TestCase):
|
||||
def test_parent_warehouse(self):
|
||||
parent_warehouse = frappe.get_doc("Warehouse", "_Test Warehouse Group - _TC")
|
||||
self.assertEquals(parent_warehouse.is_group, "Yes")
|
||||
self.assertEquals(parent_warehouse.is_group, 1)
|
||||
|
||||
def test_warehouse_hierarchy(self):
|
||||
p_warehouse = frappe.get_doc("Warehouse", "_Test Warehouse Group - _TC")
|
||||
@ -20,6 +20,6 @@ class TestWarehouse(unittest.TestCase):
|
||||
|
||||
for child_warehouse in child_warehouses:
|
||||
self.assertEquals(p_warehouse.name, child_warehouse.parent_warehouse)
|
||||
self.assertEquals(child_warehouse.is_group, "No")
|
||||
self.assertEquals(child_warehouse.is_group, 0)
|
||||
|
||||
|
||||
|
@ -27,6 +27,8 @@ frappe.ui.form.on("Warehouse", {
|
||||
frm.add_custom_button(__('Non-Group to Group'),
|
||||
function() { convert_to_group_or_ledger(frm); }, 'icon-retweet', 'btn-default')
|
||||
}
|
||||
|
||||
cur_frm.toggle_enable(['is_group', 'company'], false);
|
||||
|
||||
frm.fields_dict['parent_warehouse'].get_query = function(doc) {
|
||||
return {
|
||||
|
@ -50,7 +50,7 @@ class Warehouse(NestedSet):
|
||||
|
||||
def create_account_head(self):
|
||||
if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
|
||||
if not self.get_account(self.name):
|
||||
if not self.get_account():
|
||||
if self.get("__islocal") or not frappe.db.get_value(
|
||||
"Stock Ledger Entry", {"warehouse": self.name}):
|
||||
|
||||
@ -168,7 +168,7 @@ class Warehouse(NestedSet):
|
||||
|
||||
def get_account(self, warehouse=None):
|
||||
filters = {
|
||||
"account_type": "Warehouse",
|
||||
"account_type": "Stock",
|
||||
"company": self.company,
|
||||
"is_group": self.is_group
|
||||
}
|
||||
@ -213,7 +213,9 @@ class Warehouse(NestedSet):
|
||||
else:
|
||||
account_name = self.get_account()
|
||||
if account_name:
|
||||
frappe.get_doc("Account", account_name).convert_group_to_ledger()
|
||||
doc = frappe.get_doc("Account", account_name)
|
||||
doc.warehouse = self.name
|
||||
doc.convert_group_to_ledger()
|
||||
|
||||
self.is_group = 0
|
||||
self.save()
|
||||
@ -225,8 +227,10 @@ class Warehouse(NestedSet):
|
||||
else:
|
||||
account_name = self.get_account(self.name)
|
||||
if account_name:
|
||||
frappe.get_doc("Account", account_name).convert_ledger_to_group()
|
||||
|
||||
doc = frappe.get_doc("Account", account_name)
|
||||
doc.flags.exclude_account_type_check = True
|
||||
doc.convert_ledger_to_group()
|
||||
|
||||
self.is_group = 1
|
||||
self.save()
|
||||
return 1
|
||||
|
@ -10,6 +10,12 @@ frappe.treeview_settings['Warehouse'] = {
|
||||
label: __("Company"),
|
||||
default: frappe.defaults.get_default('company') ? frappe.defaults.get_default('company'): ""
|
||||
}],
|
||||
fields:[
|
||||
{fieldtype:'Data', fieldname: 'name_field',
|
||||
label:__('New Warehouse Name'), reqd:true},
|
||||
{fieldtype:'Check', fieldname:'is_group', label:__('Group Node'),
|
||||
description: __("Further nodes can be only created under 'Group' type nodes")}
|
||||
],
|
||||
onrender: function(node) {
|
||||
if (node.data && node.data.balance!==undefined) {
|
||||
$('<span class="balance-area pull-right text-muted small">'
|
||||
|
@ -18,7 +18,7 @@ def get_stock_value_on(warehouse=None, posting_date=None, item_code=None):
|
||||
|
||||
lft, rgt, is_group = frappe.db.get_value("Warehouse", warehouse, ["lft", "rgt", "is_group"])
|
||||
|
||||
if is_group == "Yes":
|
||||
if is_group:
|
||||
values.extend([lft, rgt])
|
||||
condition += "and exists (\
|
||||
select name from `tabWarehouse` wh where wh.name = sle.warehouse\
|
||||
@ -189,6 +189,6 @@ def validate_warehouse_company(warehouse, company):
|
||||
InvalidWarehouseCompany)
|
||||
|
||||
def is_group_warehouse(warehouse):
|
||||
if frappe.db.get_value("Warehouse", warehouse, "is_group") == "Yes":
|
||||
if frappe.db.get_value("Warehouse", warehouse, "is_group"):
|
||||
frappe.throw(_("Group node warehouse is not allowed to select for transactions"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user