gui Package

gui Package

Graphical User Interface: Dialogs, Editors, Search, Slaves, Wizards etc

events Module

Events used in the domain code

class stoqlib.gui.events.StartApplicationEvent[source]

Bases: stoqlib.lib.event.Event

Emitted when an application is activated

Parameters:
  • appname – the name of the application
  • app – the app itself
class stoqlib.gui.events.StopApplicationEvent[source]

Bases: stoqlib.lib.event.Event

Emitted when an application is deactivated

Parameters:
  • appname – the name of the application
  • app – the app itself
class stoqlib.gui.events.ApplicationSetupSearchEvent[source]

Bases: stoqlib.lib.event.Event

Emitted when a search slave is created.

Parameters:dialog – The application that is being prepared for search.
class stoqlib.gui.events.RunDialogEvent[source]

Bases: stoqlib.lib.event.Event

This is emitted when a dialog is about to be run.

This event gives the opportunity to change the dialog that is being displayed for another one.

For instance, a plugin could change the product editor for a more specialized one, or could change the sale wizard for another one that has a slightly different process.

This event is emitted with the same arguments that were passed to stoqlib.gui.base.run_dialog()

If the return value is not None, it should be a new dialog to replace the one that would be run. Note that the new dialog should be prepared to handle the same arguments as the original dialog.

Parameters:
  • dialog – The dialog that will be run
  • parent – The parent of the dialog
  • args – Custom positional arguments
  • kwargs – Custom keyword arguments.
Retval:

The new dialog to be displayed, or the original dialog, if no one handled this event

classmethod emit(dialog, parent, *args, **kwargs)[source]
class stoqlib.gui.events.DialogCreateEvent[source]

Bases: stoqlib.lib.event.Event

Emitted when a dialog is instantiated

Parameters:dialog – an instance of stoqlib.gui.base.dialogs.BasicDialog
class stoqlib.gui.events.EditorCreateEvent[source]

Bases: stoqlib.lib.event.Event

Emitted when an editor is instantiated.

Note that since a BaseEditor is also a BaseEditorSlave, the EditorSlaveCreateEvent will also be emitted. The main difference from this event to the other one, is that when this event is emitted, the editor already has a main_window property that can be used.

Parameters:
  • editor – a subclass of stoqlib.gui.editor.baseeditor.BaseEditor
  • model – usually a subclass of stoqlib.domain.base.Domain
  • store – the database store used in editor and model
  • visual_mode – a bool defining if the editor was created on visual_mode.
class stoqlib.gui.events.EditorSlaveCreateEvent[source]

Bases: stoqlib.lib.event.Event

Emitted when a slave editor is instantiated

Parameters:
  • editor – a subclass of stoqlib.gui.editor.baseeditor.BaseEditorSlave
  • model – usually a subclass of stoqlib.domain.base.Domain
  • store – the database store used in editor and model
  • visual_mode – a bool defining if the editor was created on visual_mode.
class stoqlib.gui.events.EditorSlaveConfirmEvent[source]

Bases: stoqlib.lib.event.Event

Emitted when a slave editor is confirmed

Parameters:
  • editor – a subclass of stoqlib.gui.editor.baseeditor.BaseEditorSlave
  • model – usually a subclass of stoqlib.domain.base.Domain
  • store – the database store used in editor and model
  • visual_mode – a bool defining if the editor was created on visual_mode.
class stoqlib.gui.events.SearchDialogSetupSearchEvent[source]

Bases: stoqlib.lib.event.Event

Emitted when a search slave is created.

Parameters:dialog – The dialog that is being prepared for search.
class stoqlib.gui.events.PrintReportEvent[source]

Bases: stoqlib.lib.event.Event

Emitted when a report is going to be printed

Useful if the report is going to be replaced by another. In that case, the callback connected to this event should return True and the original printing won’t happen.

Parameters:
  • report_class – the report class
  • *args

    extra args for the report class

  • **kwargs

    extra kwargs for the report class

class stoqlib.gui.events.SaleQuoteFinishPrintEvent[source]

Bases: stoqlib.lib.event.Event

Emitted when finish a sale quote

If a callsite return a value from this event, the default report will not be printed. :param sale: the sale that will generate a new report

class stoqlib.gui.events.CanSeeAllBranches[source]

