Beispiel #1
0
    def update_total(self):
        SellableItemStep.update_total(self)
        quantities = {}
        missing = {}
        lead_time = 0
        for i in self.slave.klist:
            sellable = i.sellable
            if sellable.service or not sellable.product.manage_stock:
                continue

            quantities.setdefault(sellable, 0)
            quantities[sellable] += i.quantity
            # This was already removed from stock, so we need to ignore it.
            if hasattr(i, 'quantity_decreased'):
                quantities[sellable] -= i.quantity_decreased

            if quantities[sellable] > i._stock_quantity:
                _lead_time = sellable.product.get_max_lead_time(
                    quantities[sellable], self.model.branch)
                max_lead_time = max(lead_time, _lead_time)
                missing[sellable] = Settable(
                    description=sellable.get_description(),
                    stock=i._stock_quantity,
                    ordered=quantities[sellable],
                    lead_time=_lead_time,
                )
        self.missing = missing

        if missing:
            msg = _('Not enough stock. '
                    'Estimated time to obtain missing items: %d days.') % max_lead_time
            self.slave.set_message(
                '<b>%s</b>' % (api.escape(msg)), self._show_missing_details)
        else:
            self.slave.clear_message()
Beispiel #2
0
 def setup_slaves(self):
     SellableItemStep.setup_slaves(self)
     self.hide_add_button()
     self.cost.set_editable(True)
     self.quantity.connect('validate', self._on_quantity__validate)
     self.slave.klist.connect('selection-changed',
                              self._on_klist_selection_changed)
Beispiel #3
0
    def setup_slaves(self):
        SellableItemStep.setup_slaves(self)
        self.hide_add_button()
        self.cost_label.set_label(_('Price:'))
        self.cost.set_editable(True)

        delivery = self._find_delivery()
        if delivery is not None:
            self._delivery_item = delivery.service_item
            self._delivery = CreateDeliveryModel.from_delivery(delivery)
        else:
            self._delivery = None
            self._delivery_item = None

        if isinstance(self.model, Sale):
            self.delivery_btn = self.slave.add_extra_button(label=_("Add delivery"))
            self.delivery_btn.set_sensitive(bool(len(self.slave.klist)))
        else:
            self.delivery_btn = None

        self.discount_btn = self.slave.add_extra_button(label=_("Apply discount"))
        self.discount_btn.set_sensitive(bool(len(self.slave.klist)))
        self.slave.klist.connect('has-rows', self._on_klist__has_rows)
        self.slave.klist.connect('selection-changed',
                                 self._on_klist__selection_changed)
Beispiel #4
0
 def sellable_selected(self, sellable, batch=None):
     # We may receive a batch if the user typed a batch number instead of a
     # product code, but we pass batch=None here since the user must select
     # the batch when confirming a sale.
     SellableItemStep.sellable_selected(self, sellable, batch=None)
     if sellable:
         price = sellable.get_price_for_category(self.model.client_category)
         self.cost.update(price)
    def sellable_selected(self, sellable, batch=None):
        SellableItemStep.sellable_selected(self, sellable, batch=batch)

        if sellable is None or not sellable.product.manage_stock:
            return

        storable = sellable.product_storable
        # FIXME: We should not have to override this method. This should
        # be done automatically on SellableItemStep
        self.stock_quantity.set_label(
            "%s" % storable.get_balance_for_branch(branch=self.model.branch))
Beispiel #6
0
    def setup_slaves(self):
        SellableItemStep.setup_slaves(self)
        self._delivery = None
        self._delivery_item = None

        self.delivery_button = self.slave.add_extra_button(
            label=_("Add Delivery"))
        self.delivery_button.set_sensitive(bool(len(self.slave.klist)))

        self.slave.klist.connect('has_rows', self._on_klist__has_rows)
        self.delivery_button.connect('clicked',
                                     self._on_delivery_button__clicked)
Beispiel #7
0
    def add_sellable(self, sellable, parent=None, reset_proxy=True):
        price = sellable.get_price_for_category(self.model.client_category)
        new_price = self.cost.read()

        # Percentage of discount
        discount = 100 - new_price * 100 / price

        if discount > 0 and self.manager:
            Event.log_sale_item_discount(
                store=self.store,
                sale_number=self.model.identifier,
                user_name=self.manager.username,
                discount_value=discount,
                product=sellable.description,
                original_price=price,
                new_price=new_price)

        SellableItemStep.add_sellable(self, sellable, parent=parent,
                                      reset_proxy=reset_proxy)
        self.update_total()
Beispiel #8
0
 def validate(self, value):
     SellableItemStep.validate(self, value)
     can_purchase = self.model.purchase_total > 0
     self.wizard.refresh_next(value and can_purchase)
Beispiel #9
0
 def sellable_selected(self, sellable, batch=None):
     SellableItemStep.sellable_selected(self, sellable, batch=batch)
     if sellable:
         self.cost.update(sellable.price)
    def post_init(self):
        self.hide_add_button()

        SellableItemStep.post_init(self)
 def setup_slaves(self):
     SellableItemStep.setup_slaves(self)
 def __init__(self, wizard, previous, store, model):
     manager = get_plugin_manager()
     nfe_is_active = manager.is_active('nfe')
     if nfe_is_active:
         self.cost_editable = True
     SellableItemStep.__init__(self, wizard, previous, store, model)
Beispiel #13
0
 def setup_slaves(self):
     SellableItemStep.setup_slaves(self)
     self.hide_add_button()
     self.cost_label.hide()
     self.cost.hide()
Beispiel #14
0
 def setup_slaves(self):
     SellableItemStep.setup_slaves(self)
     self.item_lbl.set_text(_(u'Services:'))
     self.hide_add_button()
     self.cost_label.hide()
     self.cost.hide()