Beispiel #1
0
 def _on_BookSearchView__activate(self, action, parameter):
     from .bookssearch import ProductBookSearch
     run_dialog(ProductBookSearch,
                None,
                self.default_store,
                hide_cost_column=True,
                hide_toolbar=True)
Beispiel #2
0
 def on_credit_transactions_button__clicked(self, button):
     # If we are not in edit mode, we are creating a new object, and thus we
     # should reuse the transaction
     reuse_store = not self.edit_mode
     run_dialog(CreditInfoListDialog, self.get_toplevel().get_toplevel(),
                self.store, self.model, reuse_store=reuse_store)
     self.proxy.update('credit_account_balance')
    def finish(self):
        missing = get_missing_items(self.model, self.store)
        if missing:
            run_dialog(MissingItemsDialog, self, self.model, missing)
            return False

        invoice_ok = InvoiceSetupEvent.emit()
        if invoice_ok is False:
            # If there is any problem with the invoice, the event will display an error
            # message and the dialog is kept open so the user can fix whatever is wrong.
            return

        # FIXME: If any issue happen at any point of the "send process",
        # trying to issue it again would make some products have their stock
        # decreased twice. Make sure we undo it first.
        # The issue itself was related to missing stock. Why get_missing_items
        # failed above?
        self.store.savepoint('before_send_transfer')
        try:
            self.model.send(api.get_current_user(self.store))
        except Exception as e:
            warning(_("An error happened when trying to confirm the transfer"),
                    str(e))
            self.store.rollback_to_savepoint('before_send_transfer')
            raise

        self.retval = self.model
        self.close()

        StockTransferWizardFinishEvent.emit(self.model)
        # Commit before printing to avoid losing data if something breaks
        self.store.confirm(self.retval)
        self._receipt_dialog(self.model)
Beispiel #4
0
 def on_observations_button__clicked(self, *args):
     run_dialog(NoteEditor,
                self.wizard,
                self.store,
                self.model,
                'notes',
                title=_("Additional Information"))
Beispiel #5
0
    def _pay(self, payable_views):
        """
        Pay a list of items from a payable_views, note that
        the list of payable_views must reference the same order
        @param payables_views: a list of payable_views
        """
        assert self._can_pay(payable_views)

        # Do not allow confirming the payment if the purchase was not
        # completely received.
        purchase_order = payable_views[0].purchase

        if (purchase_order
                and api.sysparam.get_bool('BLOCK_INCOMPLETE_PURCHASE_PAYMENTS')
                and not purchase_order.status == PurchaseOrder.ORDER_CLOSED):

            return warning(
                _("Can't confirm the payment if the purchase "
                  "is not completely received yet."))

        with api.new_store() as store:
            payments = [store.fetch(view.payment) for view in payable_views]

            run_dialog(PurchasePaymentConfirmSlave,
                       self,
                       store,
                       payments=payments)

        if store.committed:
            # We need to refresh the whole list as the payment(s) can possibly
            # disappear for the selected view
            self.refresh()

        self._update_widgets()
Beispiel #6
0
 def on_details_button__clicked(self, *args):
     selected = self.search.results.get_selected_rows()[0]
     if not selected:
         raise ValueError('You should have one order selected '
                          'at this point, got nothing')
     run_dialog(PurchaseDetailsDialog, self.wizard, self.store,
                model=selected.purchase)
Beispiel #7
0
def test_dialog():  # pragma nocover
    from stoq.lib.gui.base.dialogs import run_dialog

    ec = stoq_api.prepare_test()
    client = ec.store.find(Client).any()
    run_dialog(OpticalPatientDetails, None, ec.store, client)
    ec.store.commit()
Beispiel #8
0
 def on_details_btn__clicked(self, button):
     model = self.workorders.get_selected().work_order
     run_dialog(WorkOrderEditor,
                self,
                self.store,
                model=model,
                visual_mode=True)
