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 ) order.send_item(transfer_item) order.receive()
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)