~chromano/stoq/ideale

« back to all changes in this revision

Viewing changes to stoq/gui/production/production.py

  • Committer: george
  • Date: 2009-07-31 14:02:18 UTC
  • Revision ID: vcs-imports@canonical.com-20090731140218-3yjzk32k2phx0zdt
#4037: Wizard de abertura de producao (stoq). r=romaia

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
from kiwi.ui.objectlist import SearchColumn, Column
32
32
from kiwi.ui.search import ComboSearchFilter, SearchFilterPosition
33
33
 
 
34
from stoqlib.database.runtime import new_transaction, finish_transaction
34
35
from stoqlib.domain.production import ProductionOrder
35
36
from stoqlib.gui.search.productionsearch import ProductionProductSearch
 
37
from stoqlib.gui.search.servicesearch import ServiceSearch
 
38
from stoqlib.gui.wizards.productionwizard import ProductionWizard
36
39
 
37
40
from stoq.gui.application import SearchableAppWindow
38
41
 
47
50
    search_label = _(u'matching:')
48
51
    klist_selection_mode = gtk.SELECTION_MULTIPLE
49
52
 
 
53
    def __init__(self, app):
 
54
        SearchableAppWindow.__init__(self, app)
 
55
        self._update_widgets()
 
56
 
 
57
    def _update_widgets(self):
 
58
        selection = self.results.get_selected_rows()
 
59
        can_edit = False
 
60
        if len(selection) == 1:
 
61
            selected = selection[0]
 
62
            can_edit = (selected.status == ProductionOrder.ORDER_OPENED or
 
63
                        selected.status == ProductionOrder.ORDER_WAITING)
 
64
        self.edit_button.set_sensitive(can_edit)
 
65
 
50
66
    def _get_status_values(self):
51
67
        items = [(text, value)
52
68
                 for value, text in ProductionOrder.statuses.items()]
53
69
        items.insert(0, (_(u'Any'), None))
54
70
        return items
55
71
 
 
72
    def _open_production_order(self, order=None):
 
73
        trans = new_transaction()
 
74
        order = trans.get(order)
 
75
        retval = self.run_dialog(ProductionWizard, trans, order)
 
76
        finish_transaction(trans, retval)
 
77
        trans.close()
 
78
 
56
79
    #
57
80
    # SearchableAppWindow
58
81
    #
82
105
    def on_Products__activate(self, action):
83
106
        self.run_dialog(ProductionProductSearch, self.conn)
84
107
 
 
108
    def on_Services__activate(self, action):
 
109
        self.run_dialog(ServiceSearch, self.conn, hide_price_column=True)
 
110
 
85
111
    def on_MenuNewProduction__activate(self, action):
86
 
        pass
 
112
        self._open_production_order()
87
113
 
88
114
    def on_ToolbarNewProduction__activate(self, action):
89
 
        pass
 
115
        self._open_production_order()
 
116
 
 
117
    def on_edit_button__clicked(self, widget):
 
118
        order = self.results.get_selected_rows()[0]
 
119
        assert order is not None
 
120
        self._open_production_order(order)
 
121
 
 
122
    def on_results__selection_changed(self, results, selected):
 
123
        self._update_widgets()