コード例 #1
0
 def create_transfer(self):
     from stoqlib.domain.transfer import TransferOrder
     return TransferOrder(source_branch=self.create_branch(),
                          destination_branch=self.create_branch(),
                          source_responsible=self.create_employee(),
                          destination_responsible=self.create_employee(),
                          store=self.store)
コード例 #2
0
ファイル: stocktransferwizard.py プロジェクト: tmaxter/stoq
    def finish(self):
        missing = get_missing_items(self.model, self.store)
        if missing:
            run_dialog(MissingItemsDialog, self, self.model, missing)
            return False

        order = TransferOrder(
            open_date=self.model.open_date,
            receival_date=self.model.receival_date,
            source_branch=self.model.source_branch,
            destination_branch=self.model.destination_branch,
            source_responsible=self.model.source_responsible,
            destination_responsible=self.model.destination_responsible,
            store=self.store)
        for item in self.model.get_items():
            transfer_item = order.add_sellable(item.sellable, batch=None,
                                               quantity=item.quantity)
            transfer_item.send()

        # XXX Waiting for transfer order receiving wizard implementation
        order.receive()

        self.retval = self.model
        self.close()
        StockTransferWizardFinishEvent.emit(order)
        self._receipt_dialog(order)
コード例 #3
0
 def _create_model(self, store):
     user = api.get_current_user(store)
     source_responsible = store.find(Employee, person=user.person).one()
     return TransferOrder(
         source_branch=api.get_current_branch(store),
         source_responsible=source_responsible,
         destination_branch=Branch.get_active_remote_branches(store)[0],
         store=store)
コード例 #4
0
 def create_transfer_order(self, source_branch=None, dest_branch=None):
     from stoqlib.domain.transfer import TransferOrder
     source_branch = source_branch or self.create_branch(u"Source")
     dest_branch = dest_branch or self.create_branch(u"Dest")
     source_resp = self.create_employee(u"Ipswich")
     dest_resp = self.create_employee(u"Bolton")
     return TransferOrder(source_branch=source_branch,
                          destination_branch=dest_branch,
                          source_responsible=source_resp,
                          destination_responsible=dest_resp,
                          store=self.store)
コード例 #5
0
ファイル: transferimporter.py プロジェクト: 5l1v3r1/stoq-1
    def process_one(self, data, fields, store):
        person = store.find(Person, name=data.source_branch_name).one()
        if person is None or person.branch is None:
            raise ValueError("%s is not a valid branch" %
                             (data.source_branch_name, ))
        source_branch = person.branch

        person = store.find(Person, name=data.source_employee_name).one()
        if person is None or person.employee is None:
            raise ValueError("%s is not a valid employee" %
                             (data.source_employee_name, ))
        source_employee = person.employee

        person = store.find(Person, name=data.dest_branch_name).one()
        if person is None or person.branch is None:
            raise ValueError("%s is not a valid branch" %
                             (data.dest_branch_name, ))
        dest_branch = person.branch

        person = store.find(Person, name=data.dest_employee_name).one()
        if person is None or person.employee is None:
            raise ValueError("%s is not a valid employee" %
                             (data.dest_employee_name, ))
        dest_employee = person.employee

        station = store.find(BranchStation).any()
        user = store.find(LoginUser).any()
        sellables = self.parse_multi(Sellable, data.sellable_list, store)

        order = TransferOrder(store=store,
                              open_date=self.parse_date(data.open_date),
                              receival_date=None,
                              branch=source_branch,
                              station=station,
                              destination_branch=dest_branch,
                              source_responsible=source_employee,
                              destination_responsible=None)

        for sellable in sellables:
            if not sellable.product:
                continue
            order.add_sellable(sellable,
                               batch=None,
                               quantity=int(data.quantity))

        order.send(user)
        order.receive(user, dest_employee)
コード例 #6
0
ファイル: transferimporter.py プロジェクト: tmaxter/stoq
    def process_one(self, data, fields, store):
        person = store.find(Person, name=data.source_branch_name).one()
        if person is None or person.branch is None:
            raise ValueError("%s is not a valid branch" %
                             (data.source_branch_name, ))
        source_branch = person.branch

        person = store.find(Person, name=data.source_employee_name).one()
        if person is None or person.employee is None:
            raise ValueError("%s is not a valid employee" %
                             (data.source_employee_name, ))
        source_employee = person.employee

        person = store.find(Person, name=data.dest_branch_name).one()
        if person is None or person.branch is None:
            raise ValueError("%s is not a valid branch" %
                             (data.dest_branch_name, ))
        dest_branch = person.branch

        person = store.find(Person, name=data.dest_employee_name).one()
        if person is None or person.employee is None:
            raise ValueError("%s is not a valid employee" %
                             (data.dest_employee_name, ))
        dest_employee = person.employee

        sellables = self.parse_multi(Sellable, data.sellable_list, store)

        order = TransferOrder(store=store,
                              open_date=self.parse_date(data.open_date),
                              receival_date=self.parse_date(
                                  data.receival_date),
                              source_branch=source_branch,
                              destination_branch=dest_branch,
                              source_responsible=source_employee,
                              destination_responsible=dest_employee)

        for sellable in sellables:
            if not sellable.product:
                continue
            transfer_item = TransferOrderItem(store=store,
                                              quantity=int(data.quantity),
                                              sellable=sellable,
                                              transfer_order=order)
            transfer_item.send()

        order.receive()