[POS-commit] r5465 - in stoqlib/trunk: stoqlib/gui/editors

Johan Dahlin jdahlin at async.com.br
Tue Dec 5 10:58:06 BRST 2006


Author: jdahlin
Date: Tue Dec  5 10:58:06 2006
New Revision: 5465

Added:
   stoqlib/trunk/data/glade/CashInEditor.glade
Modified:
   stoqlib/trunk/stoqlib/gui/editors/tilleditor.py

Log:
#2980: Suprimento deve especificar a razão como a sangria

Added: stoqlib/trunk/data/glade/CashInEditor.glade
==============================================================================
--- (empty file)
+++ stoqlib/trunk/data/glade/CashInEditor.glade	Tue Dec  5 10:58:06 2006
@@ -0,0 +1,80 @@
+<?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="GtkSizeGroup" id="casheditor_entry_sizegroup">
+        <property name="mode">horizontal</property>
+    </widget>
+    <widget class="GtkSizeGroup" id="casheditor_label_sizegroup">
+        <property name="mode">horizontal</property>
+    </widget>
+    <widget class="GtkWindow" id="CashInEditor">
+        <property name="default_height">250</property>
+        <property name="default_width">440</property>
+        <child>
+            <widget class="GtkVBox" id="vbox1">
+                <property name="spacing">6</property>
+                <property name="visible">True</property>
+                <child>
+                    <widget class="GtkEventBox" id="base_cash_holder">
+                        <property name="visible">True</property>
+                        <child>
+                            <placeholder/>
+                        </child>
+                    </widget>
+                    <packing>
+                        <property name="expand">False</property>
+                    </packing>
+                </child>
+                <child>
+                    <widget class="GtkTable" id="table2">
+                        <property name="column_spacing">6</property>
+                        <property name="n_columns">3</property>
+                        <property name="n_rows">1</property>
+                        <property name="row_spacing">6</property>
+                        <property name="visible">True</property>
+                        <child>
+                            <widget class="GtkLabel" id="reason_lbl">
+                                <property name="label" context="yes" translatable="yes">Reason:</property>
+                                <property name="sizegroup">casheditor_label_sizegroup</property>
+                                <property name="visible">True</property>
+                                <property name="xalign">1.0</property>
+                            </widget>
+                            <packing>
+                                <property name="x_options">fill</property>
+                                <property name="y_options">fill</property>
+                            </packing>
+                        </child>
+                        <child>
+                            <widget class="GtkLabel" id="label1">
+                                <property name="visible">True</property>
+                            </widget>
+                            <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="x_options">fill</property>
+                                <property name="y_options">fill</property>
+                            </packing>
+                        </child>
+                        <child>
+                            <widget class="ProxyEntry" id="reason">
+                                <property name="data_type">unicode</property>
+                                <property name="is_focus">True</property>
+                                <property name="model_attribute">description</property>
+                                <property name="sizegroup">casheditor_entry_sizegroup</property>
+                                <property name="visible">True</property>
+                            </widget>
+                            <packing>
+                                <property name="left_attach">2</property>
+                                <property name="right_attach">3</property>
+                                <property name="y_options">fill</property>
+                            </packing>
+                        </child>
+                    </widget>
+                    <packing>
+                        <property name="position">1</property>
+                    </packing>
+                </child>
+            </widget>
+        </child>
+    </widget>
+</glade-interface>

Modified: stoqlib/trunk/stoqlib/gui/editors/tilleditor.py
==============================================================================
--- stoqlib/trunk/stoqlib/gui/editors/tilleditor.py	(original)
+++ stoqlib/trunk/stoqlib/gui/editors/tilleditor.py	Tue Dec  5 10:58:06 2006
@@ -306,7 +306,11 @@
         till = Till.get_current(conn)
         assert till
 
-        return till.create_debit(currency(0))
+        # FIXME: Implement and use IDescribable on PersonAdaptToBranch
+        description = (_(u'Cash out for station "%s" of branch "%s"')
+                       % (till.station.name,
+                          till.station.branch.person.name))
+        return till.create_debit(currency(0), description)
 
     def setup_slaves(self):
         self.cash_slave = BaseCashSlave(
@@ -343,9 +347,9 @@
     It uses BashCashSlave without any extensions
     """
 
-    model_name = _(u'Cash In')
+    model_name = _(u'Cash Out')
     model_type = TillEntry
-    gladefile = 'BaseTemplate'
+    gladefile = 'CashOutEditor'
 
     #
     # BaseEditorSlave
@@ -362,12 +366,22 @@
         return till.create_credit(currency(0), description)
 
     def setup_slaves(self):
-        self.cash_slave = BaseCashSlave(self.conn,
-                                        _BaseCashModel(self.model))
-        self.attach_slave("main_holder", self.cash_slave)
+        self.cash_slave = BaseCashSlave(
+            self.conn, _BaseCashModel(self.model))
+        self.attach_slave("base_cash_holder", self.cash_slave)
 
     def validate_confirm(self):
         return self.cash_slave.validate_confirm()
 
     def on_confirm(self):
-        return self.cash_slave.on_confirm()
+        valid = self.cash_slave.on_confirm()
+        if valid:
+            reason = self.reason.get_text()
+            if reason:
+                # %s is the description used when removing money
+                payment_description = _(u'Cash in: %s') % reason
+            else:
+                payment_description = _(u'Cash in')
+            self.model.description = payment_description
+
+        return valid


More information about the POS-commit mailing list