stoqlib Package

stoqlib Package

api Module

Stoqlib API

Singleton object which makes it easier to common stoqlib APIs without having to import their symbols.

class stoqlib.api.safe_str[source]

Bases: str

class stoqlib.api.safe_unicode[source]

Bases: unicode

class stoqlib.api.StoqAPI[source]

Bases: object

get_default_store()[source]
new_store()[source]
get_current_branch(store)[source]
get_current_station(store)[source]
get_current_user(store)[source]
config
db_settings
user_settings
is_developer_mode()[source]
get_l10n_field(field_name, country=None)[source]
for_combo(resultset, attr=None, empty=None, sorted=True)[source]

Prepares the result of a table for inserting into a combo. Formats the item and sorts them according to the current locale

Parameters:
  • resultset – a resultset
  • attr – attribute to use instead of IDescribable
  • empty – if set, add an initial None item with this parameter as a label

Example:

categories = self.store.find(SellableCategory)
self.category_combo.prefill(api.for_combo(categories,
                            attr='full_description'))
for_person_combo(resultset)[source]

This is similar to for_combo() but takes a class that references a Person, such as a Client, Company, Supplier etc.

Parameters:resultset – a resultset

Example:

suppliers = Supplier.get_active_suppliers(self.store)
self.supplier.prefill(api.for_person_combo(suppliers))
can_see_all_branches()[source]
get_branches_for_filter(store, use_id=False)[source]

Returns a list of branches to be used in a combo.

Parameters:use_id – If True, we will return the options using the object id instead of the real object.
escape(string)[source]

Escapes the text and makes it suitable for use with a PangoMarkup, usually via Label.set_markup()

prepare_test()[source]

Prepares to run a standalone test. This initializes Stoq and creates a store and returns an example creator.

Returns:an ExampleCreator

enums Module

Database enums

class stoqlib.enums.SyncPolicy[source]

Bases: kiwi.python.enum

  • I{FROM_SOURCE}: from the source to the target
  • I{FROM_TARGET}: from the target to the source
  • I{BOTH}: in both directions
  • I{INITIAL}: only when doing the initial clone
BOTH = <SyncPolicy value BOTH>
FROM_SOURCE = <SyncPolicy value FROM_SOURCE>
FROM_TARGET = <SyncPolicy value FROM_TARGET>
INITIAL = <SyncPolicy value INITIAL>
names = {'BOTH': <SyncPolicy value BOTH>, 'FROM_TARGET': <SyncPolicy value FROM_TARGET>, 'INITIAL': <SyncPolicy value INITIAL>, 'FROM_SOURCE': <SyncPolicy value FROM_SOURCE>}
values = {0: <SyncPolicy value FROM_SOURCE>, 1: <SyncPolicy value FROM_TARGET>, 2: <SyncPolicy value BOTH>, 3: <SyncPolicy value INITIAL>}
class stoqlib.enums.CreatePaymentStatus[source]

Bases: kiwi.python.enum

Anyone who catches CreatePaymentEvent should return one of this.

FAIL = <CreatePaymentStatus value FAIL>
SUCCESS = <CreatePaymentStatus value SUCCESS>
UNHANDLED = <CreatePaymentStatus value UNHANDLED>
names = {'FAIL': <CreatePaymentStatus value FAIL>, 'UNHANDLED': <CreatePaymentStatus value UNHANDLED>, 'SUCCESS': <CreatePaymentStatus value SUCCESS>}
values = {0: <CreatePaymentStatus value SUCCESS>, 1: <CreatePaymentStatus value FAIL>, 2: <CreatePaymentStatus value UNHANDLED>}
class stoqlib.enums.NFeDanfeOrientation[source]

Bases: kiwi.python.enum

LANDSCAPE = <NFeDanfeOrientation value LANDSCAPE>
PORTRAIT = <NFeDanfeOrientation value PORTRAIT>
names = {'PORTRAIT': <NFeDanfeOrientation value PORTRAIT>, 'LANDSCAPE': <NFeDanfeOrientation value LANDSCAPE>}
values = {0: <NFeDanfeOrientation value PORTRAIT>, 1: <NFeDanfeOrientation value LANDSCAPE>}
class stoqlib.enums.ReturnPolicy[source]

