Merge lp:~romaia/stoq/ideale into lp:~stoq-dev/stoq/master-old

Proposed by Ronaldo Maia
Status: Merged
Merged at revision: not available
Proposed branch: lp:~romaia/stoq/ideale
Merge into: lp:~stoq-dev/stoq/master-old
Diff against target: None lines
To merge this branch: bzr merge lp:~romaia/stoq/ideale
Reviewer Review Type Date Requested Status
George Kussumoto (community) code-review Approve
Review via email: mp+11546@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ronaldo Maia (romaia) wrote :
Revision history for this message
George Kussumoto (georgeyk) wrote :

Ficou legal!

=== modified file 'stoq/gui/stock/stock.py'
--- stoq/gui/stock/stock.py 2009-07-27 18:19:18 +0000
+++ stoq/gui/stock/stock.py 2009-09-10 17:00:40 +0000

@@ -131,6 +126,30 @@
         items.insert(0, [_('All branches'), None])
         return items

+ def _setup_widgets(self):
+ space = gtk.EventBox()
+ space.show()
+ self.hbox7.pack_start(space)
+
+ self.image = gtk.Image()
+
+ button = gtk.Button()
+ button.set_size_request(74, 64)
+ button.set_image(self.image)
+ button.set_relief(gtk.RELIEF_NONE)
+ button.show()
+ button.connect('clicked', self._on_image_button__clicked)
+ self.hbox7.pack_start(button, False, False)
+ self.image_button = button
+
+

uma linha sobrando acima.
Atualiza o nome hbox7 para algo melhor, tipo button_box.

review: Approve (code-review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'stoq/gui/stock/stock.py'
2--- stoq/gui/stock/stock.py 2009-07-27 18:19:18 +0000
3+++ stoq/gui/stock/stock.py 2009-09-10 17:00:40 +0000
4@@ -29,6 +29,7 @@
5
6 import pango
7 import gtk
8+from kiwi.datatypes import converter
9 from kiwi.enums import SearchFilterPosition
10 from kiwi.ui.search import ComboSearchFilter
11 from kiwi.ui.objectlist import Column, SearchColumn
12@@ -42,6 +43,7 @@
13 from stoqlib.domain.views import ProductFullStockView
14 from stoqlib.lib.defaults import sort_sellable_code
15 from stoqlib.lib.message import warning
16+from stoqlib.gui.editors.producteditor import ProductStockEditor
17 from stoqlib.gui.wizards.receivingwizard import ReceivingOrderWizard
18 from stoqlib.gui.wizards.stocktransferwizard import StockTransferWizard
19 from stoqlib.gui.search.receivingsearch import PurchaseReceivingSearch
20@@ -67,6 +69,7 @@
21 search_table = ProductFullStockView
22 search_labels = _('Matching:')
23 klist_selection_mode = gtk.SELECTION_MULTIPLE
24+ pixbuf_converter = converter.get_converter(gtk.gdk.Pixbuf)
25
26 def __init__(self, app):
27 SearchableAppWindow.__init__(self, app)
28@@ -113,14 +116,6 @@
29 # Private API
30 #
31
32- def _setup_widgets(self):
33- self.search.set_summary_label(column='stock',
34- label=_('<b>Stock Total:</b>'),
35- format='<b>%s</b>')
36-
37- if Inventory.has_open(self.conn, get_current_branch(self.conn)):
38- show_inventory_process_message()
39-
40 def _get_branches(self):
41 items = [(b.person.name, b)
42 for b in Person.iselect(IBranch, connection=self.conn)]
43@@ -131,6 +126,30 @@
44 items.insert(0, [_('All branches'), None])
45 return items
46
47+ def _setup_widgets(self):
48+ space = gtk.EventBox()
49+ space.show()
50+ self.hbox7.pack_start(space)
51+
52+ self.image = gtk.Image()
53+
54+ button = gtk.Button()
55+ button.set_size_request(74, 64)
56+ button.set_image(self.image)
57+ button.set_relief(gtk.RELIEF_NONE)
58+ button.show()
59+ button.connect('clicked', self._on_image_button__clicked)
60+ self.hbox7.pack_start(button, False, False)
61+ self.image_button = button
62+
63+
64+ self.search.set_summary_label(column='stock',
65+ label=_('<b>Stock Total:</b>'),
66+ format='<b>%s</b>')
67+
68+ if Inventory.has_open(self.conn, get_current_branch(self.conn)):
69+ show_inventory_process_message()
70+
71 def _update_widgets(self):
72 branch = get_current_branch(self.conn)
73 if Inventory.has_open(self.conn, branch):
74@@ -142,7 +161,21 @@
75
76 is_main_branch = self.branch_filter.get_state().value is branch
77 has_stock = len(self.results) > 0
78- one_selected = len(self.results.get_selected_rows()) == 1
79+
80+ selected = self.results.get_selected_rows()
81+ one_selected = len(selected) == 1
82+
83+ pixbuf = None
84+ if one_selected:
85+ item = selected[0]
86+ pixbuf = self.pixbuf_converter.from_string(item.product.image)
87+
88+ if pixbuf:
89+ self.image.set_from_pixbuf(pixbuf)
90+ else:
91+ self.image.set_from_stock(gtk.STOCK_EDIT, gtk.ICON_SIZE_DIALOG)
92+
93+ self.image_button.set_sensitive(one_selected)
94 self.history_button.set_sensitive(one_selected and is_main_branch)
95 self.retention_button.set_sensitive(one_selected and is_main_branch)
96 self.print_button.set_sensitive(has_stock)
97@@ -233,3 +266,17 @@
98 sellable = Sellable.get(selected[0].id, connection=self.conn)
99 self.run_dialog(ProductStockHistoryDialog, self.conn, sellable,
100 branch=self.branch_filter.combo.get_selected())
101+
102+ def _on_image_button__clicked(self, button):
103+ selected = self.results.get_selected_rows()
104+ one_selected = len(selected) == 1
105+
106+ if not one_selected:
107+ return
108+
109+ trans = new_transaction()
110+ product = trans.get(selected[0].product)
111+
112+ model = self.run_dialog(ProductStockEditor, trans, product)
113+ finish_transaction(trans, model)
114+ trans.close()

Subscribers

People subscribed via source and target branches