def open(self): # As the 'open' button might modify the model we need to be sure all other fields/widgets # have been stored in the model. Otherwise the recordChanged() triggered by modifying # the parent model could make us lose changes. self.view.store() value = self.record.value(self.name) if value: model, (id, name) = value # If Control Key is pressed when the open button is clicked # the record will be opened in a new tab. Otherwise it's opened # in a new modal dialog. if QApplication.keyboardModifiers() & Qt.ControlModifier: if QApplication.keyboardModifiers() & Qt.ShiftModifier: target = 'background' else: target = 'current' Api.instance.createWindow( False, model, id, [('id', '=', id)], 'form', mode='form,tree', target=target) else: dialog = ScreenDialog(self) dialog.setup(model, id) dialog.setAttributes(self.attrs) dialog.exec_() else: self.search()
def open(self): # As the 'open' button might modify the model we need to be sure all other fields/widgets # have been stored in the model. Otherwise the recordChanged() triggered by modifying # the parent model could make us lose changes. # self.view.store() if self.record.value(self.name): # If Control Key is pressed when the open button is clicked # the record will be opened in a new tab. Otherwise it's opened # in a new modal dialog. if QApplication.keyboardModifiers() & Qt.ControlModifier: model = self.attributes['relation'] id = self.record.get()[self.name] Api.instance.createWindow(False, model, id, [], 'form', mode='form,tree') else: dialog = ScreenDialog(self.parent()) dialog.setAttributes(self.attributes) dialog.setContext(self.record.fieldContext(self.name)) dialog.setDomain(self.record.domain(self.name)) dialog.setup(self.attributes['relation'], self.record.get()[self.name]) if dialog.exec_() == QDialog.Accepted: self.record.setValue(self.name, dialog.record) else: self.search('')
def new(self): dialog = ScreenDialog(self.currentEditor) dialog.setAttributes(self.attributes) dialog.setContext(self.record.fieldContext(self.name)) dialog.setDomain(self.record.domain(self.name)) dialog.setup(self.attributes['relation']) if dialog.exec_() == QDialog.Accepted: self.record.setValue(self.name, dialog.record)
def new(self): resource = self.uiModel.itemData(self.uiModel.currentIndex()) dialog = ScreenDialog(self) dialog.setContext(self.record.fieldContext(self.name)) dialog.setup(resource) dialog.setAttributes(self.attrs) if dialog.exec_() == QDialog.Accepted: resource = self.uiModel.itemData(self.uiModel.currentIndex()) self.record.setValue(self.name, (resource, dialog.record))
def new(self): self.hide() dialog = ScreenDialog(self) dialog.setContext(self.context) dialog.setDomain(self.modelGroup.domain()) dialog.setup(self.model) if dialog.exec_() == QDialog.Accepted: self.result = [dialog.recordId] self.accept() else: self.reject()
def open(self): # As the 'open' button might modify the model we need to be sure all other fields/widgets # have been stored in the model. Otherwise the recordChanged() triggered by modifying # the parent model could make us lose changes. self.view.store() if self.record.value(self.name): # If Control Key is pressed when the open button is clicked # the record will be opened in a new tab. Otherwise it's opened # in a new modal dialog. if QApplication.keyboardModifiers() & Qt.ControlModifier: model = self.attrs['relation'] id = self.record.get()[self.name] if QApplication.keyboardModifiers() & Qt.ShiftModifier: target = 'background' else: target = 'current' Api.instance.createWindow(False, model, id, [('id', '=', id)], 'form', mode='form,tree', target=target) else: dialog = ScreenDialog(self) dialog.setAttributes(self.attrs) dialog.setup(self.attrs['relation'], self.record.get()[self.name]) if dialog.exec_() == QDialog.Accepted: # TODO: As we want to ensure that if the user changed any field # in the related model, on_change event is triggered in our model # so those changes can take effect, we force the change by setting # the field to False first. # # Note that this is technically correct but not ideal because it will # trigger two on_change server calls instead of only one. We'd need to # have explicit support for that by having a special "forceChange" # parameter or something like that. if not self.isReadOnly(): if dialog.record and dialog.record[ 0] == self.record.get()[self.name]: self.record.setValue(self.name, False) self.record.setValue(self.name, dialog.record) self.display() else: text = str(self.uiText.text()) if text.strip() == '': self.search('')