def on_further_details_button__clicked(self, *args): store = api.new_store() model = store.fetch(self.model) run_person_role_dialog(ClientEditor, self, store, model, visual_mode=True) store.confirm(False) store.close()
def _create_client(self): store = api.new_store() client = run_person_role_dialog(ClientEditor, self.wizard, store, None) store.confirm(client) if not client: return if len(self.client) == 0: self._setup_clients_widget() return clients = self.client.get_model_items().values() if client.id in clients: if client.is_active: self.client.select(client.id) else: # remove client from combo self.client.select_item_by_data(client.id) iter = self.client.get_active_iter() model = self.client.get_model() model.remove(iter) # just in case the inactive client was selected before. self.client.select_item_by_position(0) elif client.is_active: self.client.append_item(client.person.name, client.id) self.client.select(client.id) store.close()
def run_dialog(self, store, person): from stoqlib.domain.person import (Branch, Client, Supplier, Transporter, SalesPerson) from stoqlib.gui.editors.personeditor import (BranchEditor, ClientEditor, EmployeeEditor, SupplierEditor, TransporterEditor) editors = { Branch: BranchEditor, Client: ClientEditor, Supplier: SupplierEditor, Transporter: TransporterEditor, SalesPerson: EmployeeEditor, } editor = editors.get(self.person_type) if editor is None: # pragma no cover raise NotImplementedError(self.person_type) # FIXME: Salesperson is edited on EmployeeEditor, so we need to get # that facet for the editor if isinstance(person, SalesPerson): person = person.person.employee from stoqlib.gui.wizards.personwizard import run_person_role_dialog return run_person_role_dialog(editor, self.toplevel, store, person, visual_mode=not self.can_edit)
def on_create_client__clicked(self, button): with api.new_store() as store: client = run_person_role_dialog(ClientEditor, self, store, None) if store.committed: self._fill_clients_combo() self.client.select(client.id)
def _run_medic_editor(self, medic=None, visual_mode=False): with api.trans() as store: medic = run_person_role_dialog(MedicEditor, self, store, medic, visual_mode=True) if medic: self._medic_combo_prefill() medic = self.store.fetch(medic) self.medic_combo.select(medic)
def _run_client_editor(self, client=None): with api.new_store() as store: rv = run_person_role_dialog(ClientEditor, self, store, client, visual_mode=self.visual_mode) if rv: self._fill_clients_combo() self.client.select(rv.id)
def _run_client_editor(self, client=None): with api.trans() as store: rv = run_person_role_dialog(ClientEditor, self, store, client, visual_mode=self.visual_mode) if rv: self._fill_clients_combo() self.client.select(self.store.fetch(rv))
def _create_client(self): store = api.new_store() client = run_person_role_dialog(ClientEditor, self.wizard, store, None) store.confirm(client) client = self.store.fetch(client) store.close() if not client: return if len(self.client) == 0: self._fill_clients_combo() return clients = self.client.get_model_items().values() if client in clients: if client.is_active: self.client.select(client) else: # remove client from combo self.client.select_item_by_data(client) iter = self.client.get_active_iter() model = self.client.get_model() model.remove(iter) # just in case the inactive client was selected before. self.client.select_item_by_position(0) elif client.is_active: self.client.append_item(client.person.name, client) self.client.select(client) self._update_widgets()
def _run_medic_editor(self, medic=None, visual_mode=False): with api.new_store() as store: parent = self.get_toplevel().get_toplevel() medic = run_person_role_dialog(MedicEditor, parent, store, medic, visual_mode=True) if medic: self._medic_combo_prefill() medic = self.store.fetch(medic) self.medic_combo.select(medic)
def on_create_client__clicked(self, button): store = api.new_store() client = run_person_role_dialog(ClientEditor, self.wizard, store, None) retval = store.confirm(client) store.close() if retval: self._fill_clients_combo() self.client.select(client.id)
def on_create_client__clicked(self, button): store = api.new_store() client = run_person_role_dialog(ClientEditor, self.wizard, store, None) retval = store.confirm(client) client = self.store.fetch(client) store.close() if not retval: return self._fill_clients_combo() self.client.select(client)
def _run_transporter_editor(self, transporter=None): store = api.new_store() transporter = store.fetch(transporter) model = run_person_role_dialog(TransporterEditor, self.wizard, store, transporter) rv = store.confirm(model) store.close() if rv: self._setup_transporter_entry() model = self.store.fetch(model) self.transporter.select(model)
def on_create_transporter__clicked(self, button): store = api.new_store() transporter = store.fetch(self.model.transporter) model = run_person_role_dialog(TransporterEditor, self.wizard, store, transporter) rv = store.confirm(model) store.close() if rv: self._fill_transporter_combo() model = self.store.fetch(model) self.transporter.select(model)
def _run_supplier_dialog(self, supplier): store = api.new_store() if supplier is not None: supplier = store.fetch(self.model.supplier) model = run_person_role_dialog(SupplierEditor, self.wizard, store, supplier) retval = store.confirm(model) if retval: model = self.store.fetch(model) self._fill_supplier_combo() self.supplier.select(model) store.close()
def _run_editor(self): with api.new_store() as store: model = getattr(self._model, self._model_property) model = store.fetch(model) if self._is_person: value = run_person_role_dialog(self._editor_class, self._parent, store, model) else: value = run_dialog(self._editor_class, self._parent, store, model) if value: value = self.store.fetch(value) self.set_value(value)
def _run_client_editor(self, store, model, description=None, visual_mode=False): return run_person_role_dialog(ClientEditor, self.wizard, store, model, document=self.wizard._current_document, description=description, visual_mode=visual_mode)
def run_dialog(self, store, person): from stoqlib.domain.person import Branch, Client, Supplier, Transporter from stoqlib.gui.editors.personeditor import (BranchEditor, ClientEditor, SupplierEditor, TransporterEditor) editors = { Branch: BranchEditor, Client: ClientEditor, Supplier: SupplierEditor, Transporter: TransporterEditor, } editor = editors.get(self.person_type) if editor is None: # pragma no cover raise NotImplementedError(self.person_type) from stoqlib.gui.wizards.personwizard import run_person_role_dialog return run_person_role_dialog(editor, self.toplevel, store, person, visual_mode=not self.can_edit)
def test_client(): # pragma nocover from stoqlib.gui.wizards.personwizard import run_person_role_dialog creator = api.prepare_test() retval = run_person_role_dialog(ClientEditor, None, creator.store, None) creator.store.confirm(retval)
def _run_client_editor(self, store, model): return run_person_role_dialog(ClientEditor, self.wizard, store, model, document=self.wizard._current_document)
def _new_user(self): store = api.new_store() model = run_person_role_dialog(UserEditor, self, store) store.confirm(model) store.close()
def run_dialog(self, editor_class, parent, *args, **kwargs): return run_person_role_dialog(editor_class, parent, *args, **kwargs)