コード例 #1
0
ファイル: parameters.py プロジェクト: rosalin/stoq
def _credit_limit_salary_changed(new_value, store):
    from stoqlib.domain.person import Client

    old_value = sysparam(store).CREDIT_LIMIT_SALARY_PERCENT
    if new_value == old_value:
        return

    new_value = Decimal(new_value)
    Client.update_credit_limit(new_value, store)
コード例 #2
0
ファイル: parameters.py プロジェクト: esosaja/stoq
def _credit_limit_salary_changed(new_value, store):
    from stoqlib.domain.person import Client

    old_value = sysparam.get_decimal('CREDIT_LIMIT_SALARY_PERCENT')
    if new_value == old_value:
        return

    new_value = Decimal(new_value)
    Client.update_credit_limit(new_value, store)
コード例 #3
0
    def _create_client(self, store):
        from stoqlib.domain.address import Address, CityLocation
        from stoqlib.domain.person import Client, Person

        person = Person(name=u'Person', store=store)
        city = CityLocation.get_default(store)
        Address(store=store,
                street=u'Rua Principal',
                streetnumber=123,
                postal_code=u'12345-678',
                is_main_address=True,
                person=person,
                city_location=city)
        client = Client(person=person, store=store)
        client.credit_limit = currency("1000")
        return client
コード例 #4
0
ファイル: fields.py プロジェクト: romaia/stoq
    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)
コード例 #5
0
ファイル: fields.py プロジェクト: tmaxter/stoq
    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)
コード例 #6
0
 def _fill_clients_combo(self):
     # FIXME: This should not be using a normal ProxyComboEntry,
     #        we need a specialized widget that does the searching
     #        on demand.
     clients = Client.get_active_clients(self.store)
     self.client.prefill(api.for_person_combo(clients))
     self.client.mandatory = True
コード例 #7
0
ファイル: loanwizard.py プロジェクト: qman1989/stoq
 def _fill_clients_combo(self):
     # FIXME: This should not be using a normal ProxyComboEntry,
     #        we need a specialized widget that does the searching
     #        on demand.
     items = Client.get_active_items(self.store)
     self.client.prefill(items)
     self.client.mandatory = True
コード例 #8
0
ファイル: test_pos.py プロジェクト: amaurihamasu/stoq
    def _create_client(self, store):
        from stoqlib.domain.address import Address, CityLocation
        from stoqlib.domain.person import Client, Person

        person = Person(name=u'Person', store=store)
        city = CityLocation.get_default(store)
        Address(store=store,
                street=u'Rua Principal',
                streetnumber=123,
                postal_code=u'12345-678',
                is_main_address=True,
                person=person,
                city_location=city)
        client = Client(person=person, store=store)
        client.credit_limit = currency("1000")
        return client
コード例 #9
0
ファイル: clientimporter.py プロジェクト: 5l1v3r1/stoq-1
    def process_one(self, data, fields, store):
        person = Person(
            store=store,
            name=data.name,
            phone_number=data.phone_number,
            mobile_number=data.mobile_number)

        Individual(person=person,
                   store=store,
                   cpf=data.cpf,
                   rg_number=data.rg)

        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
        )

        Client(person=person, store=store)
コード例 #10
0
    def test_update_credit_limit(self):
        client = self.create_client()
        client.salary = 100

        # just setting paramater to a value that won't interfere in
        # the tests
        sysparam(self.store).update_parameter(u"CREDIT_LIMIT_SALARY_PERCENT",
                                              u"5")

        # testing if updates
        Client.update_credit_limit(10, self.store)
        client.credit_limit = AutoReload
        self.assertEquals(client.credit_limit, 10)

        # testing if it does not update
        client.credit_limit = 200
        Client.update_credit_limit(0, self.store)
        self.assertEquals(client.credit_limit, 200)
コード例 #11
0
    def create_client(cls, store, name, cpf, address=None):
        # TODO: Add phone number
        person = Person(name=name, store=store)
        Individual(cpf=cpf, person=person, store=store)
        if address:
            cls.create_address(person, address)

        client = Client(person=person, store=store)
        return client
コード例 #12
0
 def test_generated_file_with_individual(self):
     individual = self.create_individual()
     individual.cpf = u'123.123.123-23'
     client = Client(person=individual.person, store=self.store)
     self._create_address(individual.person,
                          street=u"Rua dos Tomates",
                          streetnumber=2666,
                          postal_code=u'87654-321')
     self._test_generated_files(client)
コード例 #13
0
    def _fill_clients_combo(self):
        marker('Filling clients')
        # FIXME: This should not be using a normal ProxyComboEntry,
        #        we need a specialized widget that does the searching
        #        on demand.

        clients = Client.get_active_clients(self.store)
        self.client.prefill(api.for_person_combo(clients))
        self.client.set_sensitive(len(self.client.get_model()))
        marker('Filled clients')
コード例 #14
0
ファイル: test_person.py プロジェクト: rosalin/stoq
    def test_update_credit_limit(self):
        client = self.create_client()
        client.salary = 100

        # just setting paramater to a value that won't interfere in
        # the tests
        sysparam(self.store).update_parameter(
            u"CREDIT_LIMIT_SALARY_PERCENT",
            u"5")

        # testing if updates
        Client.update_credit_limit(10, self.store)
        client.credit_limit = AutoReload
        self.assertEquals(client.credit_limit, 10)

        # testing if it does not update
        client.credit_limit = 200
        Client.update_credit_limit(0, self.store)
        self.assertEquals(client.credit_limit, 200)
