Sfoglia il codice sorgente

[rename with merge] updated on_rename function for item, warehouse, al tree type documents

version-14
Nabin Hait 12 anni fa
parent
commit
27dea3f1d9
1 ha cambiato i file con 12 aggiunte e 2 eliminazioni
  1. +12
    -2
      webnotes/utils/nestedset.py

+ 12
- 2
webnotes/utils/nestedset.py Vedi File

@@ -32,7 +32,7 @@
from __future__ import unicode_literals

import webnotes, unittest
from webnotes import msgprint
from webnotes import msgprint, _
from webnotes.model.bean import Bean
from webnotes.model.doc import Document

@@ -326,4 +326,14 @@ class DocTypeNestedSet(object):
def on_trash(self):
self.doc.fields[self.nsm_parent_field] = ""
update_nsm(self)
update_nsm(self)
def on_rename(self, newdn, olddn, merge=False, group_fname="is_group"):
if merge:
is_group = webnotes.conn.get_value(self.doc.doctype, newdn, group_fname)
if self.doc.fields[group_fname] != is_group:
msgprint(_("""Merging is only possible between Group-to-Group or
Ledger-to-Ledger"""), raise_exception=1)
parent_field = "parent_" + self.doc.doctype.replace(" ", "_").lower()
rebuild_tree(self.doc.doctype, parent_field)

Caricamento…
Annulla
Salva