Beispiel #9
0
 def _edit_order(self, order_view):
     run_dialog(NoteEditor,
                self,
                self.store,
                model=order_view,
                attr_name='notes',
                title=_(u"Notes"))
Beispiel #10
0
    def _show_client_birthdays_by_date(self, date):
        from stoq.lib.gui.search.personsearch import ClientSearch

        with api.new_store() as store:
            y, m, d = map(int, date.split('-'))
            date = localdate(y, m, d).date()
            run_dialog(ClientSearch, self.app, store, birth_date=date)
Beispiel #11
0
def test_employee_role():  # pragma nocover
    creator = api.prepare_test()
    role = creator.create_employee_role()
    run_dialog(EmployeeRoleEditor,
               parent=None,
               store=creator.store,
               model=role)
Beispiel #12
0
    def _dialog_client(self, id):
        from stoqlib.domain.person import Client
        from stoq.lib.gui.dialogs.clientdetails import ClientDetailsDialog

        with api.new_store() as store:
            model = store.get(Client, id)
            run_dialog(ClientDetailsDialog, self.app, store, model)
Beispiel #13
0
    def run_wizard(cls, parent):
        """Run the wizard to create a product

        This will run the wizard and after finishing, ask if the user
        wants to create another product alike. The product will be
        cloned and `stoq.lib.gui.editors.producteditor.ProductEditor`
        will run as long as the user chooses to create one alike
        """
        with api.new_store() as store:
            rv = run_dialog(cls, parent, store)

        if rv:
            inner_rv = rv

            while yesno(_("Would you like to register another product alike?"),
                        Gtk.ResponseType.NO, _("Yes"), _("No")):
                with api.new_store() as store:
                    template = store.fetch(rv)
                    inner_rv = run_dialog(ProductEditor,
                                          parent,
                                          store,
                                          product_type=template.product_type,
                                          template=template)

                if not inner_rv:
                    break

        # We are insterested in the first rv that means that at least one
        # obj was created.
        return rv
Beispiel #14
0
 def on_details_button_clicked(self, *args):
     # FIXME: Person editor/slaves are depending on the store being a
     # StoqlibStore. See bug 5012
     with api.new_store() as store:
         selected = self.results.get_selected()
         user = store.fetch(selected.user)
         run_dialog(UserEditor, self, store, user, visual_mode=True)
Beispiel #15
0
    def _edit(self, payable_views):
        with api.new_store() as store:
            order = store.fetch(payable_views[0].purchase)
            run_dialog(PurchasePaymentsEditor, self, store, order)

        if store.committed:
            self.refresh()
 def run_editor(self, obj):
     visual_mode = obj is not None
     if self._reuse_store:
         self.store.savepoint('before_run_editor_client_history')
         retval = run_dialog(self.editor_class,
                             self,
                             self.store,
                             self.store.fetch(obj),
                             self.store.fetch(self.client),
                             visual_mode=visual_mode)
         if not retval:
             self.store.rollback_to_savepoint(
                 'before_run_editor_client_history')
     else:
         store = api.new_store()
         client = store.fetch(self.client)
         retval = run_dialog(self.editor_class,
                             self,
                             store,
                             store.fetch(obj),
                             store.fetch(client),
                             visual_mode=visual_mode)
         store.confirm(retval)
         store.close()
     return retval
Beispiel #17
0
    def _show_client_calls_by_date(self, date):
        from stoq.lib.gui.search.callsearch import ClientCallsSearch

        store = api.new_store()
        y, m, d = map(int, date.split('-'))
        date = localdate(y, m, d).date()
        run_dialog(ClientCallsSearch, self.app, store, date=date)
        store.close()
Beispiel #18
0
 def _run_editor(self, button, editor_class):
     with api.new_store() as store:
         run_dialog(editor_class, self, store)
     if store.committed:
         self.search.refresh()
         self.results.unselect_all()
         if len(self.results):
             self.results.select(self.results[-1])
