示例#1
0
    def _create_receiving_order(self):
        supplier_id = self.purchases[0].supplier_id
        branch_id = self.purchases[0].branch_id

        # If the receiving is for another branch, we need a temporary identifier
        temporary_identifier = None
        if (api.sysparam.get_bool('SYNCHRONIZED_MODE')
                and api.get_current_branch(self.store).id != branch_id):
            temporary_identifier = ReceivingOrder.get_temporary_identifier(
                self.store)

        # We cannot create the model in the wizard since we haven't
        # selected a PurchaseOrder yet which ReceivingOrder depends on
        # Create the order here since this is the first place where we
        # actually have a purchase selected
        receiving_invoice = ReceivingInvoice(supplier=supplier_id,
                                             store=self.store,
                                             branch=branch_id,
                                             responsible=api.get_current_user(
                                                 self.store))
        self.wizard.model = self.model = ReceivingOrder(
            identifier=temporary_identifier,
            receiving_invoice=receiving_invoice,
            responsible=receiving_invoice.responsible,
            invoice_number=None,
            branch=branch_id,
            store=self.store)

        for row in self.purchases:
            self.model.add_purchase(row.purchase)
示例#2
0
    def _create_receiving_order(self):
        # since we will create a new receiving order, we should confirm the
        # purchase first. Note that the purchase may already be confirmed
        if self.model.status in [PurchaseOrder.ORDER_PENDING,
                                 PurchaseOrder.ORDER_CONSIGNED]:
            self.model.confirm()

        temporary_identifier = None
        if self.wizard.is_for_another_branch():
            temporary_identifier = ReceivingOrder.get_temporary_identifier(self.store)

        receiving_invoice = ReceivingInvoice(
            store=self.store,
            supplier=self.model.supplier,
            branch=self.model.branch,
            responsible=api.get_current_user(self.store))
        receiving_model = ReceivingOrder(
            identifier=temporary_identifier,
            receiving_invoice=receiving_invoice,
            responsible=receiving_invoice.responsible,
            branch=self.model.branch,
            invoice_number=None,
            store=self.store)
        receiving_model.add_purchase(self.model)

        # Creates ReceivingOrderItem's
        for item in self.model.get_pending_items():
            receiving_model.add_purchase_item(item)

        self.wizard.receiving_model = receiving_model
示例#3
0
    def _create_receiving_order(self):
        # since we will create a new receiving order, we should confirm the
        # purchase first. Note that the purchase may already be confirmed
        if self.model.status in [
                PurchaseOrder.ORDER_PENDING, PurchaseOrder.ORDER_CONSIGNED
        ]:
            self.model.confirm(api.get_current_user(self.store))

        temporary_identifier = None
        if self.wizard.is_for_another_branch():
            temporary_identifier = ReceivingOrder.get_temporary_identifier(
                self.store)

        receiving_invoice = ReceivingInvoice(
            store=self.store,
            supplier=self.model.supplier,
            branch=self.model.branch,
            station=api.get_current_station(self.store),
            responsible=api.get_current_user(self.store))
        receiving_model = ReceivingOrder(
            identifier=temporary_identifier,
            receiving_invoice=receiving_invoice,
            responsible=receiving_invoice.responsible,
            branch=self.model.branch,
            station=api.get_current_station(self.store),
            invoice_number=None,
            store=self.store)
        receiving_model.add_purchase(self.model)

        # Creates ReceivingOrderItem's
        for item in self.model.get_pending_items():
            receiving_model.add_purchase_item(item)

        self.wizard.receiving_model = receiving_model
示例#4
0
    def _create_receiving_order(self):
        supplier_id = self.purchases[0].supplier_id
        branch_id = self.purchases[0].branch_id

        # If the receiving is for another branch, we need a temporary identifier
        temporary_identifier = None
        if (api.sysparam.get_bool('SYNCHRONIZED_MODE') and
                api.get_current_branch(self.store).id != branch_id):
            temporary_identifier = ReceivingOrder.get_temporary_identifier(self.store)

        # We cannot create the model in the wizard since we haven't
        # selected a PurchaseOrder yet which ReceivingOrder depends on
        # Create the order here since this is the first place where we
        # actually have a purchase selected
        receiving_invoice = ReceivingInvoice(
            supplier=supplier_id, store=self.store, branch=branch_id,
            responsible=api.get_current_user(self.store))
        self.wizard.model = self.model = ReceivingOrder(
            identifier=temporary_identifier,
            receiving_invoice=receiving_invoice,
            responsible=receiving_invoice.responsible,
            invoice_number=None, branch=branch_id, store=self.store)

        for row in self.purchases:
            self.model.add_purchase(row.purchase)