[Stoq-devel] Remoção de SelectCashMethodSlave

Henrique Romano henrique at async.com.br
Thu Jul 27 15:40:11 BRT 2006


Olá,

Segue em anexo patch que remove o slave SelectCashMethodSlave.
Esse slave era utilizado quando nenhuma forma de pagamento (a não ser 
dinheiro) estava disponível no sistema. Mas, acredito que isso não 
precisa de tratamento especial... mostrar somente um radio button 
selecionado ao invés de uma label não parece melhorar em nada, embora 
tratar de dois slaves diferentes em um placeholder pareça algo 
desnecessário nesse caso, esse é o principal motivo do patch... remover 
o slave cuja funcionalidade pode ser muito bem implementada por outro 
que já existe.

Johan, poderia revisar?

Henrique.

-------------- next part --------------
Index: data/glade/SelectCashMethodSlave.glade
===================================================================
--- data/glade/SelectCashMethodSlave.glade	(revisão 3987)
+++ data/glade/SelectCashMethodSlave.glade	(cópia de trabalho)
@@ -1,40 +0,0 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://gazpacho.sicem.biz/gazpacho-0.1.dtd">
-<glade-interface domain="stoqlib">
-    <widget class="GtkWindow" id="SelectCashMethodSlave">
-        <property name="default_height">250</property>
-        <property name="default_width">440</property>
-        <child>
-            <widget class="GtkVBox" id="vbox1">
-                <property name="visible">True</property>
-                <child>
-                    <widget class="GtkHBox" id="hbox1">
-                        <property name="border_width">6</property>
-                        <property name="spacing">6</property>
-                        <property name="visible">True</property>
-                        <child>
-                            <widget class="GtkLabel" id="label1">
-                                <property name="label" context="yes" translatable="yes">Method of Payment:</property>
-                                <property name="visible">True</property>
-                                <property name="xalign">1.0</property>
-                            </widget>
-                        </child>
-                        <child>
-                            <widget class="GtkLabel" id="label2">
-                                <property name="label" context="yes" translatable="yes">Money</property>
-                                <property name="visible">True</property>
-                                <property name="xalign">0.0</property>
-                            </widget>
-                            <packing>
-                                <property name="position">1</property>
-                            </packing>
-                        </child>
-                    </widget>
-                    <packing>
-                        <property name="expand">False</property>
-                    </packing>
-                </child>
-            </widget>
-        </child>
-    </widget>
-</glade-interface>
Index: stoqlib/gui/wizards/abstract.py
===================================================================
--- stoqlib/gui/wizards/abstract.py	(revisão 4005)
+++ stoqlib/gui/wizards/abstract.py	(cópia de trabalho)
@@ -46,14 +46,12 @@
 from stoqlib.gui.base.dialogs import run_dialog
 from stoqlib.gui.base.editors import NoteEditor
 from stoqlib.gui.base.lists import AdditionListSlave
-from stoqlib.gui.slaves.paymentmethod import (SelectCashMethodSlave,
-                                              SelectPaymentMethodSlave)
+from stoqlib.gui.slaves.paymentmethod import SelectPaymentMethodSlave
 from stoqlib.gui.slaves.sale import DiscountSurchargeSlave
 from stoqlib.domain.sale import Sale
 from stoqlib.domain.product import Product
 from stoqlib.domain.interfaces import ISellable
 from stoqlib.domain.payment.base import AbstractPaymentGroup
