fix: Made employee optional in sales person
This commit is contained in:
parent
7dcdb93596
commit
b305f38869
@ -22,6 +22,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "name_and_employee_id",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@ -54,6 +55,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "sales_person_name",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
@ -88,6 +90,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "Select company name first.",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "parent_sales_person",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@ -122,6 +125,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "commission_rate",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
@ -154,6 +158,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "is_group",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@ -189,6 +194,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "1",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "enabled",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@ -221,6 +227,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "cb0",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@ -251,6 +258,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "employee",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@ -270,7 +278,7 @@
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
@ -284,6 +292,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_from": "employee.department",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "department",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@ -317,6 +326,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "lft",
|
||||
"fieldtype": "Int",
|
||||
"hidden": 1,
|
||||
@ -350,6 +360,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "rgt",
|
||||
"fieldtype": "Int",
|
||||
"hidden": 1,
|
||||
@ -383,6 +394,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "old_parent",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
@ -417,6 +429,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "Set targets Item Group-wise for this Sales Person.",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "target_details_section_break",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@ -450,6 +463,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "targets",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
@ -485,6 +499,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "Select Monthly Distribution to unevenly distribute targets across months.",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "distribution_id",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@ -524,7 +539,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2019-01-30 11:28:16.966735",
|
||||
"modified": "2019-04-09 20:03:35.967037",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Sales Person",
|
||||
@ -594,7 +609,7 @@
|
||||
"search_fields": "parent_sales_person",
|
||||
"show_name_in_global_search": 1,
|
||||
"sort_order": "ASC",
|
||||
"track_changes": 1,
|
||||
"track_changes": 0,
|
||||
"track_seen": 0,
|
||||
"track_views": 0
|
||||
}
|
@ -21,18 +21,18 @@ class SalesPerson(NestedSet):
|
||||
self.load_dashboard_info()
|
||||
|
||||
def load_dashboard_info(self):
|
||||
company_default_currency = get_default_currency()
|
||||
company_default_currency = get_default_currency()
|
||||
|
||||
allocated_amount = frappe.db.sql("""
|
||||
select sum(allocated_amount)
|
||||
from `tabSales Team`
|
||||
from `tabSales Team`
|
||||
where sales_person = %s and docstatus=1 and parenttype = 'Sales Order'
|
||||
""",(self.sales_person_name))
|
||||
|
||||
info = {}
|
||||
info["allocated_amount"] = flt(allocated_amount[0][0]) if allocated_amount else 0
|
||||
info["currency"] = company_default_currency
|
||||
|
||||
|
||||
self.set_onload('dashboard_info', info)
|
||||
|
||||
def on_update(self):
|
||||
@ -48,10 +48,11 @@ class SalesPerson(NestedSet):
|
||||
return frappe.db.get_value("User", user, "email") or user
|
||||
|
||||
def validate_employee_id(self):
|
||||
sales_person = frappe.db.get_value("Sales Person", {"employee": self.employee})
|
||||
|
||||
if sales_person and sales_person != self.name:
|
||||
frappe.throw(_("Another Sales Person {0} exists with the same Employee id").format(sales_person))
|
||||
if self.employee:
|
||||
sales_person = frappe.db.get_value("Sales Person", {"employee": self.employee})
|
||||
|
||||
if sales_person and sales_person != self.name:
|
||||
frappe.throw(_("Another Sales Person {0} exists with the same Employee id").format(sales_person))
|
||||
|
||||
def on_doctype_update():
|
||||
frappe.db.add_index("Sales Person", ["lft", "rgt"])
|
||||
@ -65,7 +66,7 @@ def get_timeline_data(doctype, name):
|
||||
from
|
||||
`tabSales Order` dt, `tabSales Team` st
|
||||
where
|
||||
st.sales_person = %s and st.parent = dt.name and dt.transaction_date > date_sub(curdate(), interval 1 year)
|
||||
st.sales_person = %s and st.parent = dt.name and dt.transaction_date > date_sub(curdate(), interval 1 year)
|
||||
group by dt.transaction_date ''', name)))
|
||||
|
||||
sales_invoice = dict(frappe.db.sql('''select
|
||||
@ -75,7 +76,7 @@ def get_timeline_data(doctype, name):
|
||||
where
|
||||
st.sales_person = %s and st.parent = dt.name and dt.posting_date > date_sub(curdate(), interval 1 year)
|
||||
group by dt.posting_date ''', name))
|
||||
|
||||
|
||||
for key in sales_invoice:
|
||||
if out.get(key):
|
||||
out[key] += sales_invoice[key]
|
||||
@ -97,5 +98,3 @@ def get_timeline_data(doctype, name):
|
||||
out[key] = delivery_note[key]
|
||||
|
||||
return out
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user