Beispiel #1
0
 def _set_expected_receival_date(self, item):
     supplier = self.model.supplier
     product = item.sellable.product
     supplier_info = ProductSupplierInfo.find_by_product_supplier(
         self.store, product, supplier, api.get_current_branch(self.store))
     if supplier_info is not None:
         delta = datetime.timedelta(days=supplier_info.lead_time)
         expected_receival = self.model.open_date + delta
         item.expected_receival_date = expected_receival
Beispiel #2
0
 def _set_expected_receival_date(self, item):
     supplier = self.model.supplier
     product = item.sellable.product
     supplier_info = ProductSupplierInfo.find_by_product_supplier(
         self.store, product, supplier)
     if supplier_info is not None:
         delta = datetime.timedelta(days=supplier_info.lead_time)
         expected_receival = self.model.open_date + delta
         item.expected_receival_date = expected_receival
Beispiel #3
0
 def _get_supplier_info(self):
     sellable = self.proxy.model.sellable
     if not sellable:
         # FIXME: We should not be accessing a private method here
         sellable, batch = self._get_sellable_and_batch()
     if not sellable:
         return
     product = sellable.product
     supplier = self.model.supplier
     return ProductSupplierInfo.find_by_product_supplier(
         self.store, product, supplier, api.get_current_branch(self.store))
Beispiel #4
0
 def _get_supplier_info(self):
     sellable = self.proxy.model.sellable
     if not sellable:
         # FIXME: We should not be accessing a private method here
         sellable, batch = self._get_sellable_and_batch()
     if not sellable:
         return
     product = sellable.product
     supplier = self.model.supplier
     return ProductSupplierInfo.find_by_product_supplier(
         self.store, product, supplier)
Beispiel #5
0
    def create_purchase(self, supplier, work_order_item, is_freebie,
                        branch: Branch, station: BranchStation,
                        user: LoginUser):
        """Create a purchase

        :param supplier: the |supplier| of that purchase
        :param work_order_item: The work order item that a purchase is being created
        for.
        :param is_freebie: indicates if the item is a freebie
        """
        sellable = work_order_item.sellable
        store = self.work_order.store
        purchase = PurchaseOrder(store=store,
                                 branch=branch,
                                 station=station,
                                 status=PurchaseOrder.ORDER_PENDING,
                                 supplier=supplier,
                                 responsible=user,
                                 work_order=self.work_order)
        if is_freebie:
            purchase.notes = _(
                'The product %s is a freebie') % sellable.description
            # FIXME We may want the cost 0, but as it is we wont be able to
            # receive this purchase without changing the receiving. We must
            # evaluate the consequences of changing the receiving a little bit
            # further in order to change that behavior.
            cost = decimal.Decimal('0.01')
        else:
            psi = ProductSupplierInfo.find_by_product_supplier(
                store, sellable.product, supplier, branch)
            cost = psi.base_cost if psi else sellable.cost

        # Add the sellable to the purchase
        purchase_item = purchase.add_item(sellable,
                                          quantity=work_order_item.quantity,
                                          cost=cost)
        work_order_item.purchase_item = purchase_item

        purchase.confirm(user)
        return purchase
Beispiel #6
0
    def create_purchase(self, supplier, work_order_item, is_freebie):
        """Create a purchase

        :param supplier: the |supplier| of that purchase
        :param work_order_item: The work order item that a purchase is being created
        for.
        :param is_freebie: indicates if the item is a freebie
        """
        sellable = work_order_item.sellable
        store = self.work_order.store
        current_branch = api.get_current_branch(store)
        purchase = PurchaseOrder(store=store,
                                 status=PurchaseOrder.ORDER_PENDING,
                                 supplier=supplier,
                                 responsible=api.get_current_user(store),
                                 branch=current_branch,
                                 work_order=self.work_order)
        if is_freebie:
            purchase.notes = _('The product %s is a freebie') % sellable.description
            # FIXME We may want the cost 0, but as it is we wont be able to
            # receive this purchase without changing the receiving. We must
            # evaluate the consequences of changing the receiving a little bit
            # further in order to change that behavior.
            cost = decimal.Decimal('0.01')
        else:
            psi = ProductSupplierInfo.find_by_product_supplier(store, sellable.product,
                                                               supplier)
            cost = psi.base_cost if psi else sellable.cost

        # Add the sellable to the purchase
        purchase_item = purchase.add_item(sellable,
                                          quantity=work_order_item.quantity,
                                          cost=cost)
        work_order_item.purchase_item = purchase_item

        purchase.confirm()
        return purchase