fix: Set Root as Parent if no parent in new tree view node (#22497)
Co-authored-by: Nabin Hait <nabinhait@gmail.com>
This commit is contained in:
parent
8732b8caf6
commit
3e93a2f67f
@ -6,9 +6,12 @@ import frappe
|
||||
from frappe import _
|
||||
|
||||
|
||||
from frappe.utils.nestedset import NestedSet
|
||||
from frappe.utils.nestedset import NestedSet, get_root_of
|
||||
class CustomerGroup(NestedSet):
|
||||
nsm_parent_field = 'parent_customer_group'
|
||||
def validate(self):
|
||||
if not self.parent_customer_group:
|
||||
self.parent_customer_group = get_root_of("Customer Group")
|
||||
|
||||
def on_update(self):
|
||||
self.validate_name_with_customer()
|
||||
|
@ -5,13 +5,16 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import flt
|
||||
from frappe.utils.nestedset import NestedSet
|
||||
from frappe.utils.nestedset import NestedSet, get_root_of
|
||||
from erpnext import get_default_currency
|
||||
|
||||
class SalesPerson(NestedSet):
|
||||
nsm_parent_field = 'parent_sales_person'
|
||||
|
||||
def validate(self):
|
||||
if not self.parent_sales_person:
|
||||
self.parent_sales_person = get_root_of("Sales Person")
|
||||
|
||||
for d in self.get('targets') or []:
|
||||
if not flt(d.target_qty) and not flt(d.target_amount):
|
||||
frappe.throw(_("Either target qty or target amount is mandatory."))
|
||||
|
@ -6,12 +6,14 @@ import frappe
|
||||
from frappe.utils import flt
|
||||
from frappe import _
|
||||
|
||||
from frappe.utils.nestedset import NestedSet
|
||||
from frappe.utils.nestedset import NestedSet, get_root_of
|
||||
|
||||
class Territory(NestedSet):
|
||||
nsm_parent_field = 'parent_territory'
|
||||
|
||||
def validate(self):
|
||||
if not self.parent_territory:
|
||||
self.parent_territory = get_root_of("Territory")
|
||||
|
||||
for d in self.get('targets') or []:
|
||||
if not flt(d.target_qty) and not flt(d.target_amount):
|
||||
|
Loading…
Reference in New Issue
Block a user