Ejemplo n.º 1
0
    def _can_open(self):
        branch = api.get_current_branch(self.store)
        if Inventory.has_open(self.store, branch):
            return False

        # It doesn't make sense to open an inventory if we don't have any stock
        return self.store.find(ProductStockItem, branch=branch).count() > 0
Ejemplo n.º 2
0
    def _update_view(self):
        self.proxy.update("status_str")

        has_open_inventory = bool(Inventory.has_open(self.store, api.get_current_branch(self.store)))

        tab = self._get_tab("execution_holder")
        # If it's not opened, it's at least approved.
        # So, we can enable the execution slave
        tab.set_sensitive(
            self.model.status == WorkOrder.STATUS_WORK_IN_PROGRESS and not has_open_inventory and not self.visual_mode
        )

        has_items = bool(self.model.order_items.count())
        if self.model.can_approve():
            label = _("Approve")
        elif self.model.can_work() and not has_items:
            label = _("Start")
        elif self.model.can_work():
            label = _("Continue")
        elif self.model.can_pause():
            label = _("Pause")
        else:
            label = ""
        self.toggle_status_btn.set_label(label)
        self.toggle_status_btn.set_sensitive(not self.visual_mode and self.model.client is not None)
        self.toggle_status_btn.set_visible(bool(label))

        stock_id, tooltip = get_workorder_state_icon(self.model)
        if stock_id is not None:
            self.state_icon.set_from_stock(stock_id, gtk.ICON_SIZE_MENU)
            self.state_icon.set_visible(True)
            self.state_icon.set_tooltip_text(tooltip)
        else:
            self.state_icon.hide()
Ejemplo n.º 3
0
    def _can_open(self):
        branch = api.get_current_branch(self.store)
        if Inventory.has_open(self.store, branch):
            return False

        # It doesn't make sense to open an inventory if we don't have any stock
        return self.store.find(ProductStockItem, branch=branch).count() > 0
Ejemplo n.º 4
0
    def new_sale(self):
        store = self.window.store
        if Inventory.has_open(store, api.get_current_branch(store)):
            warning(_("You cannot create a quote with an open inventory."))
            return

        with api.new_store() as store:
            run_dialog(SaleQuoteWizard, None, store)
Ejemplo n.º 5
0
    def new_sale(self):
        store = self.window.store
        if Inventory.has_open(store, api.get_current_branch(store)):
            warning(_("You cannot create a quote with an open inventory."))
            return

        with api.new_store() as store:
            run_dialog(SaleQuoteWizard, None, store)
Ejemplo n.º 6
0
    def setup_proxies(self):
        # Avoid changing widget states in __init__, so that plugins have a
        # chance to override the default settings
        has_open_inventory = Inventory.has_open(self.store,
                                                api.get_current_branch(self.store))
        self.receive_now.set_sensitive(not bool(has_open_inventory))

        self._setup_transporter_entry()
        self.proxy = self.add_proxy(self.model, self.proxy_widgets)
Ejemplo n.º 7
0
    def setup_proxies(self):
        # Avoid changing widget states in __init__, so that plugins have a
        # chance to override the default settings
        has_open_inventory = Inventory.has_open(
            self.store, api.get_current_branch(self.store))
        self.receive_now.set_sensitive(not bool(has_open_inventory))

        self._setup_transporter_entry()
        self.proxy = self.add_proxy(self.model, self.proxy_widgets)
Ejemplo n.º 8
0
    def return_sale(self):
        assert not Inventory.has_open(self.store, api.get_current_branch(self.store))
        sale_view = self.sales.get_selected()
        store = api.new_store()
        retval = return_sale(self.get_parent(), store.fetch(sale_view.sale), store)
        store.confirm(retval)
        store.close()

        if retval:
            self.emit("sale-returned", retval)
Ejemplo n.º 9
0
    def _setup_widgets(self):
        self.edit_button.set_sensitive(False)
        if not self.visual_mode:
            self.start_production_check.hide()

        has_open_inventory = Inventory.has_open(self.store,
                                                get_current_branch(self.store))
        self.start_production_check.set_sensitive(not bool(has_open_inventory))

        self.materials.set_columns(self._get_columns())
        for production_item in self.model.get_items():
            self._add_materials(production_item)
Ejemplo n.º 10
0
    def _setup_widgets(self):
        self.edit_button.set_sensitive(False)
        if not self.visual_mode:
            self.start_production_check.hide()

        has_open_inventory = Inventory.has_open(self.store,
                                                get_current_branch(self.store))
        self.start_production_check.set_sensitive(not bool(has_open_inventory))

        self.materials.set_columns(self._get_columns())
        for production_item in self.model.get_items():
            self._add_materials(production_item)