Bases: stoqlib.lib.event.Event

This is emmited when a branch filter is being created and we should decide if all branches should be selectable or only the current one.

class stoqlib.gui.events.CouponCreatedEvent[source]

Bases: stoqlib.lib.event.Event

Emitted when a coupon is to be created on fiscalprinter.

Parameters:
  • coupon (:stoqlib.gui.fiscalprinter.FiscalCoupon) – The newly created coupon
  • sale – The sale to wich we are creating the coupon. Will be None when it is still in progress (i.e. a sale in progress on POS).
class stoqlib.gui.events.WizardSellableItemStepEvent[source]

Bases: stoqlib.lib.event.Event

This event is emitted when the items step <stoqlib.gui.wizard...> of the receiving wizard is reached.

Parameters:wizard_step – The product receiving order dialog.
class stoqlib.gui.events.WizardAddSellableEvent[source]

Bases: stoqlib.lib.event.Event

This event is emitted when a sellable is added on a stock operation wizard, such as sales, loans, transfers and decreases.

Parameters:
  • wizard – The wizard that is handling the operation.
  • item – The operation item added to the operation.
class stoqlib.gui.events.POSConfirmSaleEvent[source]

Bases: stoqlib.lib.event.Event

This event is emitted in case a sale is confirmed in the pos app.

Note that the <ConfirmSaleEvent> is also emitted, right before this event, but this event may not be emitted if the sale is being confirmed outside the pos app.

Parameters:sale_items – A list of objects representing the itens added in the Sale. This objects are instances of <stoq.gui.pos.TemporarySaleItem>
class stoqlib.gui.events.POSAddSellableEvent[source]

Bases: stoqlib.lib.event.Event

This event is emitted when a sellable is added on the pos app.

Parameters:
  • sellable – The sellable <stoqlib.domain.sellable.Sellable> object added to the sale
  • quantity – The quantity of the sellable added
  • batch – The batch of the sellable added
class stoqlib.gui.events.NewLoanWizardFinishEvent[source]

Bases: stoqlib.lib.event.Event

This event is emitted in case a loan is confirmed in the New Loan Wizard.

Parameters:loan – The loan <stoqlib.domain.loan.Loan> object that represents the loan created.
class stoqlib.gui.events.LoanItemSelectionStepEvent[source]

Bases: stoqlib.lib.event.Event

This event is emitted in item selection step of the close loan wizard

Parameters:step – The step itself
class stoqlib.gui.events.CloseLoanWizardFinishEvent[source]

Bases: stoqlib.lib.event.Event

This event is emitted when stoqlib.gui.wizards.loanwizard.CloseLoanWizard> finishes

Parameters:
  • loans – A list of all closed loans.
  • created_sale – The sale object that was created for the closed loans
  • wizard – The stoqlib.gui.wizards.loanwizard.CloseLoanWizard> itself
class stoqlib.gui.events.ReceivingOrderWizardFinishEvent[source]

Bases: stoqlib.lib.event.Event

This event is emitted in case an order is received in the Receiving Order Wizard.

Parameters:order – The receiving order <stoqlib.domain.receiving.ReceivingOrder> object that represents the order received.
class stoqlib.gui.events.SaleReturnWizardFinishEvent[source]

Bases: stoqlib.lib.event.Event

This event is emitted in case a sale is returned in the Sale Return Wizard.

Parameters:returned_sale – The returned sale <stoqlib.domain.returned_sale.ReturnedSale> object that represents the sale returned.
class stoqlib.gui.events.SaleTradeWizardFinishEvent[source]

Bases: stoqlib.lib.event.Event

This event is emitted in case a new trade is created in the Sale Trade Wizard. Note that the trade will only be confirmed after the new sale is confirmed in the POS app.

Parameters:returned_sale – The returned sale <stoqlib.domain.returnedsale.ReturnedSale> object that represents the sale returned.
class stoqlib.gui.events.StockDecreaseWizardFinishEvent[source]

Bases: stoqlib.lib.event.Event

This event is emitted in case the stock is decreased in the Stock Decrease Wizard.

Parameters:stock_decreased – The stock decrease <stoqlib.domain.stockdecrease.StockDecrease> object that represents the stock decrement.
class stoqlib.gui.events.StockTransferWizardFinishEvent[source]