コード例 #15
0
    def _fill_clients_combo(self):
        # FIXME: This should not be using a normal ProxyComboEntry,
        #        we need a specialized widget that does the searching
        #        on demand.

        items = Client.get_active_items(self.store)
        self.client.prefill(items)

        # TODO: Implement a has_items() in kiwi
        self.client.set_sensitive(len(self.client.get_model()))
コード例 #16
0
    def test_generated_file_with_company(self):
        company = self.create_company()
        company.cnpj = u'123.456.789/1234-00'
        client = Client(person=company.person, store=self.store)
        self._create_address(company.person,
                             street=u"Rua dos Tomates",
                             streetnumber=2666,
                             postal_code=u'87654-321')

        self._test_generated_files(client)
コード例 #17
0
ファイル: salewizard.py プロジェクト: romaia/stoq
    def _fill_clients_combo(self):
        marker('Filling clients')
        # FIXME: This should not be using a normal ProxyComboEntry,
        #        we need a specialized widget that does the searching
        #        on demand.

        clients = Client.get_active_clients(self.store)
        self.client.prefill(api.for_person_combo(clients))
        self.client.set_sensitive(len(self.client.get_model()))
        marker('Filled clients')
コード例 #18
0
    def _fill_clients_combo(self):
        # FIXME: This should not be using a normal ProxyComboEntry,
        #        we need a specialized widget that does the searching
        #        on demand.

        # This is to keep the clients in cache
        clients_cache = list(Client.get_active_clients(self.store))
        clients_cache  # pyflakes

        # We are using ClientView here to show the fancy name as well
        clients = ClientView.get_active_clients(self.store)
        items = [(c.get_description(), c.client) for c in clients]
        items = locale_sorted(items, key=operator.itemgetter(0))
        self.client.prefill(items)

        # TODO: Implement a has_items() in kiwi
        self.client.set_sensitive(len(self.client.get_model()))
コード例 #19
0
ファイル: salequotewizard.py プロジェクト: rosalin/stoq
    def _fill_clients_combo(self):
        # FIXME: This should not be using a normal ProxyComboEntry,
        #        we need a specialized widget that does the searching
        #        on demand.

        # This is to keep the clients in cache
        clients_cache = list(Client.get_active_clients(self.store))
        clients_cache  # pyflakes

        # We are using ClientView here to show the fancy name as well
        clients = ClientView.get_active_clients(self.store)
        items = [(c.get_description(), c.client) for c in clients]
        items = locale_sorted(items, key=operator.itemgetter(0))
        self.client.prefill(items)

        # TODO: Implement a has_items() in kiwi
        self.client.set_sensitive(len(self.client.get_model()))
コード例 #20
0
    def _update_sale_client(self):
        """Update the sale client based on the informed document

        If the sale does not have a client yet, and the current_document (informed by
        the ecf plugin) is set, and a person with the given document exists, that client
        will be associated with this sale.
        """
        if self.model.client or not self.wizard._current_document:
            return

        person = Person.get_by_document(self.store,
                                        str(self.wizard._current_document))
        if not person:
            return

        if person.client:
            self.model.client = person.client
        else:
            self.model.client = Client(store=self.store, person=person)
コード例 #21
0
    def _create_examples(self):
        person = Person(name=u'Jonas', store=self.store)
        Individual(person=person, store=self.store)
        role = EmployeeRole(store=self.store, name=u'desenvolvedor')
        Employee(person=person, store=self.store,
                 role=role)
        self.salesperson = SalesPerson(person=person,
                                       store=self.store)
        Company(person=person, store=self.store)
        client = Client(person=person, store=self.store)
        self.branch = Branch(person=person, store=self.store)

        group = self.create_payment_group()
        self.sale = Sale(coupon_id=123, client=client,
                         cfop_id=self.sparam.get_object_id('DEFAULT_SALES_CFOP'),
                         group=group, branch=self.branch,
                         salesperson=self.salesperson,
                         store=self.store)

        self.storable = self.create_storable()
コード例 #22
0
ファイル: saleeditor.py プロジェクト: leandrodax/stoq
 def _fill_clients_combo(self):
     items = Client.get_active_items(self.store)
     self.client.prefill(items)
     self.client.set_sensitive(len(self.client.get_model()))
コード例 #23
0
 def _fill_clients_combo(self):
     clients = Client.get_active_clients(self.store)
     self.client.prefill(api.for_person_combo(clients))
コード例 #24
0
 def create_client(self, name=u'Client'):
     from stoqlib.domain.person import Client, Individual, Person
     person = Person(name=name, store=self.store)
     Individual(person=person, store=self.store)
     return Client(person=person, store=self.store)
コード例 #25
0
ファイル: saleeditor.py プロジェクト: barkinet/stoq
 def _fill_clients_combo(self):
     items = Client.get_active_items(self.store)
     self.client.prefill(items)
     self.client.set_sensitive(len(self.client.get_model()))
コード例 #26
0
 def _fill_clients_combo(self):
     items = Client.get_active_items(self.store)
     self.client.prefill(items)
コード例 #27
0
ファイル: workordereditor.py プロジェクト: LeonamSilva/stoq
 def _fill_clients_combo(self):
     clients = Client.get_active_clients(self.store)
     self.client.prefill(api.for_person_combo(clients))
コード例 #28
0
ファイル: personeditor.py プロジェクト: tmaxter/stoq
 def create_model(self, store):
     person = BasePersonRoleEditor.create_model(self, store)
     client = person.client
     if client is None:
         client = Client(person=person, store=store)
     return client