[POS-commit] r7445 - in stoqlib/trunk/stoqlib: domain gui/dialogs gui/editors
jdahlin at async.com.br
jdahlin at async.com.br
Wed Feb 20 16:33:57 BRT 2008
Author: jdahlin
Date: Wed Feb 20 16:33:57 2008
New Revision: 7445
Log:
Convert DeviceSettingsDialog to use ModelListDialog, Implement IDescribable on DeviceSettings and remove some cruft in the DeviceSettingsEditor now when we don't have fiscal printers in that dialog
Modified:
stoqlib/trunk/stoqlib/domain/devices.py
stoqlib/trunk/stoqlib/gui/dialogs/devices.py
stoqlib/trunk/stoqlib/gui/editors/deviceseditor.py
Modified: stoqlib/trunk/stoqlib/domain/devices.py
==============================================================================
--- stoqlib/trunk/stoqlib/domain/devices.py (original)
+++ stoqlib/trunk/stoqlib/domain/devices.py Wed Feb 20 16:33:57 2008
@@ -38,7 +38,7 @@
from stoqlib.database.columns import DecimalCol
from stoqlib.database.runtime import get_current_station
from stoqlib.domain.base import Domain
-from stoqlib.domain.interfaces import IActive
+from stoqlib.domain.interfaces import IActive, IDescribable
from stoqlib.exceptions import DatabaseInconsistency
from stoqlib.lib.translation import stoqlib_gettext
@@ -46,7 +46,7 @@
class DeviceSettings(Domain):
- implements(IActive)
+ implements(IActive, IDescribable)
type = IntCol()
brand = UnicodeCol()
@@ -155,6 +155,13 @@
return _(u'Active')
return _(u'Inactive')
+ #
+ # IDescribable implementation
+ #
+
+ def get_description(self):
+ return self.get_printer_description()
+
class FiscalDayTax(Domain):
"""This represents the information that needs to be used to
Modified: stoqlib/trunk/stoqlib/gui/dialogs/devices.py
==============================================================================
--- stoqlib/trunk/stoqlib/gui/dialogs/devices.py (original)
+++ stoqlib/trunk/stoqlib/gui/dialogs/devices.py Wed Feb 20 16:33:57 2008
@@ -2,7 +2,7 @@
# vi:si:et:sw=4:sts=4:ts=4
##
-## Copyright (C) 2006 Async Open Source <http://www.async.com.br>
+## Copyright (C) 2006, 2008 Async Open Source <http://www.async.com.br>
## All rights reserved
##
## This program is free software; you can redistribute it and/or modify
@@ -19,41 +19,45 @@
## along with this program; if not, write to the Free Software
## Foundation, Inc., or visit: http://www.gnu.org/.
##
-## Author(s): Henrique Romano <henrique at async.com.br>
+## Author(s): Henrique Romano <henrique at async.com.br>
+## Johan Dahlin <jdahlin at async.com.br>
##
##
-""" Device Settings listing dialog """
+"""Device Settings listing dialog """
-from stoqlib.gui.base.lists import AdditionListDialog
-from stoqlib.gui.slaves.devicesslave import DeviceSettingsDialogSlave
-from stoqlib.lib.translation import stoqlib_gettext
+from kiwi.ui.objectlist import Column
+
+from stoqlib.database.runtime import get_current_station
from stoqlib.domain.devices import DeviceSettings
+from stoqlib.gui.base.lists import ModelListDialog
+from stoqlib.gui.editors.deviceseditor import DeviceSettingsEditor
+from stoqlib.lib.translation import stoqlib_gettext
_ = stoqlib_gettext
-class DeviceSettingsDialog(AdditionListDialog):
- size = (500, 300)
- def __init__(self, conn, station=None):
- self._station = station
- AdditionListDialog.__init__(self, conn, title=_("Devices"))
- self.set_before_delete_items(self._on_delete_items)
-
- def _on_delete_items(self, slave, items):
- result = DeviceSettings.select(
- DeviceSettings.q.type == DeviceSettings.FISCAL_PRINTER_DEVICE,
- connection=self.conn)
- if result:
- return
- self.conn.commit()
-
- #
- # AdditionListDialog hooks
- #
-
- def get_slave(self, editor_class, columns, klist_objects):
- return DeviceSettingsDialogSlave (self.conn,
- station=self._station)
-
- def on_confirm(self):
- self.conn.commit()
- return AdditionListDialog.on_confirm(self)
+
+class DeviceSettingsDialog(ModelListDialog):
+
+ # ModelListDialog
+ model_type = DeviceSettings
+ title = _('Device settings')
+ size = (620, 300)
+
+ # ListDialog
+ columns = [
+ Column('device_type_name', title=_('Device Type'),
+ data_type=str, sorted=True, width=120),
+ Column('description', title=_('Description'),
+ data_type=str, expand=True),
+ Column('station.name', title=_('Station'),
+ data_type=str, width=150, searchable=True),
+ Column('is_active', title=_("Active"),
+ data_type=bool, width=100)]
+
+ def _populate(self):
+ return DeviceSettings.select(connection=self.trans)
+
+ def run_editor(self, trans, model):
+ return self.run_dialog(DeviceSettingsEditor, conn=trans,
+ model=model,
+ station=get_current_station(trans))
Modified: stoqlib/trunk/stoqlib/gui/editors/deviceseditor.py
==============================================================================
--- stoqlib/trunk/stoqlib/gui/editors/deviceseditor.py (original)
+++ stoqlib/trunk/stoqlib/gui/editors/deviceseditor.py Wed Feb 20 16:33:57 2008
@@ -34,11 +34,11 @@
from stoqlib.domain.devices import DeviceSettings
from stoqlib.domain.person import BranchStation
from stoqlib.gui.editors.baseeditor import BaseEditor
-from stoqlib.lib.message import warning
from stoqlib.lib.translation import stoqlib_gettext
_ = stoqlib_gettext
+
class DeviceSettingsEditor(BaseEditor):
gladefile = 'DeviceSettingsEditor'
model_type = DeviceSettings
@@ -174,20 +174,7 @@
return False
return True
- # FIXME: this part will improved when bug #2334 is fixed.
def on_confirm(self):
- if not self.model.is_a_printer():
- return self.model
- is_enabled = self.edit_mode or self.model.constants
- # FIXME: this part will be improved when bug #2641 is fixed
- is_enabled = is_enabled or (self.model.brand != "bematech"
- and self.model.model != "DP20C")
- if not is_enabled:
- warning( _(u"The printer will be disabled"),
- _(u"The printer will be disabled automatically "
- "because there are no constants defined yet."))
- self.model.inactivate()
-
return self.model
#
More information about the POS-commit
mailing list