Esempio n. 1
0
    def post_init(self):
        # A receiving model was created. We should remove it (and its items),
        # since after this step we can either receive the products now or
        # later, on the stock application.
        receiving_model = self.wizard.receiving_model
        if receiving_model:
            for item in receiving_model.get_items():
                ReceivingOrderItem.delete(item.id, self.store)

            ReceivingOrder.delete(receiving_model.id, store=self.store)
            self.wizard.receiving_model = None

        self.salesperson_name.grab_focus()
        self._set_receival_date_suggestion()
        self.register_validate_function(self.wizard.refresh_next)
        self.force_validation()
Esempio n. 2
0
    def post_init(self):
        # A receiving model was created. We should remove it (and its items),
        # since after this step we can either receive the products now or
        # later, on the stock application.
        receiving_model = self.wizard.receiving_model
        if receiving_model:
            for item in receiving_model.get_items():
                ReceivingOrderItem.delete(item.id, self.store)

            ReceivingOrder.delete(receiving_model.id, store=self.store)
            self.wizard.receiving_model = None

        self.salesperson_name.grab_focus()
        self._set_receival_date_suggestion()
        self.register_validate_function(self.wizard.refresh_next)
        self.force_validation()
Esempio n. 3
0
    def finish(self):
        assert self.model
        assert self.model.branch

        # Remove the items that will not be received now.
        for item in self.model.get_items():
            if item.quantity > 0:
                continue
            ReceivingOrderItem.delete(item.id, store=self.store)

        if yesno(_(u'Do you want to print the labels for the received products?'),
                 gtk.RESPONSE_YES, _(u'Print labels'), _(u"Don't print")):
            label_data = run_dialog(SkipLabelsEditor, self, self.store)
            if label_data:
                print_labels(label_data, self.store, self.model.purchase)

        ReceivingOrderWizardFinishEvent.emit(self.model)

        self.retval = self.model
        self.model.confirm()
        self.close()
Esempio n. 4
0
    def finish(self):
        assert self.model
        assert self.model.branch

        # Remove the items that will not be received now.
        for item in self.model.get_items():
            if item.quantity > 0:
                continue
            ReceivingOrderItem.delete(item.id, store=self.store)

        if yesno(
                _(u'Do you want to print the labels for the received products?'
                  ), gtk.RESPONSE_YES, _(u'Print labels'), _(u"Don't print")):
            label_data = run_dialog(SkipLabelsEditor, self, self.store)
            if label_data:
                print_labels(label_data, self.store, self.model.purchase)

        ReceivingOrderWizardFinishEvent.emit(self.model)

        self.retval = self.model
        self.model.confirm()
        self.close()
Esempio n. 5
0
 def create_receiving_order_item(self, receiving_order=None, sellable=None,
                                 purchase_item=None, quantity=8):
     from stoqlib.domain.receiving import ReceivingOrderItem
     from stoqlib.domain.product import Storable
     if receiving_order is None:
         receiving_order = self.create_receiving_order()
     if sellable is None:
         sellable = self.create_sellable()
         product = sellable.product
         Storable(product=product, store=self.store)
     if purchase_item is None:
         purchase_item = receiving_order.purchase.add_item(
             sellable, quantity)
     return ReceivingOrderItem(store=self.store,
                               quantity=quantity, cost=125,
                               purchase_item=purchase_item,
                               sellable=sellable,
                               receiving_order=receiving_order)
Esempio n. 6
0
    def process_one(self, data, fields, store):
        person = store.find(Person, name=data.supplier_name).one()
        if person is None or person.supplier is None:
            raise ValueError(u"%s is not a valid supplier" %
                             (data.supplier_name, ))
        supplier = person.supplier

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

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

        login_user = store.find(LoginUser, username=u'admin').one()
        group = PaymentGroup(store=store)
        purchase = PurchaseOrder(store=store,
                                 status=PurchaseOrder.ORDER_PENDING,
                                 open_date=self.parse_date(data.due_date),
                                 supplier=supplier,
                                 transporter=transporter,
                                 group=group,
                                 responsible=get_current_user(store),
                                 branch=branch)

        for sellable in self.parse_multi(Sellable, data.sellable_list, store):
            if not sellable.product:
                continue
            PurchaseItem(store=store,
                         quantity=int(data.quantity),
                         base_cost=sellable.cost,
                         sellable=sellable,
                         order=purchase)

        method = PaymentMethod.get_by_name(store, data.payment_method)
        method.create_payment(Payment.TYPE_OUT, purchase.group, branch,
                              purchase.purchase_total,
                              self.parse_date(data.due_date))
        purchase.confirm()
        for payment in purchase.payments:
            payment.open_date = purchase.open_date

        receiving_order = ReceivingOrder(responsible=login_user,
                                         supplier=supplier,
                                         invoice_number=int(data.invoice),
                                         transporter=transporter,
                                         branch=branch,
                                         store=store)
        receiving_order.add_purchase(purchase)

        for purchase_item in purchase.get_items():
            ReceivingOrderItem(store=store,
                               cost=purchase_item.sellable.cost,
                               sellable=purchase_item.sellable,
                               quantity=int(data.quantity),
                               purchase_item=purchase_item,
                               receiving_order=receiving_order)
        receiving_order.confirm()