Bases: stoqlib.lib.event.Event

This event is emitted in case a stock transfer is ordered in the Stock Transfer Wizard.

Parameters:transfer_order – The transfer order <stoqlib.domain.transfer.TransferOrder> object that represents the stock transfer.
class stoqlib.gui.events.ConfirmSaleWizardFinishEvent[source]

Bases: stoqlib.lib.event.Event

This event is emitted in case a sale is confirmed using the confirm sale wizard

Parameters:sale – The sale that was confirmed.
class stoqlib.gui.events.SaleQuoteWizardFinishEvent[source]

Bases: stoqlib.lib.event.Event

This event is emitted in case a sale quote is created using the sale quote wizard.

Parameters:sale – The sale that was created.
class stoqlib.gui.events.InvoiceSetupEvent[source]

Bases: stoqlib.lib.event.Event

This event is triggered before an operation wizard commit to check and/or setup the invoice data. If the return value is False, the commit is not done, and the wizard should let the user fix the mistakes or do a rollback. If it’s True, the wizard can go on with the commit. If the event is not caught or the callsite returns None, the wizard can go on with the commit too.

Return type:bool or NoneType
Returns:A bool value representing the validity of the invoice data or None
class stoqlib.gui.events.StockOperationPersonValidationEvent[source]

Bases: stoqlib.lib.event.Event

This event is issued when a person is about to be associated to a stock operation.

param person:The <stoqlib.domain.person.Person> of the model added to the operation.
param person_type:
 The type of the model added, such as Client, Branch, Transporter.
Return type:<kiwy.datatypes.ValidationError>
Returns:A ValidationError if validation fails else None

fields Module

stoqlib.gui.fields.get_store_for_field(field)[source]

Returns the store being used on the editor field is attached

class stoqlib.gui.fields.DomainChoiceField(label='', **kwargs)[source]

Bases: kiwi.ui.forms.ChoiceField

Field used to select a domain object

The graphical interface for it contains:

* a combobox entry for selecting the model object
* an add_button, which you can click to add a new object
  to the model. It's sensitivity is controller by :obj:`.can_add`
* an edit_button, which you can click to edit the selected
  object. It's sensitivity is controlled by :obj:`.can_edit` and
  :obj:`.can_view`.

It’s supposed to be subclassed and have it’s populate() and run_dialog() implemented on the subclass

default_overrides = {'has_edit_button': True, 'has_add_button': True}
can_add

If we have the permission to add new object of this kind

can_edit

If we have the permission to edit the currently selected object

can_view

If we have the permission to view the details of the currently selected object

use_ids = False

If we are using the ids to pupulate the field instead of domain objects. This changes what gets send as argument on populate() after _run_editor is called

prefill(items, value=None)[source]
attach()[source]
add_button_clicked(button)[source]
edit_button_clicked(button)[source]
content_changed()[source]
run_dialog(store, model)[source]
do_get_property(pspec)
do_set_property(pspec, value)
class stoqlib.gui.fields.AddressField(label='', **kwargs)[source]

Bases: stoqlib.gui.fields.DomainChoiceField

default_overrides = {'has_edit_button': True, 'use_entry': True, 'has_add_button': True}
person

The person the address belongs to, must be a stoqlib.domain.person.Person

attach()[source]
populate(address)[source]
run_dialog(store, address)[source]
set_from_client(client)[source]
do_get_property(pspec)
do_set_property(pspec, value)
class stoqlib.gui.fields.PaymentMethodField(label='', **kwargs)[source]

Bases: kiwi.ui.forms.ChoiceField

payment_type

The type of the payment used to get creatable methods. See stoqlib.lib.interfaces.IPaymentOperation.creatable() for more information

separate

If this is being created separated from a sale / purchase See stoqlib.lib.interfaces.IPaymentOperation.creatable() for more information

populate(value)[source]
do_get_property(pspec)
do_set_property(pspec, value)
class stoqlib.gui.fields.PaymentCategoryField(label='', **kwargs)[source]

Bases: stoqlib.gui.fields.DomainChoiceField

category_type

This is the type of payment category we will display in this field, it it should either be PaymentCategory.TYPE_PAYABLE or PaymentCategory.TYPE_RECEIVABLE

