Example #1
0
    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)
    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,
                                               quantity=item.quantity,
                                               batch=item.batch)
            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)
Example #3
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)
Example #4
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)
Example #5
0
    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()
Example #6
0
    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()
Example #7
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)
Example #8
0
    def finish(self):
        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 = TransferOrderItem(store=self.store,
                                              transfer_order=order,
                                              sellable=item.sellable,
                                              quantity=item.quantity)
            order.send_item(transfer_item)
        #XXX Waiting for transfer order receiving wizard implementation
        order.receive()

        self.retval = self.model
        self.close()
        StockTransferWizardFinishEvent.emit(order)
        self._receipt_dialog(order)
Example #9
0
    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)
Example #10
0
    def _create_pending_info_message(self):
        branch = api.get_current_branch(self.store)
        n_transfers = TransferOrder.get_pending_transfers(self.store, branch).count()

        if not n_transfers:
            return None

        msg = stoqlib_ngettext(_(u"You have %s incoming transfer"),
                               _(u"You have %s incoming transfers"),
                               n_transfers) % n_transfers
        info_bar = self.window.add_info_bar(Gtk.MessageType.QUESTION, msg)
        button = info_bar.add_button(_(u"Receive"), Gtk.ResponseType.OK)
        button.connect('clicked', self._on_info_transfers__clicked)

        return info_bar
Example #11
0
    def _create_pending_info_message(self):
        branch = api.get_current_branch(self.store)
        n_transfers = TransferOrder.get_pending_transfers(self.store, branch).count()

        if not n_transfers:
            return None

        msg = stoqlib_ngettext(_(u"You have %s incoming transfer"),
                               _(u"You have %s incoming transfers"),
                               n_transfers) % n_transfers
        info_bar = self.window.add_info_bar(gtk.MESSAGE_QUESTION, msg)
        button = info_bar.add_button(_(u"Receive"), gtk.RESPONSE_OK)
        button.connect('clicked', self._on_info_transfers__clicked)

        return info_bar
Example #12
0
    def _search_transfers(self):
        branch = api.get_current_branch(self.store)
        self.run_dialog(TransferOrderSearch, self.store)

        if self.transfers_bar:
            n_transfers = TransferOrder.get_pending_transfers(self.store, branch).count()

            if n_transfers > 0:
                msg = stoqlib_ngettext(_(u"You have %s incoming transfer"),
                                       _(u"You have %s incoming transfers"),
                                       n_transfers) % n_transfers
                self.transfers_bar.set_message(msg)
            else:
                self.transfers_bar.hide()
        self.refresh()
Example #13
0
    def _search_transfers(self):
        branch = api.get_current_branch(self.store)
        self.run_dialog(TransferOrderSearch, self.store)

        # After the search is closed we may want to update , or even hide the
        # message, if there is no pending transfer to receive
        if self.transfers_bar:
            n_transfers = TransferOrder.get_pending_transfers(self.store, branch).count()

            if n_transfers > 0:
                msg = stoqlib_ngettext(_(u"You have %s incoming transfer"),
                                       _(u"You have %s incoming transfers"),
                                       n_transfers) % n_transfers
                self.transfers_bar.set_message(msg)
            else:
                self.transfers_bar.hide()
        self.refresh()
Example #14
0
    def _search_transfers(self):
        branch = api.get_current_branch(self.store)
        self.run_dialog(TransferOrderSearch, self.store)

        # After the search is closed we may want to update , or even hide the
        # message, if there is no pending transfer to receive
        if self.transfers_bar:
            n_transfers = TransferOrder.get_pending_transfers(self.store, branch).count()

            if n_transfers > 0:
                msg = stoqlib_ngettext(_(u"You have %s incoming transfer"),
                                       _(u"You have %s incoming transfers"),
                                       n_transfers) % n_transfers
                self.transfers_bar.set_message(msg)
            else:
                self.transfers_bar.hide()
        self.refresh()