-from stoqlib.domain.payment.methods import get_active_pm_ifaces
 from stoqlib.domain.person import Person
 from stoqlib.domain.interfaces import (IPaymentGroup, ISalesPerson,
                                        IMultiplePM, IMoneyPM,
@@ -149,8 +147,7 @@
             self.salesperson_combo.grab_focus()
 
     def _get_selected_payment_method(self):
-        if (isinstance(self.pm_slave, SelectCashMethodSlave)
-            or self.pm_slave.cash_check.get_active()):
+        if self.pm_slave.cash_check.get_active():
             return IMoneyPM
         elif self.pm_slave.certificate_check.get_active():
             return IGiftCertificatePM
@@ -229,14 +226,10 @@
         if self.get_slave(slave_holder):
             self.detach_slave(slave_holder)
         self.attach_slave('discount_surcharge_slave', self.discsurcharge_slave)
-        pm_ifaces = get_active_pm_ifaces()
-        if len(pm_ifaces) == 1:
-            self.pm_slave = SelectCashMethodSlave()
-        else:
-            self.pm_slave = SelectPaymentMethodSlave(pm_ifaces)
-            self._setup_payment_method_widgets()
-        self.pm_slave.connect('method-changed',
-                              self.on_payment_method_changed)
+
+        self.pm_slave = SelectPaymentMethodSlave()
+        self._setup_payment_method_widgets()
+        self.pm_slave.connect('method-changed', self.on_payment_method_changed)
         self.attach_slave('select_method_holder', self.pm_slave)
 
     def setup_proxies(self):
Index: stoqlib/gui/slaves/paymentmethod.py
===================================================================
--- stoqlib/gui/slaves/paymentmethod.py	(revisão 3987)
+++ stoqlib/gui/slaves/paymentmethod.py	(cópia de trabalho)
@@ -33,8 +33,8 @@
                                        IMultiplePM, IMoneyPM)
 from stoqlib.domain.payment.destination import PaymentDestination
 from stoqlib.domain.payment.methods import (AbstractCheckBillAdapter,
-                                            FinanceDetails)
-
+                                            FinanceDetails,
+                                            get_active_pm_ifaces)
 
 class CheckBillSettingsSlave(BaseEditorSlave):
     model_type = AbstractCheckBillAdapter
@@ -75,32 +75,30 @@
         self.add_proxy(self.model,
                        FinanceDetailsSlave.proxy_widgets)
 
-
-class SelectCashMethodSlave(SlaveDelegate):
-    toplevel_name = gladefile = 'SelectCashMethodSlave'
-
-
 class SelectPaymentMethodSlave(SlaveDelegate):
-    toplevel_name = gladefile = 'SelectPaymentMethodSlave'
+    """ This slave show a radion button group with three payment method options:
+    Money, Gift Certificate and Other (any other method supported by the system).
+    The visibility of these buttons are directly related to payment method
+    availabiltiy in the company.
+    """
+    gladefile = 'SelectPaymentMethodSlave'
     gsignal('method-changed', object)
 
-    def __init__(self, active_pm_ifaces):
-        SlaveDelegate.__init__(self, toplevel=self.toplevel_name,
-                               gladefile=self.gladefile)
-        self._setup_widgets(active_pm_ifaces)
+    def __init__(self):
+        SlaveDelegate.__init__(self, gladefile=SelectPaymentMethodSlave.gladefile)
+        self._setup_widgets()
 
-    def _setup_widgets(self, active_pm_ifaces):
-        if len(active_pm_ifaces) == 1:
-            raise ValueError("You should have more than one "
-                             "active payment methods to use "
-                             "this slave")
+    def _setup_widgets(self):
+        active_pm_ifaces = get_active_pm_ifaces()
         if not IGiftCertificatePM in active_pm_ifaces:
             self.certificate_check.hide()
-            return
-        otherm_ifaces = [iface for iface in (ICheckPM, ICardPM,
-                                             IBillPM, IFinancePM)
-                                if iface in active_pm_ifaces]
-        if not otherm_ifaces:
+        else:
+            active_pm_ifaces.remove(IGiftCertificatePM)
+        if not IMoneyPM in active_pm_ifaces:
+            raise StoqlibError("The money payment method should be always "
+                               "available")
+        active_pm_ifaces.remove(IMoneyPM)
+        if not active_pm_ifaces:
             self.othermethods_check.hide()
 
     #


More information about the Stoq-devel mailing list