Beispiel #19
0
def test_price_editor():  # pragma nocover
    from decimal import Decimal
    ec = stoq_api.prepare_test()
    sellable = ec.create_sellable()
    sellable.cost = Decimal('15.55')
    sellable.price = Decimal('21.50')
    run_dialog(SellablePriceEditor,
               parent=None, store=ec.store, model=sellable)
Beispiel #20
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)
Beispiel #21
0
def test_sellable_tax_constant():  # pragma nocover
    ec = api.prepare_test()
    tax_constant = api.sysparam.get_object(ec.store,
                                           'DEFAULT_PRODUCT_TAX_CONSTANT')
    run_dialog(SellableTaxConstantEditor,
               parent=None,
               store=ec.store,
               model=tax_constant)
    print(tax_constant)
Beispiel #22
0
def test_grid_editor():  # pragma nocover
    from stoq.lib.gui.base.dialogs import run_dialog
    ec = stoq_api.prepare_test()
    group = ec.store.find(GridGroup).any()
    attribute = ec.create_grid_attribute(attribute_group=group)
    attribute.group = None
    run_dialog(GridAttributeEditor,
               parent=None, store=ec.store, model=attribute)
    print(attribute.group)
Beispiel #23
0
    def _maybe_show_welcome_dialog(self):
        from stoqlib.api import api
        if not api.user_settings.get('show-welcome-dialog', True):
            return
        api.user_settings.set('show-welcome-dialog', False)

        from stoq.gui.welcomedialog import WelcomeDialog
        from stoq.lib.gui.base.dialogs import run_dialog
        run_dialog(WelcomeDialog)
Beispiel #24
0
 def show_details(self):
     """Called when the details button is clicked. Displays the details of
     the selected object in the list."""
     model = self.get_details_model(self.klist.get_selected())
     run_dialog(self.get_details_dialog_class(),
                parent=self._parent,
                store=self._parent.store,
                model=model,
                visual_mode=True)
Beispiel #25
0
    def _create_pre_sale(self):
        if self._current_app.check_open_inventory():
            warning(_("You cannot create a pre-sale with an open inventory."))
            return

        with api.new_store() as store:
            run_dialog(OpticalSaleQuoteWizard, self._current_app, store)

        if store.committed:
            self._current_app.refresh()
Beispiel #26
0
    def _show_missing_products(self):
        missing_products = set([i.sellable for i in self.model.get_items()])
        for quote in self.quoting_list:
            if quote.selected:
                missing_products = missing_products.difference(quote.items)
            if len(missing_products) == 0:
                break

        run_dialog(SimpleListDialog, self.wizard, self.product_columns,
                   missing_products, title=_(u'Missing Products'))
Beispiel #27
0
    def on_details_button_clicked(self, button):
        work_order_view = self.results.get_selected()
        if not work_order_view:
            return

        run_dialog(WorkOrderEditor,
                   self,
                   self.store,
                   model=work_order_view.work_order,
                   visual_mode=True)
Beispiel #28
0
def run_person_role_dialog(role_editor,
                           parent,
                           store,
                           model=None,
                           **editor_kwargs):
    if not model:
        editor_kwargs.pop('visual_mode', None)
        return run_dialog(PersonRoleWizard, parent, store, role_editor,
                          **editor_kwargs)
    return run_dialog(role_editor, parent, store, model, **editor_kwargs)
Beispiel #29
0
    def _dialog_work_order(self, id):
        from stoqlib.domain.workorder import WorkOrder
        from stoq.lib.gui.editors.workordereditor import WorkOrderEditor

        with api.new_store() as store:
            model = store.get(WorkOrder, id)
            user = api.get_current_user(store)
            visual_mode = not user.profile.check_app_permission(u'services')
            run_dialog(WorkOrderEditor, self.app, store, model,
                       visual_mode=visual_mode)
 def on_info_button__clicked(self, button):
     item = self.items_list.get_selected()
     run_dialog(NoteEditor,
                self,
                self.store,
                item,
                'reason',
                title=_('Reason'),
                label_text=_('Adjust reason'),
                visual_mode=True)