populate(value)[source]
run_dialog(store, category)[source]
do_get_property(pspec)
do_set_property(pspec, value)
class stoqlib.gui.fields.PersonField(label='', **kwargs)[source]

Bases: stoqlib.gui.fields.DomainChoiceField

default_overrides = {'has_edit_button': True, 'use_entry': True, 'has_add_button': True}
use_ids = True
person_type

This is the type of person we will display in this field, it must be a class referencing a stoqlib.domain.person.Person

populate(person_id)[source]
run_dialog(store, person)[source]
edit_button_clicked(button)[source]
do_get_property(pspec)
do_set_property(pspec, value)
class stoqlib.gui.fields.PersonQueryField(label='', **kwargs)[source]

Bases: kiwi.ui.forms.TextField

default_overrides = {'has_edit_button': True, 'has_add_button': True}
person_type

This is the type of person we will display in this field, it must be a class referencing a stoqlib.domain.person.Person

widget_data_type

alias of object

attach()[source]
populate(obj)[source]
set_value(obj)[source]
add_button_clicked(button)[source]
edit_button_clicked(button)[source]
do_get_property(pspec)
do_set_property(pspec, value)
class stoqlib.gui.fields.CfopField(label='', **kwargs)[source]

Bases: stoqlib.gui.fields.DomainChoiceField

A domain choice field for selecting a C.F.O.P.

More information about this class on DomainChoiceField

default_overrides = {'has_edit_button': True, 'use_entry': True, 'can_edit': False, 'has_add_button': True}
populate(cfop)[source]
run_dialog(store, cfop)[source]
class stoqlib.gui.fields.GridGroupField(label='', **kwargs)[source]

Bases: stoqlib.gui.fields.DomainChoiceField

A domain choice field for selecting a grid group

More information about this class on DomainChoiceField

populate(gridgroup)[source]
run_dialog(store, gridgroup)[source]
class stoqlib.gui.fields.AttachmentField(label='', **kwargs)[source]

Bases: kiwi.ui.forms.Field

This field allows attaching files to models.

The graphical interface for it contains:

  • a button, which you can click if there’s an attachment. The attachment will open in the default system application based on its mimetype
  • the add_button, which you can click to add an attachment in case there’s none
  • the edit_button, which you can click to change an attachment
  • the delete_button, which you can click to delete an attachment

It is the editor’s responsibility to get the attachment and associate it to the model. For example:

self.model.attachment = self.fields['attachment'].attachment
widget_data_type

alias of object

has_add_button = True
has_edit_button = True
has_delete_button = True
no_attachment_lbl = 'No attachment.'
attachment

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

build_widget()[source]
populate(attachment)[source]
delete_button_clicked(button)[source]
add_button_clicked(button)[source]
edit_button_clicked(button)[source]
do_get_property(pspec)
do_set_property(pspec, value)
class stoqlib.gui.fields.DateTextField(label='', **kwargs)[source]

Bases: kiwi.ui.forms.TextField

widget_data_type

alias of date

fiscalprinter Module

class stoqlib.gui.fiscalprinter.FiscalPrinterHelper(store, parent)[source]

Bases: gobject._gobject.GObject

Signals:

  • till-status-changed (bool, bool): Emitted when the status of the till has changed. it can be open/closed, and while open/closed, it can be blocked
  • ecf-changed (bool): Emitted fater the check_till method is called, indicating if a ecf printer is present and functional.
open_till()[source]

Opens the till

close_till(close_db=True, close_ecf=True)[source]

Closes the till

There are 3 possibilities for parameters combination:
  • total close: Both close_db and close_ecf are True. The till on both will be closed.
  • partial close: Both close_db and close_ecf are False. It’s more like a till verification. The actual user will do it to check and maybe remove money from till, leaving it ready for the next one. Note that this will not emit ‘till-status-changed’ event, since the till will not really close.
  • fix conflicting status: close_db and close_ecf are different. Use this only if you need to fix a conflicting status, like if the DB is open but the ECF is closed, or the other way around.
Parameters:
  • close_db – If the till in the DB should be closed
  • close_ecf – If the till in the ECF should be closed
Returns:

True if the till was closed, otherwise False

verify_till()[source]

Verifies the till

This is just a shortcut for calling close_till passing close_db/close_ecf = False. See it’s doc for more info.

