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

Johan Dahlin jdahlin at async.com.br
Tue Apr 17 11:35:25 BRT 2007


Author: jdahlin
Date: Tue Apr 17 11:35:24 2007
New Revision: 6378

Modified:
   stoqlib/trunk/stoqlib/gui/editors/sellableeditor.py
   stoqlib/trunk/stoqlib/gui/slaves/sellableslave.py

Log:
#3292: Cadastro de produto aceita preço de venda negativo, patch by Gilma Souza

Modified: stoqlib/trunk/stoqlib/gui/editors/sellableeditor.py
==============================================================================
--- stoqlib/trunk/stoqlib/gui/editors/sellableeditor.py	(original)
+++ stoqlib/trunk/stoqlib/gui/editors/sellableeditor.py	Tue Apr 17 11:35:24 2007
@@ -23,9 +23,11 @@
 ##              Evandro Vale Miquelito      <evandro at async.com.br>
 ##              Bruno Rafael Garcia         <brg at async.com.br>
 ##              Fabio Morbec                <fabio at async.com.br>
+##              Gilma Gomes de Souza        <anaiort at gmail.com>
 ##
 """ Editors definitions for sellable"""
 
+from kiwi.datatypes import ValidationError
 from kiwi.python import Settable
 from kiwi.ui.objectlist import Column
 from sqlobject.sqlbuilder import LIKE, func
@@ -323,7 +325,15 @@
             self._sellable.barcode = barcode
         self.ensure_sellable_unit()
         return True
-
+   
+    def on_price__validate(self, entry, value):
+        if value <= 0:
+           return ValidationError(_("Price cannot be zero or negative"))
+
+    def on_cost__validate(self, entry, value):
+        if value <= 0:
+           return ValidationError(_("Cost cannot be zero or negative"))
+    
 class SellableItemEditor(BaseEditor):
     gladefile = 'SellableItemEditor'
     proxy_widgets = ('quantity',

Modified: stoqlib/trunk/stoqlib/gui/slaves/sellableslave.py
==============================================================================
--- stoqlib/trunk/stoqlib/gui/slaves/sellableslave.py	(original)
+++ stoqlib/trunk/stoqlib/gui/slaves/sellableslave.py	Tue Apr 17 11:35:24 2007
@@ -20,12 +20,17 @@
 ## Foundation, Inc., or visit: http://www.gnu.org/.
 ##
 ## Author(s):   Evandro Vale Miquelito      <evandro at async.com.br>
+##              Gilma Gomes de Souza        <anaiort at gmail.com>
 ##
 """ Slaves for sellables """
 
+from kiwi.datatypes import ValidationError
+
 from stoqlib.gui.editors.baseeditor import BaseEditorSlave
 from stoqlib.domain.sellable import OnSaleInfo
+from stoqlib.lib.translation import stoqlib_gettext
 
+_ = stoqlib_gettext
 
 class OnSaleInfoSlave(BaseEditorSlave):
     """A slave for price and dates information when a certain product,
@@ -46,3 +51,11 @@
 
     def setup_proxies(self):
         self.proxy = self.add_proxy(self.model, self.proxy_widgets)
+  
+    #
+    # Kiwi callbacks
+    #
+
+    def on_on_sale_price__validate(self, entry, value):
+        if value < 0:
+           return ValidationError(_("Sale price can not be 0"))


More information about the POS-commit mailing list