Bases: kiwi.python.enum

Policy for returning sales.

This enum is used by the parameter RETURN_POLICY_ON_SALES.

CLIENT_CHOICE = <ReturnPolicy value CLIENT_CHOICE>
RETURN_CREDIT = <ReturnPolicy value RETURN_CREDIT>
RETURN_MONEY = <ReturnPolicy value RETURN_MONEY>
names = {'RETURN_CREDIT': <ReturnPolicy value RETURN_CREDIT>, 'CLIENT_CHOICE': <ReturnPolicy value CLIENT_CHOICE>, 'RETURN_MONEY': <ReturnPolicy value RETURN_MONEY>}
values = {0: <ReturnPolicy value CLIENT_CHOICE>, 1: <ReturnPolicy value RETURN_MONEY>, 2: <ReturnPolicy value RETURN_CREDIT>}
class stoqlib.enums.LatePaymentPolicy[source]

Bases: kiwi.python.enum

Policy for clients with late payments

This enum is used by the parameter LATE_PAYMENTS_POLICY.

ALLOW_SALES = <LatePaymentPolicy value ALLOW_SALES>
DISALLOW_SALES = <LatePaymentPolicy value DISALLOW_SALES>
DISALLOW_STORE_CREDIT = <LatePaymentPolicy value DISALLOW_STORE_CREDIT>
names = {'DISALLOW_SALES': <LatePaymentPolicy value DISALLOW_SALES>, 'ALLOW_SALES': <LatePaymentPolicy value ALLOW_SALES>, 'DISALLOW_STORE_CREDIT': <LatePaymentPolicy value DISALLOW_STORE_CREDIT>}
values = {0: <LatePaymentPolicy value ALLOW_SALES>, 1: <LatePaymentPolicy value DISALLOW_STORE_CREDIT>, 2: <LatePaymentPolicy value DISALLOW_SALES>}
class stoqlib.enums.ChangeSalespersonPolicy[source]

Bases: kiwi.python.enum

Policy for changing the salesperson on POS sales

This enum is used by the parameter ACCEPT_CHANGE_SALESPERSON

ALLOW = <ChangeSalespersonPolicy value ALLOW>
DISALLOW = <ChangeSalespersonPolicy value DISALLOW>
FORCE_CHOOSE = <ChangeSalespersonPolicy value FORCE_CHOOSE>
names = {'FORCE_CHOOSE': <ChangeSalespersonPolicy value FORCE_CHOOSE>, 'ALLOW': <ChangeSalespersonPolicy value ALLOW>, 'DISALLOW': <ChangeSalespersonPolicy value DISALLOW>}
values = {0: <ChangeSalespersonPolicy value DISALLOW>, 1: <ChangeSalespersonPolicy value ALLOW>, 2: <ChangeSalespersonPolicy value FORCE_CHOOSE>}
class stoqlib.enums.SearchFilterPosition[source]

Bases: kiwi.python.enum

An enum used to indicate where a search filter should be added to a SearchContainer:

- TOP: top left corner
- BOTTOM: bottom
BOTTOM = <SearchFilterPosition value BOTTOM>
TOP = <SearchFilterPosition value TOP>
names = {'TOP': <SearchFilterPosition value TOP>, 'BOTTOM': <SearchFilterPosition value BOTTOM>}
values = {0: <SearchFilterPosition value TOP>, 1: <SearchFilterPosition value BOTTOM>}
class stoqlib.enums.RelativeLocation[source]

Bases: kiwi.python.enum

An enum used to indicate the relative location between two persons

This enum is used by stoq-plugin-nfe We must maintain these values otherwise it will break the plugin

