Ejemplo n.º 1
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(
                price=self._delivery_item.price,
                notes=self._delivery_item.notes,
                transporter=delivery.transporter,
                address=delivery.address,
                estimated_fix_date=self._delivery_item.estimated_fix_date)
        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)
Ejemplo n.º 2
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(
                price=self._delivery_item.price, notes=self._delivery_item.notes,
                transporter=delivery.transporter, address=delivery.address,
                estimated_fix_date=self._delivery_item.estimated_fix_date)
        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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
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
            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()
Ejemplo n.º 5
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
            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()
Ejemplo n.º 6
0
 def sellable_selected(self, sellable, batch=None):
     SellableItemStep.sellable_selected(self, sellable, batch=batch)
     if sellable:
         price = sellable.get_price_for_category(
             self.model.client_category)
         self.cost.set_text("%s" % price)
         self.proxy.update('cost')
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
    def setup_slaves(self):
        SellableItemStep.setup_slaves(self)
        self.hide_add_button()

        if not self.wizard.create_payments:
            self.cost_label.hide()
            self.cost.hide()
        self.quantity.connect('validate', self._on_quantity__validate)
Ejemplo n.º 9
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)
Ejemplo n.º 10
0
    def setup_slaves(self):
        SellableItemStep.setup_slaves(self)
        self.hide_add_button()
        self.cost_label.set_label(_('Price:'))
        self.cost.set_editable(True)

        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)
Ejemplo n.º 11
0
    def setup_slaves(self):
        SellableItemStep.setup_slaves(self)
        self.hide_add_button()
        self.cost_label.set_label(_('Price:'))
        self.cost.set_editable(True)

        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)
Ejemplo n.º 12
0
    def sellable_selected(self, sellable):
        SellableItemStep.sellable_selected(self, sellable)

        if sellable is None:
            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))
Ejemplo n.º 13
0
    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))
Ejemplo n.º 14
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)
Ejemplo n.º 15
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)
Ejemplo n.º 16
0
    def sellable_selected(self, sellable):
        SellableItemStep.sellable_selected(self, sellable)

        if sellable is None:
            return

        storable = sellable.product_storable
        stock_item = storable.get_stock_item(self.branch)
        self.stock_quantity.set_label("%s" % stock_item.quantity or 0)

        quantity = self._get_stock_balance(sellable)
        has_quantity = quantity > 0
        self.quantity.set_sensitive(has_quantity)
        self.add_sellable_button.set_sensitive(has_quantity)
        if has_quantity:
            self.quantity.set_range(1, quantity)
Ejemplo n.º 17
0
    def sellable_selected(self, sellable):
        SellableItemStep.sellable_selected(self, sellable)

        if sellable is None:
            return

        storable = sellable.product_storable
        # TODO: Add batch information here.
        stock_item = storable.get_stock_item(self.branch, batch=None)
        self.stock_quantity.set_label("%s" % stock_item.quantity or 0)

        quantity = self._get_stock_balance(sellable)
        has_quantity = quantity > 0
        self.quantity.set_sensitive(has_quantity)
        self.add_sellable_button.set_sensitive(has_quantity)
        if has_quantity:
            self.quantity.set_range(1, quantity)
Ejemplo n.º 18
0
    def add_sellable(self, sellable):
        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)
Ejemplo n.º 19
0
    def add_sellable(self, sellable):
        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)
Ejemplo n.º 20
0
 def setup_slaves(self):
     SellableItemStep.setup_slaves(self)
     self.hide_add_button()
     self.cost_label.set_label('Price:')
     self.cost.set_editable(True)
Ejemplo n.º 21
0
 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)
Ejemplo n.º 22
0
 def setup_slaves(self):
     SellableItemStep.setup_slaves(self)
     self.hide_add_button()
     self.cost_label.hide()
     self.cost.hide()
Ejemplo n.º 23
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()
Ejemplo n.º 24
0
 def sellable_selected(self, sellable, batch=None):
     SellableItemStep.sellable_selected(self, sellable, batch=batch)
     if sellable:
         self.cost.update(sellable.price)
Ejemplo n.º 25
0
 def validate(self, value):
     SellableItemStep.validate(self, value)
     can_purchase = self.model.purchase_total > 0
     self.wizard.refresh_next(value and can_purchase)
Ejemplo n.º 26
0
 def setup_slaves(self):
     SellableItemStep.setup_slaves(self)
Ejemplo n.º 27
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)
Ejemplo n.º 28
0
 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)
Ejemplo n.º 29
0
 def sellable_selected(self, sellable, batch=None):
     SellableItemStep.sellable_selected(self, sellable, batch=batch)
     if sellable:
         self.cost.update(sellable.price)
Ejemplo n.º 30
0
 def sellable_selected(self, sellable):
     SellableItemStep.sellable_selected(self, sellable)
     if sellable:
         self.cost.update(sellable.price)
Ejemplo n.º 31
0
    def post_init(self):
        self.hide_add_button()

        SellableItemStep.post_init(self)
Ejemplo n.º 32
0
 def setup_slaves(self):
     SellableItemStep.setup_slaves(self)
Ejemplo n.º 33
0
 def __init__(self, wizard, previous, store, model):
     self.branch = api.get_current_branch(store)
     SellableItemStep.__init__(self, wizard, previous, store, model)
Ejemplo n.º 34
0
    def post_init(self):
        self.hide_add_button()

        SellableItemStep.post_init(self)
Ejemplo n.º 35
0
 def validate(self, value):
     SellableItemStep.validate(self, value)
     can_decrease = self.model.get_items().count()
     self.wizard.refresh_next(value and can_decrease)
Ejemplo n.º 36
0
 def setup_slaves(self):
     SellableItemStep.setup_slaves(self)
     self.hide_add_button()
     self.cost_label.set_label('Price:')
     self.cost.set_editable(True)
Ejemplo n.º 37
0
 def sellable_selected(self, sellable):
     SellableItemStep.sellable_selected(self, sellable)
     if sellable:
         price = sellable.get_price_for_category(self.model.client_category)
         self.cost.set_text("%s" % price)
         self.proxy.update('cost')
Ejemplo n.º 38
0
 def sellable_selected(self, sellable):
     SellableItemStep.sellable_selected(self, sellable)
     if sellable:
         self.cost.update(sellable.price)
Ejemplo n.º 39
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)