Refactor party type (#13831)

This commit is contained in:
rohitwaghchaure
2018-05-16 11:02:26 +05:30
committed by Rushabh Mehta
parent e42192bb6c
commit e8358f33a3
15 changed files with 152 additions and 82 deletions

View File

@@ -42,6 +42,39 @@
"reqd": 1,
"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": "account_type",
"fieldtype": "Select",
"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": "Account Type",
"length": 0,
"no_copy": 0,
"options": "Payable\nReceivable",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
@@ -55,7 +88,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-11-23 17:46:27.075001",
"modified": "2018-04-26 13:00:49.457439",
"modified_by": "Administrator",
"module": "Setup",
"name": "Party Type",
@@ -64,7 +97,6 @@
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 0,
"delete": 0,
@@ -84,7 +116,6 @@
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 0,
"delete": 0,
@@ -104,7 +135,6 @@
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 0,
"delete": 0,

View File

@@ -11,10 +11,15 @@ class PartyType(Document):
@frappe.whitelist()
def get_party_type(doctype, txt, searchfield, start, page_len, filters):
cond = ''
if filters and filters.get('account'):
account_type = frappe.db.get_value('Account', filters.get('account'), 'account_type')
cond = "and account_type = '%s'" % account_type
return frappe.db.sql("""select name from `tabParty Type`
where `{key}` LIKE %(txt)s
where `{key}` LIKE %(txt)s {cond}
order by name limit %(start)s, %(page_len)s"""
.format(key=searchfield), {
.format(key=searchfield, cond=cond), {
'txt': "%%%s%%" % frappe.db.escape(txt),
'start': start, 'page_len': page_len
})

View File

@@ -198,12 +198,12 @@ def install(country=None):
{'doctype': "Email Account", "email_id": "support@example.com", "append_to": "Issue"},
{'doctype': "Email Account", "email_id": "jobs@example.com", "append_to": "Job Applicant"},
{'doctype': "Party Type", "party_type": "Customer"},
{'doctype': "Party Type", "party_type": "Supplier"},
{'doctype': "Party Type", "party_type": "Employee"},
{'doctype': "Party Type", "party_type": "Member"},
{'doctype': "Party Type", "party_type": "Shareholder"},
{'doctype': "Party Type", "party_type": "Student"},
{'doctype': "Party Type", "party_type": "Customer", "account_type": "Receivable"},
{'doctype': "Party Type", "party_type": "Supplier", "account_type": "Payable"},
{'doctype': "Party Type", "party_type": "Employee", "account_type": "Payable"},
{'doctype': "Party Type", "party_type": "Member", "account_type": "Receivable"},
{'doctype': "Party Type", "party_type": "Shareholder", "account_type": "Payable"},
{'doctype': "Party Type", "party_type": "Student", "account_type": "Receivable"},
{'doctype': "Opportunity Type", "name": "Hub"},
{'doctype': "Opportunity Type", "name": _("Sales")},