Ejemplo n.º 11
0
    def return_sale(self):
        assert not Inventory.has_open(self.store,
                                      api.get_current_branch(self.store))
        sale_view = self.sales.get_selected()
        store = api.new_store()
        retval = return_sale(self.get_parent(), store.fetch(sale_view.sale),
                             store)
        store.confirm(retval)
        store.close()

        if retval:
            self.emit('sale-returned', retval)
Ejemplo n.º 12
0
    def new_sale_with_wo(self):
        store = self.window.store
        if Inventory.has_open(store, api.get_current_branch(store)):
            warning(_("You cannot create a quote with an open inventory."))
            return

        with api.new_store() as store:
            run_dialog(WorkOrderQuoteWizard, None, store)

        if store.committed:
            # We are unable to just refresh the ui, so 'deactivate' and
            # 'activate' the launcher to mimic the refresh
            self.window.switch_application('launcher')
Ejemplo n.º 13
0
    def new_sale_with_wo(self):
        store = self.window.store
        if Inventory.has_open(store, api.get_current_branch(store)):
            warning(_("You cannot create a quote with an open inventory."))
            return

        with api.new_store() as store:
            run_dialog(WorkOrderQuoteWizard, None, store)

        if store.committed:
            # We are unable to just refresh the ui, so 'deactivate' and
            # 'activate' the launcher to mimic the refresh
            self.window.switch_application('launcher')
Ejemplo n.º 14
0
    def _get_available_branches_to_inventory(self):
        """Returns a list of branches where we can open an inventory.
        Note that we can open a inventory if:
            - There's no inventory opened yet (in the same branch)
            - The branch must have some stock
        """
        available_branches = []
        for branch in self._get_branches():
            has_open_inventory = Inventory.has_open(self.store, branch)
            if not has_open_inventory:
                stock = self.store.find(ProductStockItem, branch=branch)
                if stock.count() > 0:
                    available_branches.append(branch)

        return available_branches
Ejemplo n.º 15
0
    def _get_available_branches_to_inventory(self):
        """Returns a list of branches where we can open an inventory.
        Note that we can open a inventory if:
            - There's no inventory opened yet (in the same branch)
            - The branch must have some stock
        """
        available_branches = []
        for branch in self._get_branches():
            has_open_inventory = Inventory.has_open(self.store, branch)
            if not has_open_inventory:
                stock = self.store.find(ProductStockItem, branch=branch)
                if stock.count() > 0:
                    available_branches.append(branch)

        return available_branches
Ejemplo n.º 16
0
    def _update_view(self):
        self.proxy.update('status_str')

        # Cache this to avoid multiple queries
        has_open_inventory = bool(
            Inventory.has_open(self.store, api.get_current_branch(self.store)))

        tab = self._get_tab('execution_holder')
        # If it's not opened, it's at least approved.
        # So, we can enable the execution slave
        tab.set_sensitive(
            self.model.status == WorkOrder.STATUS_WORK_IN_PROGRESS
            and not has_open_inventory and not self.visual_mode)

        has_items = bool(self.model.order_items.count())
        branch = api.get_current_branch(self.store)
        if self.model.can_approve():
            label = _("Approve")
        elif self.model.can_work(branch) and not has_items:
            label = _("Start")
        elif self.model.can_work(branch):
            label = _("Continue")
        elif self.model.can_pause():
            label = _("Pause")
        else:
            label = ''
        self.toggle_status_btn.set_label(label)
        self.toggle_status_btn.set_sensitive(not self.visual_mode
                                             and self.model.client is not None)
        self.toggle_status_btn.set_visible(bool(label))

        stock_id, tooltip = get_workorder_state_icon(self.model)
        if stock_id is not None:
            self.state_icon.set_from_icon_name(stock_id, Gtk.IconSize.MENU)
            self.state_icon.set_visible(True)
            self.state_icon.set_tooltip_text(tooltip)
        else:
            self.state_icon.hide()
Ejemplo n.º 17
0
 def has_open_inventory(self):
     return Inventory.has_open(self.store,
                               api.get_current_branch(self.store))
Ejemplo n.º 18
0
 def has_open_inventory(self):
     has_open = Inventory.has_open(self.store,
                                   api.get_current_branch(self.store))
     return bool(has_open)
Ejemplo n.º 19
0
 def has_open_inventory(self):
     has_open = Inventory.has_open(self.store,
                                   api.get_current_branch(self.store))
     return bool(has_open)
Ejemplo n.º 20
0
 def _has_open_inventory(self):
     store = self._parent.store
     has_open = Inventory.has_open(store, api.get_current_branch(store))
     return bool(has_open)
Ejemplo n.º 21
0
 def has_open_inventory(self):
     return Inventory.has_open(self.store,
                               api.get_current_branch(self.store))
Ejemplo n.º 22
0
 def _has_open_inventory(self):
     store = self._parent.store
     has_open = Inventory.has_open(store, api.get_current_branch(store))
     return bool(has_open)