コード例 #1
0
ファイル: personeditor.py プロジェクト: tmaxter/stoq
    def create_model(self, store):
        person = BasePersonRoleEditor.create_model(self, store)
        branch = person.branch
        if branch is None:
            branch = Branch(person=person, store=store)

        return branch
コード例 #2
0
def _provide_current_station(station_name=None, branch_name=None):
    if not station_name:
        station_name = get_hostname()
    store = new_store()
    if branch_name:
        branch = store.find(
            Person,
            And(Person.name == branch_name,
                Branch.person_id == Person.id)).one()
    else:
        branches = store.find(Branch)
        if branches.count() == 0:
            person = Person(name=u"test", store=store)
            branch = Branch(person=person, store=store)
        else:
            branch = branches[0]

    provide_utility(ICurrentBranch, branch)

    station = BranchStation.get_station(store, branch, station_name)
    if not station:
        station = BranchStation.create(store, branch, station_name)

    assert station
    assert station.is_active

    provide_utility(ICurrentBranchStation, station)
    store.commit(close=True)
コード例 #3
0
ファイル: branchimporter.py プロジェクト: 5l1v3r1/stoq-1
    def process_one(self, data, fields, store):
        person = Person(store=store,
                        name=data.name,
                        phone_number=data.phone_number,
                        fax_number=data.fax_number)

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

        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,
                postal_code=data.postal_code)

        branch = Branch(person=person, store=store)
        for user in store.find(LoginUser):
            user.add_access_to(branch)
        self.branches.append(branch)
コード例 #4
0
 def test_getactive_branches(self):
     person = self.create_person()
     Company(person=person, store=self.store)
     count = Branch.get_active_branches(self.store).count()
     manager = self.create_employee()
     branch = Branch(person=person,
                     store=self.store,
                     manager=manager,
                     is_active=True)
     assert branch.get_active_branches(self.store).count() == count + 1
コード例 #5
0
 def create_branch(self, name=u'Dummy', phone_number=u'12345678',
                   fax_number=u'87564321'):
     from stoqlib.domain.person import Branch, Company, Person
     person = Person(name=name, phone_number=phone_number,
                     fax_number=fax_number, store=self.store)
     self.create_address(person=person)
     fancy_name = name + u' shop'
     Company(person=person, fancy_name=fancy_name,
             store=self.store)
     return Branch(person=person, store=self.store)
コード例 #6
0
def create_main_branch(store, name):
    """Creates a new branch and sets it as the main branch for the system
    :param store: a store
    :param name: name of the new branch
    """
    person = Person(name=name, store=store)
    Company(person=person, store=store)
    branch = Branch(person=person, store=store)

    sysparam.set_object(store, 'MAIN_COMPANY', branch)

    provide_utility(ICurrentBranch, branch)
    admin = get_admin_user(store)
    admin.add_access_to(branch)

    return branch
コード例 #7
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()