needs_closing()[source]

Checks if the last opened till was closed and asks the user if he wants to close it

Returns:
  • CLOSE_TILL_BOTH if both DB and ECF needs closing.
  • CLOSE_TILL_DB if only DB needs closing.
  • CLOSE_TILL_ECF if only ECF needs closing.
  • CLOSE_TILL_NONE if both ECF and DB are consistent (they may be
    closed, or open for the current day)
create_coupon(sale=None)[source]

Creates a new fiscal coupon

Parameters:sale – The sale to which we are creating a coupon
Returns:a new coupon
setup_midnight_check()[source]

Check the till after the day changes.

If Stoq is open, the day changes, and the user tries to confirm a sale (or do any other fiscal operation), an error will happen.

This method will call check_till that will eventually, disable fiscal related interface.

check_open_coupon()[source]
check_till(reset_midnight_check=False)[source]
run_initial_checks()[source]

This will check:

  1. If printer has open coupon, cancel it
  2. If printer has pending reduce Z, offer to close the till

If the first check fails, the second one will not happen

class stoqlib.gui.fiscalprinter.FiscalCoupon(parent)[source]

Bases: gobject._gobject.GObject

This class is used just to allow us cancel an item with base in a Sellable object. Currently, services can’t be added, and they are just ignored – be aware, if a coupon with only services is emitted, it will not be opened in fact, but just ignored.

emit(signal, *args)[source]
add_item(sale_item)[source]

Adds an item to fiscal coupon

Parameters:sale_item – a sale item
Returns:id of the sale_item.: 0 >= if it was added successfully -1 if an error happend 0 if added but not printed (free deliveries)
get_items()[source]
remove_item(sale_item)[source]
identify_customer(person)[source]
is_customer_identified()[source]
open()[source]
confirm(sale, store, savepoint=None, subtotal=None)[source]

Confirms a sale on fiscalprinter and database

If the sale is confirmed, the store will be committed for you. There’s no need for the callsite to call store.confirm(). If the sale is not confirmed, for instance the user cancelled the sale or there was a problem with the fiscal printer, then the store will be rolled back.

Parameters:
  • sale – the sale to be confirmed
  • trans – a store
  • savepoint – if specified, a database savepoint name that will be used to rollback to if the sale was not confirmed.
  • subtotal – the total value of all the items in the sale
add_sale_items(sale)[source]
print_receipts(sale)[source]
totalize(sale)[source]
cancel()[source]
setup_payments(sale)[source]

Add the payments defined in the sale to the coupon. Note that this function must be called after all the payments has been created.

close(sale, store)[source]
print_payment_receipt(payment, value, receipt)[source]

Print the receipt for the payment.

This must be called after the coupon is closed.

reprint_payment_receipt(receipt, close_previous=False)[source]

Re-Print the receipt for the payment.

interfaces Module

interface stoqlib.gui.interfaces.IDomainSlaveMapper[source]

Bases: zope.interface.Interface

This is a singleton responsible for mapping a domain object to a slave.

register(domain_class, slave_class)

Register a slave class for a domain class. :param domain_class: :param slave_class:

get_slave_class(domain_class)

Fetch a slave class given a domain class. :param domain_class: :returns: the slave class or None

interface stoqlib.gui.interfaces.ISearchResultView[source]

Bases: zope.interface.Interface

This is an interface that displays the results of a search query, done by a search container

In addition to the interfaces above, the following GObject signals needs to be implemented:

  • item-activated (item)
  • item-popup-menu (item, event)
  • selection-changed ()
attach(container, columns)

This is called after we’ve been attached to a search container

Parameters:
  • container (SearchContainer) – the search container
  • columns – list of objectlist columns

Enables lazy search for this view, it only makes sense when the items are displayed in an ObjectList

show()

Displays the result view

clear()

Clears the results

search_completed(results)

The search was completed. This should populate the widget with the new information.

Parameters:results – a result set
get_n_items()
Returns:now many items there are in the view
get_selected_item()

Fetches the currently selected item

Returns:the selected item
get_settings()

Serialize the internal settings for this view

Returns:the settings for this view
Return type:a dictionary
destroy()

Destroys the result view

set_message(message)
clear_message()

stockicons Module

stoqlib.gui.stockicons.register()[source]

Subpackages