Example #1
0
 def _fill_transporter_combo(self):
     marker('Filling transporters')
     transporters = Transporter.get_active_transporters(self.store)
     items = api.for_person_combo(transporters)
     self.transporter.prefill(items)
     self.transporter.set_sensitive(len(items))
     marker('Filled transporters')
Example #2
0
 def _fill_transporter_combo(self):
     marker('Filling transporters')
     transporters = Transporter.get_active_transporters(self.store)
     items = api.for_person_combo(transporters)
     self.transporter.prefill(items)
     self.transporter.set_sensitive(len(items))
     marker('Filled transporters')
Example #3
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)
Example #4
0
    def process_one(self, data, fields, store):
        person = Person(store=store,
                        name=data.name,
                        phone_number=data.phone_number,
                        mobile_number=data.mobile_number)

        Company(person=person,
                store=store,
                cnpj=data.cnpj,
                fancy_name=data.name,
                state_registry=data.state_registry)

        ctloc = CityLocation.get_or_create(store=store,
                                           city=data.city,
                                           state=data.state,
                                           country=data.country)
        streetnumber = data.streetnumber and int(data.streetnumber) or None
        Address(is_main_address=True,
                person=person,
                city_location=ctloc,
                store=store,
                street=data.street,
                streetnumber=streetnumber,
                district=data.district)

        Transporter(person=person,
                    open_contract_date=self.parse_date(data.open_contract),
                    freight_percentage=decimal.Decimal(
                        data.freight_percentage),
                    store=store)
Example #5
0
 def create_model(self, store):
     person = BasePersonRoleEditor.create_model(self, store)
     transporter = person.transporter
     if transporter is None:
         transporter = Transporter(person=person,
                                   store=store)
     return transporter
Example #6
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)
Example #7
0
    def _setup_transporter_entry(self):
        self.add_transporter.set_tooltip_text(_("Add a new transporter"))
        self.edit_transporter.set_tooltip_text(_("Edit the selected transporter"))

        items = Transporter.get_active_transporters(self.store)
        self.transporter.prefill(api.for_person_combo(items))
        self.transporter.set_sensitive(not items.is_empty())
        self.edit_transporter.set_sensitive(not items.is_empty())
Example #8
0
 def _setup_transporter_entry(self):
     transporters = Transporter.get_active_transporters(self.store)
     self.transporter.prefill(api.for_combo(transporters))
Example #9
0
 def test_get_active_transporters(self):
     count = Transporter.get_active_transporters(self.store).count()
     transporter = self.create_transporter()
     one_more = transporter.get_active_transporters(self.store).count()
     self.assertEqual(count + 1, one_more)
Example #10
0
 def _setup_transporter_entry(self):
     transporters = Transporter.get_active_transporters(self.store)
     self.transporter.prefill(api.for_combo(transporters))
Example #11
0
 def test_get_active_transporters(self):
     count = Transporter.get_active_transporters(self.store).count()
     transporter = self.create_transporter()
     one_more = transporter.get_active_transporters(self.store).count()
     self.assertEqual(count + 1, one_more)
Example #12
0
 def create_transporter(self, name=u'John'):
     from stoqlib.domain.person import Company, Transporter
     person = self.create_person(name)
     Company(person=person, store=self.store)
     return Transporter(person=person, store=self.store)