Send signal 'record-changed' to parent only once
This commit is contained in:
1 parent
c20f807b17
commit
3c83d9aaec
2 files changed
+10
-6
No files matched your search
@@ -184,11 +184,12 @@ class ModelRecordGroup(SignalEvent):
|
||||
if newmod and display:
|
||||
self.signal('model-changed', newmod)
|
||||
|
||||
if modified:
|
||||
if modified and newmods:
|
||||
for newmod in newmods:
|
||||
newmod.modified = True
|
||||
if newmod.parent:
|
||||
newmod.signal('record-changed', newmod.parent)
|
||||
# send record-changed only once
|
||||
if newmod.parent:
|
||||
newmod.signal('record-changed', newmod.parent)
|
||||
|
||||
self.current_idx = 0
|
||||
return True
|
||||
@@ -291,7 +292,7 @@ class ModelRecordGroup(SignalEvent):
|
||||
return None
|
||||
return self.models[self.current_idx]
|
||||
|
||||
def remove(self, model, remove=False, modified=True):
|
||||
def remove(self, model, remove=False, modified=True, signal=True):
|
||||
idx = self.models.index(model)
|
||||
if self.models[idx].id > 0:
|
||||
if remove:
|
||||
@@ -303,7 +304,8 @@ class ModelRecordGroup(SignalEvent):
|
||||
if modified:
|
||||
model.modified = True
|
||||
self.models.remove(self.models[idx])
|
||||
model.signal('record-changed', model.parent)
|
||||
if signal:
|
||||
model.signal('record-changed', model.parent)
|
||||
|
||||
def add_fields_custom(self, fields, models):
|
||||
to_add = []
|
||||
|
||||
@@ -515,7 +515,9 @@ class Screen(SignalEvent):
|
||||
# set current model to None to prevent __select_changed
|
||||
# to save the previous_model as it can be already deleted.
|
||||
self.current_model = None
|
||||
self.models.remove(model, remove=remove)
|
||||
self.models.remove(model, remove=remove, signal=False)
|
||||
# send record-changed only once
|
||||
model.signal('record-changed', model.parent)
|
||||
if self.models.models:
|
||||
idx = min(idx, len(self.models.models)-1)
|
||||
self.current_model = self.models.models[idx]
|
||||
|
||||
Reference in new issue
Block a user