Esempio n. 1
0
    def populate(self, person):
        from stoqlib.domain.person import (Client, Supplier, Transporter,
                                           SalesPerson, Branch)
        store = get_store_for_field(self)
        person_type = self.person_type
        if person_type == Supplier:
            objects = Supplier.get_active_suppliers(store)
            self.add_button.set_tooltip_text(_("Add a new supplier"))
            self.edit_button.set_tooltip_text(_("Edit the selected supplier"))
        elif person_type == Client:
            objects = Client.get_active_clients(store)
            self.add_button.set_tooltip_text(_("Add a new client"))
            self.edit_button.set_tooltip_text(_("Edit the selected client"))
        elif person_type == Transporter:
            objects = Transporter.get_active_transporters(store)
            self.add_button.set_tooltip_text(_("Add a new transporter"))
            self.edit_button.set_tooltip_text(_("Edit the selected transporter"))
        elif person_type == SalesPerson:
            objects = SalesPerson.get_active_salespersons(store)
            self.add_button.set_tooltip_text(_("Add a new sales person"))
            self.edit_button.set_tooltip_text(_("Edit the selected sales person"))
        elif person_type == Branch:
            objects = Branch.get_active_branches(store)
            self.add_button.set_tooltip_text(_("Add a new branch"))
            self.edit_button.set_tooltip_text(_("Edit the selected branch"))
        else:
            raise AssertionError(self.person_type)

        self.widget.prefill(api.for_person_combo(objects))

        if person:
            assert isinstance(person, person_type)
            self.widget.select(person)
Esempio n. 2
0
    def populate(self, person):
        from stoqlib.domain.person import (Client, Supplier, Transporter,
                                           SalesPerson, Branch)
        store = get_store_for_field(self)
        person_type = self.person_type
        if person_type == Supplier:
            objects = Supplier.get_active_suppliers(store)
            self.add_button.set_tooltip_text(_("Add a new supplier"))
            self.edit_button.set_tooltip_text(_("Edit the selected supplier"))
        elif person_type == Client:
            objects = Client.get_active_clients(store)
            self.add_button.set_tooltip_text(_("Add a new client"))
            self.edit_button.set_tooltip_text(_("Edit the selected client"))
        elif person_type == Transporter:
            objects = Transporter.get_active_transporters(store)
            self.add_button.set_tooltip_text(_("Add a new transporter"))
            self.edit_button.set_tooltip_text(
                _("Edit the selected transporter"))
        elif person_type == SalesPerson:
            objects = SalesPerson.get_active_salespersons(store)
            self.add_button.set_tooltip_text(_("Add a new sales person"))
            self.edit_button.set_tooltip_text(
                _("Edit the selected sales person"))
        elif person_type == Branch:
            objects = Branch.get_active_branches(store)
            self.add_button.set_tooltip_text(_("Add a new branch"))
            self.edit_button.set_tooltip_text(_("Edit the selected branch"))
        else:
            raise AssertionError(self.person_type)

        self.widget.prefill(api.for_person_combo(objects))

        if person:
            assert isinstance(person, person_type)
            self.widget.select(person)
Esempio n. 3
0
 def _fill_supplier_combo(self):
     suppliers = Supplier.get_active_suppliers(self.store)
     self.edit_supplier.set_sensitive(any(suppliers))
     self.supplier.prefill(api.for_person_combo(suppliers))
Esempio n. 4
0
 def _fill_supplier_combo(self):
     suppliers = Supplier.get_active_suppliers(self.store)
     self.supplier.prefill(api.for_person_combo(suppliers))
Esempio n. 5
0
 def get_targets(self):
     suppliers = Supplier.get_active_suppliers(self.store)
     return api.for_person_combo(suppliers)
Esempio n. 6
0
 def get_targets(self):
     suppliers = Supplier.get_active_suppliers(self.store)
     return api.for_person_combo(suppliers)
Esempio n. 7
0
 def test_get_active_suppliers(self):
     for supplier in Supplier.get_active_suppliers(self.store):
         self.assertEquals(supplier.status, Supplier.STATUS_ACTIVE)
Esempio n. 8
0
 def _fill_supplier_combo(self):
     suppliers = Supplier.get_active_suppliers(self.store)
     self.supplier.prefill(api.for_person_combo(suppliers))
Esempio n. 9
0
 def test_get_active_suppliers(self):
     for supplier in Supplier.get_active_suppliers(self.store):
         self.assertEquals(supplier.status,
                           Supplier.STATUS_ACTIVE)