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:
Marica 2020-06-29 17:39:26 +05:30 committed by GitHub
parent 8732b8caf6
commit 3e93a2f67f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View File

@ -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()

View File

@ -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."))

View File

@ -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):