OTHER_COUNTRY = <RelativeLocation value OTHER_COUNTRY>
OTHER_STATE = <RelativeLocation value OTHER_STATE>
SAME_STATE = <RelativeLocation value SAME_STATE>
names = {'OTHER_COUNTRY': <RelativeLocation value OTHER_COUNTRY>, 'OTHER_STATE': <RelativeLocation value OTHER_STATE>, 'SAME_STATE': <RelativeLocation value SAME_STATE>}
values = {1: <RelativeLocation value SAME_STATE>, 2: <RelativeLocation value OTHER_STATE>, 3: <RelativeLocation value OTHER_COUNTRY>}

exceptions Module

Exception and warning definitions

exception stoqlib.exceptions.ConfigError[source]

Bases: exceptions.Exception

Error for config files which don’t have a certain section

exception stoqlib.exceptions.FilePermissionError[source]

Bases: exceptions.Exception

General error for file permissions.

exception stoqlib.exceptions.NoConfigurationError[source]

Bases: exceptions.Exception

Raise this error when we don’t have a config option properly set.

exception stoqlib.exceptions.ModelDataError[source]

Bases: exceptions.Exception

General model data errors

exception stoqlib.exceptions.SellError[source]

Bases: exceptions.Exception

Exceptions for sale operations

exception stoqlib.exceptions.DatabaseInconsistency[source]

Bases: exceptions.Exception

Exceptions for missing data or inconsistency

exception stoqlib.exceptions.DatabaseError(msg, long=None)[source]

Bases: exceptions.Exception

General database errors

There are two ways of raising this exception:

raise DatabaseError(msg) raise DatabaseError(short, msg)

exception stoqlib.exceptions.StockError[source]

Bases: exceptions.Exception

Exception for stock operations

exception stoqlib.exceptions.EditorError[source]

Bases: exceptions.Exception

Exception for stoqlib editors

exception stoqlib.exceptions.SelectionError[source]

Bases: exceptions.Exception

Invalid number of items selected in a list

exception stoqlib.exceptions.TillError[source]

Bases: exceptions.Exception

General Till operation errors

exception stoqlib.exceptions.PaymentError[source]

Bases: exceptions.Exception

General payment errors

exception stoqlib.exceptions.PaymentMethodError[source]

Bases: exceptions.Exception

Error for payment methods

exception stoqlib.exceptions.AdapterError[source]

Bases: exceptions.Exception

Raise this exception when an object try adding a facet but it doesn’t actually implements that interface

exception stoqlib.exceptions.UserProfileError[source]

Bases: exceptions.Exception

Raise when a certain user lacks credentials for an application

exception stoqlib.exceptions.LoginError[source]

Bases: exceptions.Exception

Raise when an username or password is invalid

exception stoqlib.exceptions.SQLError[source]

Bases: exceptions.Exception

Bad syntax for sql scripts

exception stoqlib.exceptions.SellableError[source]

Bases: exceptions.Exception

Errors for sellables

exception stoqlib.exceptions.StoqlibError[source]

Bases: exceptions.Exception

General Error for stoqlib domain classes and dialogs

exception stoqlib.exceptions.InvalidStatus[source]

Bases: exceptions.Exception

Invalid status for the object which the operation was requested

exception stoqlib.exceptions.NeedReason[source]

Bases: exceptions.Exception

The operation needs a reason to be accomplished

exception stoqlib.exceptions.BarcodeDoesNotExists[source]

Bases: exceptions.Exception

There are no products with the specified barcode

exception stoqlib.exceptions.DeviceError[source]

Bases: exceptions.Exception

A problem with a Device such as a fiscal printer

exception stoqlib.exceptions.TaxError[source]

Bases: exceptions.Exception

A problem with taxes such as icms, ipi, etc.

For exemple: this might be raised if the tax rate has expired.

exception stoqlib.exceptions.ReportError[source]

Bases: exceptions.Exception

A problem happened when generating a report

exception stoqlib.exceptions.CertificateException[source]

Bases: exceptions.Exception

A problem happened while configuring a digital certificate

Subpackages