lib Package¶
lib
Package¶
Generic class/method library
algorithms
Module¶
asyncrequests
Module¶
Asynchronous requests utilities.
This module tries to mimic the requests api, providing functions with the same signature as it. The only difference is that the requests here are executed asynchronously on a separated thread.
-
class
stoqlib.lib.asyncrequests.
AsyncRequest
(method, url, callback=None, errback=None, **kwargs)[source]¶ Bases:
threading.Thread
Async request implementation.
Responsible for doing the request asynchronously, and optionally call a callback/errback on success/failure.
-
DEFAULT_TIMEOUT
= 5¶ The default request timeout if none is defined
-
-
stoqlib.lib.asyncrequests.
request
(method, url, callback=None, errback=None, **kwargs)[source]¶ Do a request asynchronously.
Parameters: - method – The http method to use on the request
- url – The url to do the request
- errback – An optional callback to be called if the request produces any error. The traceback object will be passed as an argument to it
Parm callback: An optional callback to be called after the request has been sucessfully executed. The request’s retval will be passed as an argument to it
Returns: The
AsyncRequest
that is running the request. One canthreading.Thread.join()
it when wanting to wait for it to finish
-
stoqlib.lib.asyncrequests.
get
(url, **kwargs)[source]¶ Do a GET request asynchronously.
Parameters: - url – The url to do the request
- kwargs – Extra keywords that will be passed to
request()
Returns: The
AsyncRequest
that is running the request. One canthreading.Thread.join()
it when wanting to wait for it to finish
-
stoqlib.lib.asyncrequests.
post
(url, **kwargs)[source]¶ Do a POST request asynchronously.
Parameters: - url – The url to do the request
- kwargs – Extra keywords that will be passed to
request()
Returns: The
AsyncRequest
that is running the request. One canthreading.Thread.join()
it when wanting to wait for it to finish
appinfo
Module¶
Application global state
autoreload
Module¶
barcode
Module¶
Parse barcodes containing weight or price information, as those printed by scales
-
class
stoqlib.lib.barcode.
BarcodeInfo
(code, price, weight, mode)[source]¶ -
options
= {0: u'4 Digits Code with Price', 1: u'5 Digits Code with Price', 2: u'4 Digits Code with Weight', 3: u'5 Digits Code with Weight', 4: u'6 Digits Code with Weight'}¶
-
modes
= {0: 1, 1: 1, 2: 0, 3: 0, 4: 0}¶
-
digits
= {0: 4, 1: 5, 2: 4, 3: 5, 4: 6}¶
-
MODE_PRICE
= 1¶
-
MODE_WEIGHT
= 0¶
-
OPTION_4_DIGITS_PRICE
= 0¶
-
OPTION_4_DIGITS_WEIGHT
= 2¶
-
OPTION_5_DIGITS_PRICE
= 1¶
-
OPTION_5_DIGITS_WEIGHT
= 3¶
-
OPTION_6_DIGITS_WEIGHT
= 4¶
-
boleto
Module¶
Boleto generation code.
-
stoqlib.lib.boleto.
custom_property
(name, num_length)[source]¶ Function to create properties on boleto
It accepts a number with or without a DV and zerofills it
-
class
stoqlib.lib.boleto.
BankInfo
(payment)[source]¶ Bases:
object
Base class for generating bill information
For each bank, a subclass of this should be created defining how the value is formatted for the bill.
-
aceite
= 'N'¶
-
especie_documento
= 'DM'¶
-
especie
= 'R$'¶
-
moeda
= '9'¶
-
quantidade
= None¶
-
valor
= None¶
-
description
= None¶
-
bank_name
= None¶
-
bank_number
= None¶
-
options
= {}¶
-
logo
= ''¶
-
validate_field_func
= None¶
-
validate_field_dv
= None¶
-
nosso_numero
¶
-
agencia
¶
-
conta
¶
-
get_properties
(payment)[source]¶ Get values necesary for bill emission.
This includes nosso numero, bank agency and bank account.
Also, any other custom options that the bank require will be present here.
-
local_pagamento
¶
-
numero_documento
¶
-
penalty_percentage
¶
-
interest_percentage
¶
-
discount_percentage
¶
-
instrucoes
¶
-
demonstrativo
¶
-
campo_livre
¶
-
barcode
¶
-
dv_nosso_numero
¶ Returns nosso número DV
It should be implemented by derived class
-
dv_agencia
¶
-
dv_conta
¶
-
dv_agencia_conta
¶ Verifier digit for agency and account
Some banks don’t require this. The ones that does, should override this method
-
format_nosso_numero
()[source]¶ Return Formatted Nosso Número for bill printing
It should be implemented by derived class
-
fator_vencimento
¶
-
agencia_conta
¶
-
codigo_dv_banco
¶
-
linha_digitavel
¶ - Linha que o cliente pode utilizar para digitar se o código
- de barras não puder ser lido
Posição Conteúdo 1 a 3 Número do banco 4 Código da Moeda - 9 para Real 5 Digito verificador do Código de Barras 6 a 19 Valor (12 inteiros e 2 decimais) 20 a 44 Campo Livre definido por cada banco
-
-
class
stoqlib.lib.boleto.
BankBanrisul
(payment)[source]¶ Bases:
stoqlib.lib.boleto.BankInfo
-
description
= 'Banrisul'¶
-
bank_number
= 41¶
-
logo
= 'logo_banrisul.jpg'¶
-
options
= {u'agencia': 0, u'conta': 0}¶
-
nosso_numero
¶
-
conta
¶
-
campo_livre
¶
-
-
class
stoqlib.lib.boleto.
BankBradesco
(payment)[source]¶ Bases:
stoqlib.lib.boleto.BankInfo
-
description
= 'Bradesco'¶
-
bank_name
= 'BRADESCO'¶
-
cnab_class
¶ alias of
BradescoCnab
-
bank_number
= 237¶
-
logo
= 'logo_bancobradesco.jpg'¶
-
options
= {u'agencia': 0, u'convenio': 2, u'identificacao_produto': 2, u'conta': 0, u'carteira': 2}¶
-
validate_field_func
= 'modulo11'¶
-
validate_field_dv
= '0'¶
-
nosso_numero
¶
-
agencia
¶
-
conta
¶
-
dv_nosso_numero
¶
-
campo_livre
¶
-
-
class
stoqlib.lib.boleto.
BankBB
(payment)[source]¶ Bases:
stoqlib.lib.boleto.BankInfo
-
description
= 'Banco do Brasil'¶
-
bank_number
= 1¶
-
bank_name
= 'BANCO DO BRASIL'¶
-
logo
= 'logo_bb.gif'¶
-
options
= {u'agencia': 0, u'convenio': 2, u'conta': 0}¶
-
validate_field_func
= 'modulo11'¶
-
validate_field_dv
= 'x'¶
-
agencia
¶
-
conta
¶
-
cnab_class
¶ alias of
BBCnab
-
nosso_numero
¶
-
convenio
¶
-
agencia_conta
¶
-
dv_nosso_numero
¶
-
campo_livre
¶
-
-
class
stoqlib.lib.boleto.
BankCaixa
(payment)[source]¶ Bases:
stoqlib.lib.boleto.BankInfo
-
description
= 'Caixa Econ\xc3\xb4mica Federal'¶
-
bank_name
= 'CAIXA ECONOMICA FEDERAL'¶
-
bank_number
= 104¶
-
cnab_class
¶ alias of
CaixaCnab
-
logo
= 'logo_bancocaixa.jpg'¶
-
options
= {u'agencia': 0, u'codigo_convenio': 2, u'codigo_beneficiario': 2, u'conta': 0, u'carteira': 2}¶
-
inicio_nosso_numero
= '80'¶
-
conta
¶
-
nosso_numero
¶ Nosso Número sem DV, máximo 8 chars
-
dv_nosso_numero
¶
-
campo_livre
¶
-
-
class
stoqlib.lib.boleto.
BankItau
(payment)[source]¶ Bases:
stoqlib.lib.boleto.BankInfo
-
description
= 'Banco Ita\xc3\xba'¶
-
bank_name
= 'BANCO ITAU SA'¶
-
bank_number
= 341¶
-
cnab_class
¶ alias of
ItauCnab400
-
logo
= 'logo_itau.gif'¶
-
options
= OrderedDict([(u'agencia', 0), (u'conta', 0), (u'carteira', 2), (u'instrucao_1', 2), (u'instrucao_2', 2), (u'prazo', 2)])¶
-
nosso_numero
¶
-
agencia
¶
-
conta
¶
-
dac_nosso_numero
¶
-
dv_agencia_conta
¶
-
agencia_conta
¶
-
campo_livre
¶
-
-
class
stoqlib.lib.boleto.
BankReal
(payment)[source]¶ Bases:
stoqlib.lib.boleto.BankInfo
-
description
= 'Banco Real'¶
-
bank_number
= 356¶
-
logo
= 'logo_bancoreal.jpg'¶
-
options
= {u'agencia': 0, u'conta': 0, u'carteira': 2}¶
-
agencia_conta
¶
-
digitao_cobranca
¶
-
campo_livre
¶
-
-
class
stoqlib.lib.boleto.
BankSantander
(payment)[source]¶ Bases:
stoqlib.lib.boleto.BankInfo
-
description
= 'Banco Santander'¶
-
bank_name
= 'Banco Santander'¶
-
bank_number
= 33¶
-
cnab_class
¶ alias of
SantanderCnab
-
logo
= 'logo_santander.jpg'¶
-
options
= {u'agencia': 0, u'codigo_transmissao': 2, u'conta': 0, u'carteira': 2}¶
-
fixo
= '9'¶
-
ios
= '0'¶
-
nosso_numero
¶
-
carteira
= '102'¶
-
campo_livre
¶
-
certutils
Module¶
-
stoqlib.lib.certutils.
init_certdb
()[source]¶ Initialie the certdb, removing the old one if if exists.
-
stoqlib.lib.certutils.
import_pkcs11
(content)[source]¶ Import a pkcs11 (A3) certificate.
Parameters: content – The content of the certificate library
-
stoqlib.lib.certutils.
import_pkcs12
(content, password)[source]¶ Import a pkcs12 (A1) certificate.
Parameters: - content – The content of the certificate file
- password – The certificate password
-
class
stoqlib.lib.certutils.
CertificateManager
[source]¶ Bases:
object
-
setup_certificate
(certificate, password_callback=None, certificate_callback=None)[source]¶ Setup the certificate in the manager.
Setup the certificate and make sure it is ready to be used for signing and transmission.
Parameters: - certificate – The
stoqnfe.domain.cert.NfeCertificate
that is going to be configured - password_callback – A callable that will be used to ask for the certificate password
- certificate_callback – A callable that will be used to decide which if the existing certificates (PKCS11 only) will be used
- certificate – The
-
get_certs
(*args, **kwds)[source]¶ Get the certificate and its key in a temporary file.
This will separate the certificate and the key in temporary files. The path to those files will be yielded in the context, and then removed from the file system.
Note that this only works for PKCS12 since there’s no way to extract the private key from a PKCS11 token.
Returns: (cert_file_path, key_file_path)
-
colorutils
Module¶
Utilities for working with colors
configparser
Module¶
Routines for parsing the configuration file
-
class
stoqlib.lib.configparser.
StoqConfig
[source]¶ -
domain
= 'stoq'¶
-
load_settings
(settings)[source]¶ Load data from a DatabaseSettings object :param settings: the settings object
-
console
Module¶
A debug session for domain objects.
countries
Module¶
crashreport
Module¶
Crash report logic
daemonutils
Module¶
dateutils
Module¶
Utilities for working with dates
-
stoqlib.lib.dateutils.
localnow
()[source]¶ Get the current date according to the local timezone. This is relative to the clock on the computer where Stoq is run.
Return type: datetime.datetime object Returns: right now according to the current locale
-
stoqlib.lib.dateutils.
localtoday
()[source]¶ Get the beginning of the current date according to the local timezone. This is relative to the clock on the computer where Stoq is run.
Return type: datetime.datetime object Returns: today according to the current locale
-
stoqlib.lib.dateutils.
localdate
(year, month, day)[source]¶ Get a date according to the local timezone. This will return a date at midnight for the current locale. This is relative to the clock on the computer where Stoq is run.
Parameters: - year (int) – the year in four digits
- month (int) – the month (1-12)
- day (int) – the day (1-31)
Return type: datetime.datetime object
Returns: a date according to the current locale
-
stoqlib.lib.dateutils.
localdatetime
(year, month, day, hour=0, minute=0, second=0, microsecond=0)[source]¶ Get a datetime according to the local timezone. This will return a date at midnight for the current locale. This is relative to the clock on the computer where Stoq is run.
Parameters: - year (int) – the year in four digits
- month (int) – the month (1-12)
- day (int) – the day (1-31)
- hour (int) – the hour (0-23)
- minute (int) – the minute (0-59)
- second (int) – the second (0-59)
- microsecond (int) – the microsecond (1-99999)
Return type: datetime.datetime object
Returns: a date according to the current locale
-
stoqlib.lib.dateutils.
get_interval_type_items
(with_multiples=False, plural=False, adverb=False)[source]¶ Get a list of items suitable for putting into a combo. You can get three variants, singular, plural or adverb depending on how you want to display it. You can skip multiples if you plan to use them in conjuction with a spinbutton
Parameters: - with_multiples – if multiples such as biweekly and quarterly should be included
- plural – if the plural variant should be used
- adverb – if the adverbial form should be used
Returns: a list of tuples (labels, interval_type)
-
stoqlib.lib.dateutils.
create_date_interval
(interval_type, start_date=None, end_date=None, interval=None, count=None)[source]¶ Generate a bunch of dates given a set of parameters. There are two ways of using this, either as:
- interval_type, interval, count, start_date
or:
- interval_type, start_date, end_date
Parameters: - interval_type – one of the INTERVALTYPE_* above
- intervals – interval between the dates
- count – number of items to create
- start_date – start
date
- end_date – end
date
Returns: a
datetime.rrule.rrule
object
-
stoqlib.lib.dateutils.
interval_type_as_relativedelta
(interval_type)[source]¶ Gets a interval_type as a relativedelta
Returns: a relativedelta
decorators
Module¶
-
class
stoqlib.lib.decorators.
cached_property
(ttl=300)[source]¶ Bases:
object
Decorator for read-only properties evaluated only once within TTL period.
It can be used to created a cached property like this:
import random # the class containing the property must be a new-style class class MyClass(object): # create property whose value is cached for ten minutes @cached_property(ttl=600) def randint(self): # will only be evaluated every 10 min. at maximum. return random.randint(0, 100)
The value is cached in the ‘_cache’ attribute of the object instance that has the property getter method wrapped by this decorator. The ‘_cache’ attribute value is a dictionary which has a key for every property of the object which is wrapped by this decorator. Each entry in the cache is created only when the property is accessed for the first time and is a two-element tuple with the last computed property value and the last time it was updated in seconds since the epoch.
The default time-to-live (TTL) is 300 seconds (5 minutes). Set the TTL to zero for the cached value to never expire.
To expire a cached property value manually just do:
del instance._cache[<property name>]
-
class
stoqlib.lib.decorators.
cached_function
(ttl=300)[source]¶ Bases:
object
Like cached_property but for functions
-
class
stoqlib.lib.decorators.
public
(since=None)[source]¶ A decorator that is used to mark an API public.
It can be used on classes:
@public(since="1.0") class SomeClass: pass
Or a function/method:
@public(since="1.0") def foo(self, arg): pass
There’s an optional argument called since which takes a string and specifies the version in which this api was added.
defaults
Module¶
Default values for applications
-
stoqlib.lib.defaults.
MAX_INT
= 2147483647¶ The max int for 32bits. Should be used instead of sys.maxint since it will be different depending on the cpu’s architecture http://en.wikipedia.org/wiki/2147483647
-
stoqlib.lib.defaults.
get_libc
()[source]¶ Returns an accessor to C library.
Returns: a ctypes.CDLL instance
-
stoqlib.lib.defaults.
get_weekday_start
()[source]¶ Returns the dateutil.relativedelta.weekday based on the current locale.
Returns: a dateutil.realtivedelta.weekday instance
-
stoqlib.lib.defaults.
payment_value_colorize
(column_data)[source]¶ A helper method for payment value columns used to set different colors for negative values
-
stoqlib.lib.defaults.
quantize
(dec, precision=2)[source]¶ Quantities a decimal according to the current settings. if DECIMAL_PRECISION is set to two then everything but the last two decimals will be removed
>>> quantize(Decimal("10.123")) Decimal('10.12')
>>> quantize(Decimal("10.678")) Decimal('10.68')
devicemanager
Module¶
Device handling, probing hardware
-
class
stoqlib.lib.devicemanager.
SerialDevice
(device_name)[source]¶ Bases:
object
An object representing a serial device :attribute device_name: the device name, /dev/ttyXXX
-
class
stoqlib.lib.devicemanager.
DeviceManager
[source]¶ Bases:
object
DeviceManager is responsible for interacting with hardware devices. It optionally uses HAL to probe the system
-
get_serial_devices
()[source]¶ Get a list of serial devices available on the system :returns: a list of
SerialDevice
-
diffutils
Module¶
-
stoqlib.lib.diffutils.
diff_files
(orig, new, verbose=False)[source]¶ Diff two files.
@return: True i the files differ otherwise False :rtype: bool
-
stoqlib.lib.diffutils.
diff_lines
(orig_lines, new_lines, short='<stdin>', verbose=False)[source]¶ Diff two files.
@return: True i the files differ otherwise False :rtype: bool
distutils
Module¶
event
Module¶
-
class
stoqlib.lib.event.
Event
[source]¶ Bases:
kiwi.python.ClassInittableObject
Base class for events
-
returnclass
= None¶
-
classmethod
handle_return_values
(values)[source]¶ Selects an appropriate return value from all callsites
After an callsite has returned a value from this event, this will select the first not None value and return it.
Subclassses can override this if they need to handle multiple return values differently
-
fileutils
Module¶
hashlib misc utilities
-
stoqlib.lib.fileutils.
md5sum_for_filename
(filename)[source]¶ Get the md5sum for the filename in a memory efficient way
Based on: http://stackoverflow.com/questions/1131220/get-md5-hash-of-big-files-in-python
formatters
Module¶
Validators for stoq applications
-
stoqlib.lib.formatters.
get_full_date
(date)[source]¶ Return a date in it’s full format taking l10n in consideration
- For example, for Brazil, it will return something like:
- 01 de janeiro de 2012
- In the generic case, it will return something like:
- January 01, 2012
-
stoqlib.lib.formatters.
format_address
(address, include_district=True)[source]¶ Format the given address to a string.
This expects an
address
, but any object containing the following attributes would suffice: street, streetnumber and district
-
stoqlib.lib.formatters.
format_sellable_description
(sellable, batch=None)[source]¶ Gets the formatted description for sellable
If batch is
None
, the description will be the same as sellable.get_description(). But if is given, it’s number will be appended to the description, like:Normal description: "Cellphone" With batch information: "Cellphone [Batch: 123456]"
interfaces
Module¶
Stoqlib Interfaces
-
interface
stoqlib.lib.interfaces.
ICookieFile
[source]¶ Bases:
zope.interface.Interface
-
get
()¶ Query for an attribute description
-
store
(username, password)¶ Stores a username and password
Parameters: - username – username
- password – password
-
clear
()¶ Resets the cookie
-
-
interface
stoqlib.lib.interfaces.
IApplicationDescriptions
[source]¶ Bases:
zope.interface.Interface
Get a list of application names, useful for launcher programs
-
get_application_names
()¶ Gets a list of application names. :returns: a list of application names.
-
get_descriptions
()¶ Gets a list of tuples with some important Stoq application informations. Each tuple jas the following data: * Application name * Application full name * Application icon name * Application description :returns: a list of tuples with Stoq application informations.
-
-
interface
stoqlib.lib.interfaces.
ISystemNotifier
[source]¶ Bases:
zope.interface.Interface
-
info
(short, description)¶
-
warning
(short, description, *args, **kwargs)¶
-
error
(short, description)¶
-
yesno
(text, default, *verbs)¶
-
-
interface
stoqlib.lib.interfaces.
IPluginManager
[source]¶ Bases:
zope.interface.Interface
A manager for plugins.
-
interface
stoqlib.lib.interfaces.
IPlugin
[source]¶ Bases:
zope.interface.Interface
-
name
= <zope.interface.interface.Attribute object>¶
-
activate
()¶ Called everytime the plugins gets activated
This is where the init plugin logic should be, like events connection and so on.
-
get_migration
()¶ Get the database migration for the plugin
Returns: a stoqlib.database.migration.PluginSchemaMigration
-
get_tables
()¶ Returns a C{list} of domain classes
This should return a C{list} of tuples, each one containing the domain path as the first item, and a list of classes as the second. e.g. A ‘from a.b import C, D’ should be translated into the C{tuple} (‘a.b’, [‘C’, ‘D’]). @note: this information is used for database synchronization
Returns: a C{list} of C{tuple} containing domain info
-
get_server_tasks
()¶ Get a list of tasks that the server will be responsible to run
A task is a object implementing
IPluginTask
.Returns: a list of tasks
-
get_dbadmin_commands
()¶ Returns a list of available commands for dbadmin
Returns: a C{list} of available commands
-
handle_dbadmin_command
(command, options, args)¶ Handle a dbadmin command
Parameters: - command – the command string
- options – extra optparser options
- args – a list of C{args}
-
-
interface
stoqlib.lib.interfaces.
IPluginTask
[source]¶ Bases:
zope.interface.Interface
A plugin task that can run on stoq server
-
name
= <zope.interface.interface.Attribute object>¶
-
handle_actions
= <zope.interface.interface.Attribute object>¶
-
start
(**kwargs)¶ Called to start the task.
Parameters: pipe_connection – the connection used to communicate with the stoqserver api. Will only be present if handle_actions
isTrue
-
-
interface
stoqlib.lib.interfaces.
IPaymentOperation
[source]¶ Bases:
zope.interface.Interface
An object implementing IPaymentOperation is a 1:1 mapping to a payment method. It’s responsible for the logic specific parts of a method.
-
name
= <zope.interface.interface.Attribute object>¶
-
description
= <zope.interface.interface.Attribute object>¶
-
max_installments
= <zope.interface.interface.Attribute object>¶
-
pay_on_sale_confirm
()¶ If we should set the payment as paid when confirming a sale
-
payment_create
(payment)¶ This is called when a payment is created
Parameters: payment – the created payment
-
payment_delete
(payment)¶ This is called just before a payment is deleted
Parameters: payment – the payment which is going to be deleted
-
create_transaction
()¶ - If this payment method should create a transaction when
- paid
Returns: True if an AccountTransaction should be created
-
selectable
(method)¶ This is called to find out if the method should be shown in the slave list of payment methods
Returns: True if it should be shown
-
creatable
(method, payment_type, separate)¶ If it’s possible to create new payments of this payment method type
Parameters: - method – payment method
- payment_type – kind of payment
- separate – if it’s created separately from a sale/purchase
Returns: True if you can create new methods of this type
-
can_cancel
(payment)¶ If it’s possible to cancel a payment
Parameters: payment – the payment to cancel
-
can_change_due_date
(payment)¶ If it’s possible to change the due date of a payment
Parameters: payment – the payment to change due date
-
can_pay
(payment)¶ If it’s possible to pay a payable
Parameters: payment – the payment to pay
-
can_print
(payment)¶ If it’s possible to print this payment
Parameters: payment – the payment to print
-
can_set_not_paid
(payment)¶ If it can be set as not paid once it has been paid
Parameters: payment – the payment to be set as not paid
-
print_
(payment)¶ Prints this payment
Parameters: payment – the payment to print
-
get_constant
(payment)¶ This should return a stoqdriver payment method constant
Parameters: payment – the payment whose method we shout return a stoqdrivers constant Returns: one PaymentMethodConstant
-
require_person
(payment_type)¶ If this payment requires a person to be created
Parameters: payment_type – the kind of payment
-
-
interface
stoqlib.lib.interfaces.
IPaymentOperationManager
[source]¶ Bases:
zope.interface.Interface
This is a singleton for storing payment operations. You can register one and fetch by name
-
get_operation_names
()¶ Get the operation names registered in this manager
Returns: payment names Return type: list of strings
-
register
(name, operation)¶ Register a payment operation.
Parameters: - name – name of the payment operation
- operation (an object implementing
IPaymentOperation
) – the payment operation
-
get
()¶ Query for an attribute description
-
-
interface
stoqlib.lib.interfaces.
IAppInfo
[source]¶ Bases:
zope.interface.Interface
Store global application data, such as name, version.
-
set
(name, value)¶ Sets a variable to value
Parameters: - name – string, variable name
- value – value of the key
-
get
()¶ Query for an attribute description
-
-
interface
stoqlib.lib.interfaces.
IPermissionManager
[source]¶ Bases:
zope.interface.Interface
A permission manager controling what parts of the system are acessible.
To completely disable access to a feature, set permission=0.
-
set
(key, permission)¶ Set the credentials the current user have to access a feature.
If the feature should be completely disabled (user cannot access the feature), permission should be 0.
If the key is a domain object, available credentials are: PERM_SEARCH, PERM_CREATE, PERM_EDIT, PERM_DETAILS. This credentials are used by SearchEditors and will disable/enable create, edit and details button.
If the key is a menu action, the only credential is PERM_ACCESS. If the user has it, he will be allowed to access the feature, oherwise it will be hidden.
Parameters: - key – String identifing the feature. This should be the name of the domain object (Product, Client, etc..), or an identifier for the related menu action (app.admin.new_order, for instance).
- permission – The credentials the current user has for accessing the feature.
-
get
()¶ Query for an attribute description
-
can_search
(key)¶ Returns if the user has permission to search the given feature
-
can_edit
(key)¶ Returns if the user has permission to edit the given feature
-
can_create
(key)¶ Returns if the user has permission to create new objects of the given feature
-
can_see_details
(key)¶ Returns if the user has permission to see details of objects of the given feature
-
introspection
Module¶
Introspection helpers for fetching classes and interfaces
invoice
Module¶
Invoice generation
-
class
stoqlib.lib.invoice.
InvoicePage
(width, height)[source]¶ Bases:
object
This represent a page part of an invoice
-
add
(data_type, x, y, width, height, data)[source]¶ Adds a new field to the page
Parameters: - data_type – data type of the field
- x – x position of the left side of the field
- y – y position of the upper side of the field
- width – width of the field
- height – height of the field
- data – data to be printed at the field. This is dependent of the data type
-
-
class
stoqlib.lib.invoice.
PurchaseInvoice
(purchase, layout)[source]¶ Bases:
stoqlib.lib.invoice._Invoice
-
stoqlib.lib.invoice.
print_sale_invoice
(sale_invoice, invoice_printer)[source]¶ Utility function to print a sale invoice.
Parameters: - sale – a
stoqlib.domain.sale.Sale
instance - invoice_printer –
stoqlib.domain.invoice.InvoicePrinter
instance
- sale – a
-
class
stoqlib.lib.invoice.
InvoiceFieldDescription
(invoice, field)[source]¶ Bases:
object
-
field_type
¶ alias of
str
-
height
= 1¶
-
description
= ''¶
-
name
= None¶
-
category
= ''¶
-
length
= -1¶
-
-
class
stoqlib.lib.invoice.
FreeTextField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'FREE_TEXT'¶
-
description
= 'Free text'¶
-
category
= 'Other'¶
-
length
= 10¶
-
-
class
stoqlib.lib.invoice.
CompanyDocumentField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'COMPANY_DOCUMENT'¶
-
description
= 'Company document number'¶
-
category
= 'Branch'¶
-
length
= 18¶
-
-
class
stoqlib.lib.invoice.
StateRegistryField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'STATE_REGISTRY'¶
-
description
= 'State registry number'¶
-
category
= 'Branch'¶
-
length
= 14¶
-
-
class
stoqlib.lib.invoice.
CityRegistryField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'CITY_REGISTRY'¶
-
description
= 'City registry number'¶
-
category
= 'Branch'¶
-
length
= 14¶
-
-
class
stoqlib.lib.invoice.
InscrEstadualSubstitudoField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'INSCR_ESTADUAL_SUBSTITUTO_TRIB'¶
-
category
= 'Branch'¶
-
length
= 4¶
-
-
class
stoqlib.lib.invoice.
CompanyAddressField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'COMPANY_ADDRESS'¶
-
description
= 'Company address'¶
-
category
= 'Branch'¶
-
length
= 34¶
-
-
class
stoqlib.lib.invoice.
CompanyNameField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'COMPANY_NAME'¶
-
description
= 'Company name'¶
-
category
= 'Branch'¶
-
length
= 34¶
-
-
class
stoqlib.lib.invoice.
CompanyFancyNameField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'COMPANY_FANCY_NAME'¶
-
description
= 'Company fancy name'¶
-
category
= 'Branch'¶
-
length
= 34¶
-
-
class
stoqlib.lib.invoice.
CompanyPostalCodeField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'COMPANY_POSTAL_CODE'¶
-
description
= 'Company postal code'¶
-
category
= 'Branch'¶
-
length
= 8¶
-
-
class
stoqlib.lib.invoice.
CompanyCityLocationField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'COMPANY_CITY_LOCATION'¶
-
description
= 'Company city location'¶
-
category
= 'Branch'¶
-
length
= 8¶
-
-
class
stoqlib.lib.invoice.
SaleNumberField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'SALE_NUMBER'¶
-
category
= 'Sale'¶
-
length
= 1¶
-
-
class
stoqlib.lib.invoice.
SalesPersonNameField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'SALESPERSON_NAME'¶
-
category
= 'Sale'¶
-
length
= 1¶
-
-
class
stoqlib.lib.invoice.
CfopField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'CFOP'¶
-
category
= 'Other'¶
-
length
= 4¶
-
-
class
stoqlib.lib.invoice.
SaleTotalValueField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'VALOR_TOTAL_NOTA'¶
-
category
= 'Sale'¶
-
length
= 1¶
-
field_type
¶ alias of
Decimal
-
-
class
stoqlib.lib.invoice.
AdditionalSaleNotesField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'ADDITIONAL_SALE_NOTES'¶
-
category
= 'Sale'¶
-
lenght
= 1¶
-
-
class
stoqlib.lib.invoice.
SaleTokenField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'SALE_TOKEN_CODE'¶
-
description
= 'Sale token code'¶
-
category
= 'Sale'¶
-
length
= 8¶
-
-
class
stoqlib.lib.invoice.
ProductItemCounterField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'PRODUCT_ITEM_COUNTER'¶
-
description
= 'Product item counter'¶
-
category
= 'Product'¶
-
length
= 3¶
-
field_type
= [<type 'str'>]¶
-
-
class
stoqlib.lib.invoice.
ProductItemCodeDescriptionField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'PRODUCT_ITEM_CODE_DESCRIPTION'¶
-
description
= 'Product item code / description'¶
-
category
= 'Product'¶
-
length
= 35¶
-
field_type
= [<type 'str'>]¶
-
-
class
stoqlib.lib.invoice.
ProductItemDescriptionField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'PRODUCT_ITEM_DESCRIPTION'¶
-
description
= 'Product item description'¶
-
category
= 'Product'¶
-
length
= 30¶
-
field_type
= [<type 'str'>]¶
-
-
class
stoqlib.lib.invoice.
ProductItemCodeField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'PRODUCT_ITEM_CODE'¶
-
description
= 'Product item code'¶
-
category
= 'Product'¶
-
length
= 5¶
-
field_type
= [<type 'str'>]¶
-
-
class
stoqlib.lib.invoice.
ProductItemCodeSituationField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'PRODUCT_ITEM_CODE_SITUATION'¶
-
description
= 'Product item situation'¶
-
category
= 'Product'¶
-
length
= 1¶
-
field_type
= [<type 'str'>]¶
-
-
class
stoqlib.lib.invoice.
ProductItemCodeUnitField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'PRODUCT_ITEM_CODE_UNIT'¶
-
description
= 'Product item unit'¶
-
category
= 'Product'¶
-
length
= 2¶
-
field_type
= [<type 'str'>]¶
-
-
class
stoqlib.lib.invoice.
ProductItemQuantityField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'PRODUCT_ITEM_QUANTITY'¶
-
description
= 'Product item quantity'¶
-
category
= 'Product'¶
-
length
= 5¶
-
field_type
= [<class 'decimal.Decimal'>]¶
-
-
class
stoqlib.lib.invoice.
ProductItemPriceField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'PRODUCT_ITEM_PRICE'¶
-
description
= 'Product item price'¶
-
category
= 'Product'¶
-
length
= 5¶
-
field_type
= [<class 'decimal.Decimal'>]¶
-
-
class
stoqlib.lib.invoice.
ProductItemTotalField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'PRODUCT_ITEM_TOTAL'¶
-
description
= 'Product item total (price * quantity)'¶
-
category
= 'Product'¶
-
length
= 7¶
-
field_type
= [<class 'decimal.Decimal'>]¶
-
-
class
stoqlib.lib.invoice.
ValorTotalProductsField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'VALOR_TOTAL_PRODUTOS'¶
-
category
= 'Product'¶
-
length
= 1¶
-
field_type
¶ alias of
Decimal
-
-
class
stoqlib.lib.invoice.
ClientNameField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'CLIENT_NAME'¶
-
description
= 'Client name'¶
-
category
= 'Client'¶
-
length
= 35¶
-
-
class
stoqlib.lib.invoice.
ClientAddressField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'CLIENT_ADDRESS'¶
-
description
= 'Client Address'¶
-
category
= 'Client'¶
-
length
= 34¶
-
-
class
stoqlib.lib.invoice.
ClientDocumentField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'CLIENT_DOCUMENT'¶
-
description
= "Client's document number"¶
-
category
= 'Client'¶
-
length
= 14¶
-
-
class
stoqlib.lib.invoice.
ClientDistrictField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'CLIENT_DISTRICT'¶
-
description
= "Client's district"¶
-
category
= 'Client'¶
-
length
= 15¶
-
-
class
stoqlib.lib.invoice.
ClientPostalCodeField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'CLIENT_POSTAL_CODE'¶
-
description
= "Client's postal code"¶
-
category
= 'Client'¶
-
length
= 8¶
-
-
class
stoqlib.lib.invoice.
ClientCityField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'CLIENT_CITY'¶
-
description
= "Client's city"¶
-
category
= 'Client'¶
-
length
= 34¶
-
-
class
stoqlib.lib.invoice.
ClientPhoneField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'CLIENT_PHONE'¶
-
description
= 'Client Phone number'¶
-
category
= 'Client'¶
-
length
= 12¶
-
-
class
stoqlib.lib.invoice.
ClientFaxField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'CLIENT_FAX'¶
-
description
= 'Client Fax number'¶
-
category
= 'Client'¶
-
length
= 12¶
-
-
class
stoqlib.lib.invoice.
ClientPhoneFaxField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'CLIENT_PHONE_FAX'¶
-
description
= 'Client Phone/Fax number'¶
-
category
= 'Client'¶
-
length
= 12¶
-
-
class
stoqlib.lib.invoice.
ClientStateField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'CLIENT_STATE'¶
-
description
= 'Client state abbreviation'¶
-
category
= 'Client'¶
-
length
= 2¶
-
-
class
stoqlib.lib.invoice.
ClientStateRegistryDocumentField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'CLIENT_STATE_REGISTRY_DOCUMENT'¶
-
description
= 'Clients state registry number or document number'¶
-
category
= 'Client'¶
-
length
= 14¶
-
-
class
stoqlib.lib.invoice.
PaymentNumbersField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'PAYMENT_NUMBERS'¶
-
description
= 'Number of payments'¶
-
category
= 'Payment'¶
-
length
= 4¶
-
-
class
stoqlib.lib.invoice.
PaymentDueDatesField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'PAYMENT_DUE_DATES'¶
-
description
= 'Payment due dates'¶
-
category
= 'Payment'¶
-
length
= 1¶
-
-
class
stoqlib.lib.invoice.
PaymentValuesField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'PAYMENT_VALUES'¶
-
description
= 'Payment values'¶
-
category
= 'Payment'¶
-
length
= 1¶
-
-
class
stoqlib.lib.invoice.
BaseDeCalculoICMSField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'BASE_DE_CALCULO_ICMS'¶
-
length
= 1¶
-
category
= 'Tax'¶
-
field_type
¶ alias of
Decimal
-
-
class
stoqlib.lib.invoice.
ICMSValueField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'VALOR_ICMS'¶
-
category
= 'Tax'¶
-
length
= 1¶
-
field_type
¶ alias of
Decimal
-
-
class
stoqlib.lib.invoice.
BaseDeCalculoICMSSubstField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'BASE_DE_CALCULO_ICMS_SUBST'¶
-
category
= 'Tax'¶
-
length
= 1¶
-
field_type
¶ alias of
Decimal
-
-
class
stoqlib.lib.invoice.
ValorICMSSubstField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'VALOR_ICMS_SUBST'¶
-
category
= 'Tax'¶
-
length
= 1¶
-
field_type
¶ alias of
Decimal
-
-
class
stoqlib.lib.invoice.
BaseDeCalculoISSField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'BASE_DE_CALCULO_ISS'¶
-
category
= 'Tax'¶
-
length
= 1¶
-
field_type
¶ alias of
Decimal
-
-
class
stoqlib.lib.invoice.
ValorISSField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'VALOR_ISS'¶
-
category
= 'Tax'¶
-
length
= 1¶
-
field_type
¶ alias of
Decimal
-
-
class
stoqlib.lib.invoice.
ValorIPIField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'VALOR_IPI'¶
-
category
= 'Tax'¶
-
length
= 1¶
-
-
class
stoqlib.lib.invoice.
ProductItemTaxField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'PRODUCT_ITEM_TAX'¶
-
description
= 'Product item tax'¶
-
category
= 'Tax'¶
-
length
= 2¶
-
field_type
= [<type 'int'>]¶
-
-
class
stoqlib.lib.invoice.
OutgoingInvoiceField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
field_type
¶ alias of
bool
-
name
= u'OUTGOING_INVOICE'¶
-
description
= 'Outgoing invoice'¶
-
category
= 'Invoice'¶
-
length
= 1¶
-
-
class
stoqlib.lib.invoice.
IncomingInvoiceField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
field_type
¶ alias of
bool
-
name
= u'INCOMING_INVOICE'¶
-
description
= 'Incoming invoice'¶
-
category
= 'Invoice'¶
-
length
= 1¶
-
-
class
stoqlib.lib.invoice.
OrderEmissionDateField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'ORDER_EMISSION_DATE'¶
-
description
= 'Emission date'¶
-
category
= 'Invoice'¶
-
length
= 10¶
-
-
class
stoqlib.lib.invoice.
OrderCreationDateField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'ORDER_CREATION_DATE'¶
-
description
= 'Creation date'¶
-
category
= 'Invoice'¶
-
length
= 10¶
-
-
class
stoqlib.lib.invoice.
OrderCreationTimeField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'ORDER_CREATION_TIME'¶
-
description
= 'Creation time'¶
-
category
= 'Invoice'¶
-
length
= 8¶
-
-
class
stoqlib.lib.invoice.
InvoiceNumberField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'INVOICE_NUMBER'¶
-
description
= u'Invoice number'¶
-
category
= 'Invoice'¶
-
length
= 6¶
-
-
class
stoqlib.lib.invoice.
InvoiceTypeField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'INVOICE_TYPE'¶
-
description
= 'Invoice Type'¶
-
category
= 'Invoice'¶
-
length
= 10¶
-
-
class
stoqlib.lib.invoice.
ServiceItemCodeDescriptionField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'SERVICE_ITEM_CODE_DESCRIPTION'¶
-
description
= 'Service item code / description'¶
-
category
= 'Service'¶
-
length
= 35¶
-
field_type
= [<type 'str'>]¶
-
-
class
stoqlib.lib.invoice.
ServiceItemDescriptionField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'SERVICE_ITEM_DESCRIPTION'¶
-
description
= 'Service item description'¶
-
category
= 'Service'¶
-
length
= 30¶
-
field_type
= [<type 'str'>]¶
-
-
class
stoqlib.lib.invoice.
ServiceItemCodeField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'SERVICE_ITEM_CODE'¶
-
description
= 'Service item code'¶
-
category
= 'Service'¶
-
length
= 5¶
-
field_type
= [<type 'str'>]¶
-
-
class
stoqlib.lib.invoice.
ServiceItemCodeUnitField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'SERVICE_ITEM_CODE_UNIT'¶
-
description
= 'Service item unit'¶
-
category
= 'Service'¶
-
length
= 2¶
-
field_type
= [<type 'str'>]¶
-
-
class
stoqlib.lib.invoice.
ServiceItemQuantityField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'SERVICE_ITEM_QUANTITY'¶
-
description
= 'Service item quantity'¶
-
category
= 'Service'¶
-
length
= 5¶
-
field_type
= [<class 'decimal.Decimal'>]¶
-
-
class
stoqlib.lib.invoice.
ServiceItemPriceField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'SERVICE_ITEM_PRICE'¶
-
description
= 'Service item price'¶
-
category
= 'Service'¶
-
length
= 5¶
-
field_type
= [<class 'decimal.Decimal'>]¶
-
-
class
stoqlib.lib.invoice.
ServiceItemTotalField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'SERVICE_ITEM_TOTAL'¶
-
description
= 'Service item total (price * quantity)'¶
-
category
= 'Service'¶
-
length
= 7¶
-
field_type
= [<class 'decimal.Decimal'>]¶
-
-
class
stoqlib.lib.invoice.
ServiceItemTaxField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'SERVICE_ITEM_TAX'¶
-
description
= 'Service item tax'¶
-
category
= 'Service'¶
-
length
= 2¶
-
field_type
= [<type 'int'>]¶
-
-
class
stoqlib.lib.invoice.
ValorTotalServicosField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'VALOR_TOTAL_SERVICOS'¶
-
category
= 'Service'¶
-
length
= 1¶
-
field_type
¶ alias of
Decimal
-
-
class
stoqlib.lib.invoice.
ValorFreteField
(invoice, field)[source]¶ Bases:
stoqlib.lib.invoice.InvoiceFieldDescription
-
name
= u'VALOR_FRETE'¶
-
category
= 'Other'¶
-
length
= 1¶
-
imageutils
Module¶
Utilities for working with images.
Some of those functions were borrowed from datagrid_gtk3: https://github.com/nowsecure/datagrid-gtk3/blob/master/datagrid_gtk3/utils/imageutils.py
-
stoqlib.lib.imageutils.
image2pixbuf
(image)[source]¶ Convert a PIL image to a pixbuf.
Parameters: image (PIL.Image) – the image to convert Returns: the newly created pixbuf Return type: GdkPixbuf.Pixbuf
-
stoqlib.lib.imageutils.
add_border
(image, border_size=5, background_color=(255, 255, 255, 255))[source]¶ Add a border to the image.
Parameters: - image (PIL.Image) – the image to add the border
- border_size (int) – the size of the border
- background_color (tuple) – the color of the border as a tuple containing (r, g, b, a) information
Returns: the new image with the border
Return type: PIL.Image
-
stoqlib.lib.imageutils.
add_drop_shadow
(image, iterations=3, border_size=2, offset=(2, 2), shadow_color=(0, 0, 0, 255))[source]¶ Add a drop shadow to the image.
- Based on this receipe::
- http://en.wikibooks.org/wiki/Python_Imaging_Library/Drop_Shadows
Parameters: - image (PIL.Image) – the image to add the drop shadow
- iterations (int) – number of times to apply the blur filter
- border_size (int) – the size of the border to add to leave space for the shadow
- offset (tuple) – the offset of the shadow as (x, y)
- shadow_color (tuple) – the color of the shadow as a tuple containing (r, g, b, a) information
Returns: the new image with the drop shadow
Return type: PIL.Image
-
stoqlib.lib.imageutils.
get_thumbnail
(image_bytes, size)[source]¶ Generate a thumbnail of the image by the given size.
Parameters: - image_bytes (str) – The image bytes (e.g. the image from the database)
- size (tuple) – The size to generate the thumbnail
Returns: The thumbnail image
Return type: str
-
stoqlib.lib.imageutils.
get_pixbuf
(image_bytes, draw_border=True, fill_image=None)[source]¶ Render image into a pixbuf doing the necessary transformations.
Parameters: - image_bytes (str) – The image bytes (e.g. the image from the database)
- draw_border (bool) – if we should add a border on the image
- fill_image (tuple) – If we should fill the image with a transparent background to make a smaller image be at least a square of (size, size), with the real image at the center.
Returns: the resized pixbuf
Return type: GdkPixbuf.Pixbuf
kiwilibrary
Module¶
latscii
Module¶
Character mapping codec which removes accents from latin-1 characters
Written by Skip Montanaro (skip@pobox.com) using the autogenerated cp1252 codec as an example.
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY. (c) Copyright 2000 Guido van Rossum.
message
Module¶
Notifications and messages for stoqlib applications
osutils
Module¶
-
stoqlib.lib.osutils.
get_application_dir
(appname='stoq')[source]¶ Fetches a application specific directory, this can be used to save temporary files and other state. This also creates the directory if it doesn’t exist :returns: the application directory
-
stoqlib.lib.osutils.
read_registry_key
(root, key, value)[source]¶ Reads a registry key and return it’s value. None is returned if the value couldn’t be read
-
stoqlib.lib.osutils.
list_recursively
(directory, pattern)[source]¶ Returns files recursively from directory matching pattern :param directory: directory to list :param pattern: glob mattern to match
-
stoqlib.lib.osutils.
find_program
(program)[source]¶ Looks for program in PATH. :param program: name of the program to find :returns: the complete path of the program or None if it couldn’t be found
parameters
Module¶
Parameters and system data for applications
-
class
stoqlib.lib.parameters.
ParameterDetails
(key, group, short_desc, long_desc, type, initial=None, options=None, combo_data=None, range=None, multiline=False, validator=None, change_callback=None, editor=None, wrap=True, allow_none=False, is_editable=True, check_missing=None)[source]¶ Bases:
object
-
class
stoqlib.lib.parameters.
ParameterAccess
[source]¶ Bases:
object
API for accessing and updating system parameters
-
ensure_system_parameters
(store, update=False)[source]¶ Parameters: update – True
if we’re upgrading a database, otherwiseFalse
-
set_bool
(store, param_name, value)[source]¶ Updates a database bool value for a given parameter.
Parameters: - store – a database store
- param_name – the parameter name
- value (bool) – the value to set
-
get_bool
(param_name)[source]¶ Fetches a bool database value.
Parameters: param_name – the parameter name Returns: the database value Return type: bool
-
set_decimal
(store, param_name, value)[source]¶ Updates a database decimal value for a given parameter.
Parameters: - store – a database store
- param_name – the parameter name
- value (decimal.Decimal) – the value to set
-
get_decimal
(param_name)[source]¶ Fetches a decimal database value.
Parameters: param_name – the parameter name Returns: the database value Return type: decimal.Decimal
-
set_int
(store, param_name, value)[source]¶ Updates a database int value for a given parameter.
Parameters: - store – a database store
- param_name – the parameter name
- value (int) – the value to set
-
get_int
(param_name)[source]¶ Fetches an int database value.
Parameters: param_name – the parameter name Returns: the database value Return type: int
-
set_string
(store, param_name, value)[source]¶ Updates a database unicode value for a given parameter.
Parameters: - store – a database store
- param_name – the parameter name
- value (unicode) – the value to set
-
get_string
(param_name)[source]¶ Fetches a unicode database value.
Parameters: param_name – the parameter name Returns: the database value Return type: unicode
-
set_object
(store, param_name, value)[source]¶ Updates a database object.
Parameters: - store – a database store
- param_name – the parameter name
- value (a domain object) – the value to set
-
get_object
(store, param_name)[source]¶ Fetches an object from the database.
- ..note..:: This has to query the database to build an object and
- it is slower than other getters, avoid it if you can.
Parameters: - store – a database store
- param_name – the parameter name
Returns: the object
-
get_object_id
(param_name)[source]¶ Fetches the database object id
Parameters: param_name – the parameter name Returns: the object id
-
has_object
(param_name)[source]¶ Check if an object is set.
Parameters: param_name – the parameter name
-
compare_object
(param_name, other_object)[source]¶ Compare the currently set value of a parameter with a specified object.
Parameters: - param_name – the parameter name
- other_object – object to compare
-
permissions
Module¶
pluginmanager
Module¶
-
class
stoqlib.lib.pluginmanager.
PluginDescription
(filename, is_egg=False)[source]¶ Bases:
object
-
dirname
¶
-
-
class
stoqlib.lib.pluginmanager.
PluginManager
[source]¶ Bases:
object
A class responsible for administrating plugins
This class is responsible for administrating plugins, like, controlling which one is available/installed/actived or not. @important: Never instantialize this class. Always use
-
egg_plugins_names
¶ A list of names of all plugins installed as eggs
-
available_plugins_names
¶ A list of names of all available plugins
-
installed_plugins_names
¶ A list of names of all installed plugins as a getter
This getter should be avoided, and should be replaced by get_installed_plugins_names(). A more generic implementation of this.
-
active_plugins_names
¶ A list of names of all active plugins
-
download_plugin
(plugin_name)[source]¶ Download a plugin from webservice
Parameters: plugin_name – the name of the plugin to download Returns: a deferred
-
get_plugin
(plugin_name)[source]¶ Returns a plugin by it’s name
Parameters: plugin_name – the plugin’s name Returns: the IPlugin
implementation of the plugin
-
get_description_by_name
(plugin_name)[source]¶ Returns the plugin’s description given a plugin’s name
Returns: the PluginDescription
for the plugin
-
register_plugin
(plugin)[source]¶ Registers a plugin on manager
This needs to be called by every plugin, or else, the manager won’t know it’s existence. It’s usually a good idea to use
register_plugin
function on plugin code, so the plugin will be registered as soon as it’s module gets read by python.Parameters: plugin – the IPlugin
implementation of the plugin
-
activate_plugin
(plugin_name)[source]¶ Activates a plugin
This will activate the C{plugin}, calling it’s C{activate} method and possibly doing some extra logic (e.g. logging).
Parameters: - important – Always activate a plugin using this method because the manager keeps track of all active plugins. Else you probably will activate the same plugin twice, and that probably won’t be good :)
- plugin – the
IPlugin
implementation of the plugin
-
pre_install_plugin
(store, plugin_name)[source]¶ Pre Install Plugin
Registers an intention to activate a plugin, that will require further actions to enable when running stoq later, like downloading the plugin from stoq.link.
-
install_plugin
(store, plugin_name)[source]¶ Install and enable a plugin
- @important: Calling this makes a plugin installed, but, it’s
- your responsability to activate it!
Parameters: plugin – the IPlugin
implementation of the plugin
-
activate_installed_plugins
()[source]¶ Activate all installed plugins
A helper method to activate all installed plugins in just one call, without having to get and activate one by one.
-
is_active
(plugin_name)[source]¶ Returns if a plugin with a certain name is active or not.
Returns: True if the given plugin name is active, False otherwise.
-
-
stoqlib.lib.pluginmanager.
register_plugin
(plugin_class)[source]¶ Registers a plugin on IPluginManager
Just a convenience function that can be added at the end of each plugin class definition to register it on manager.
Parameters: plugin_class – class to register, must implement IPlugin
-
stoqlib.lib.pluginmanager.
get_plugin_manager
()[source]¶ Provides and returns the plugin manager
- @attention: Try to always use this instead of getting the utillity
- by hand, as that could not have been provided before.
Returns: an PluginManager
instance
process
Module¶
Platform abstracted Process utilitites
services
Module¶
session
Module¶
-
class
stoqlib.lib.session.
NssResponse
(response)[source]¶ Bases:
object
Nss response object.
This maps the nss response os a request to the same API that requests used, making it easier to exchange one for another
-
content
¶
-
-
class
stoqlib.lib.session.
NssSession
[source]¶ Bases:
object
Nss session to communicate with Sefaz using a certificate.
When using this, make sure to
init()
it andshutdown()
after. This is specially important for A3 certificates so it can free the token for the signature code to work. The easies way for doing that is by using a contextmanager like:>> with NssSession() as s: .. s.post('some_url')
-
SCHEME_PORT_MAP
= {'http': 80, 'https': 443}¶
-
settings
Module¶
Routines for parsing user configuration settings
sintegra
Module¶
-
class
stoqlib.lib.sintegra.
SintegraFile
[source]¶ Bases:
object
-
add
(register)[source]¶ Adds a register to the file :param register: a register :type register:
SintegraRegister
-
add_header
(cgc, estadual, company, city, state, fax, start, end)[source]¶ Receive values to generate Sintegra Register type 10.
Parameters: - cgc – the branch CNPJ number.
- estadual – the branch ‘Inscrição estadual’ number or ISENTO.
- company – the company fancy name.
- city – the branch city.
- state – the branch city state.
- fax – the branch fax number.
- start (datetime.date) – start’s date period, generally, the 1th month day.
- end (datetime.date) – end’s date periodo, generally, the last month day.
-
add_complement_header
(address, number, complement, district, postal, name, phone)[source]¶ Receive values to generate Sintegra Register type 11.
Parameters: - address – the branch address.
- number – the number of the branch address.
- complement – the complement of the branch address.
- district – district of the branch address.
- postal – postal code number of the branch address.
- name – the branch manager name.
- phone – the branch phone number.
-
add_fiscal_coupon
(date, printerserial, printerid, coupon_start, coupon_end, crz, cro, period_total, total)[source]¶ Receive values for generate 60M Sintegra Register.
Parameters: - date (datetime.date) – emission date of the fiscal coupon.
- printerserial – serial number of the fiscal printer.
- printerid – the refered number (id) for the fiscal printer in a branch.
- coupon_start – the number in which the coupon fiscal starts.
- coupon_end – the number in which the fiscal coupon ends.
- crz – counter the number of ‘Zs reduction’ made by fiscal printer.
- cro – counter how many times the fiscal printer was restarted their operations.
- period_total – value total in a fiscal day.
- total – total acumulated in fiscal printer.
-
add_fiscal_tax
(date, printerserial, code, value)[source]¶ Receive values for generate 60A Sintegra Register. :param date: emission date of the fiscal coupon. :type date: datetime.date :param printerserial: serial number of the fiscal printer. :param code: the tax code. :param value: the tax value.
-
add_products_summarized
(date, product_code, product_quantity, total_liquido_produto, total_icms_base, icms_aliquota)[source]¶
-
add_receiving_order
(cnpj, state_registry, receival_date, state, modelo, serial, numero, cfop, emitente, total, icms_base, icms_total, isenta, outras, aliquota_icms, situacao)[source]¶
-
add_receiving_order_item
(cnpj, modelo, serial, numero, cfop, cst, numero_item, product_code, product_quantity, valor_bruto_produto, desconto, icms_base, icms_subst_trib, ipi, icms_aliquota)[source]¶
-
add_inventory_item
(start, product_code, product_quantity, total_product_value, owner_code, owner_cnpj, owner_state_registry, state)[source]¶
-
add_product
(start, end, product_code, ncm, desc, unit, aliquota_ipi, aliquota_icms, reducao_icms, base_icms)[source]¶
-
-
class
stoqlib.lib.sintegra.
SintegraRegister
(*args, **kwargs)[source]¶ Bases:
object
This is an abstract class The arguments depends on what is defined in the class variable sintegra_fields
Variables: -
sintegra_number
= 0¶
-
sintegra_fields
= None¶
-
sintegra_unique
= False¶
-
sintegra_requires
= None¶
-
-
class
stoqlib.lib.sintegra.
SintegraRegister10
(*args, **kwargs)[source]¶ Bases:
stoqlib.lib.sintegra.SintegraRegister
-
sintegra_number
= 10¶
-
sintegra_fields
= [('cgc', 14, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('estadual', 14, <type 'basestring'>), ('company', 35, <type 'basestring'>), ('city', 30, <type 'basestring'>), ('state', 2, <type 'basestring'>), ('fax', 10, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('start_date', 8, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('end_date', 8, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('codes', 3, <type 'basestring'>)]¶
-
sintegra_unique
= True¶
-
-
class
stoqlib.lib.sintegra.
SintegraRegister11
(*args, **kwargs)[source]¶ Bases:
stoqlib.lib.sintegra.SintegraRegister
-
sintegra_number
= 11¶
-
sintegra_fields
= [('place', 34, <type 'basestring'>), ('number', 5, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('complement', 22, <type 'basestring'>), ('dibasestringict', 15, <type 'basestring'>), ('postal', 8, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('name', 28, <type 'basestring'>), ('phone', 12, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>))]¶
-
sintegra_requires
= (10,)¶
-
sintegra_unique
= True¶
-
-
class
stoqlib.lib.sintegra.
SintegraRegister60M
(*args, **kwargs)[source]¶ Bases:
stoqlib.lib.sintegra.SintegraRegister
-
sintegra_number
= 60¶
-
sintegra_fields
= [('type', 1, <type 'basestring'>), ('date', 8, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('printerserial', 20, <type 'basestring'>), ('printerid', 3, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('model', 2, <type 'basestring'>), ('start_coo', 6, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('end_coo', 6, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('crz', 6, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('cro', 3, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('period_total', 16, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('total', 16, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>))]¶
-
sintegra_requires
= (10, 11)¶
-
-
class
stoqlib.lib.sintegra.
SintegraRegister60A
(*args, **kwargs)[source]¶ Bases:
stoqlib.lib.sintegra.SintegraRegister
-
sintegra_number
= 60¶
-
sintegra_fields
= [('type', 1, <type 'basestring'>), ('date', 8, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('printerserial', 20, <type 'basestring'>), ('tax', 4, <type 'basestring'>), ('total', 12, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>))]¶
-
sintegra_requires
= (10, 11)¶
-
-
class
stoqlib.lib.sintegra.
SintegraRegister60R
(*args, **kwargs)[source]¶ Bases:
stoqlib.lib.sintegra.SintegraRegister
-
sintegra_number
= 60¶
-
sintegra_fields
= [('type', 1, <type 'basestring'>), ('date', 6, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('product_code', 14, <type 'basestring'>), ('product_quantity', 13, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('total_liquido_produto', 16, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('total_icms_base', 16, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('icms_aliquota', 4, <type 'basestring'>), ('blank', 54, <type 'basestring'>)]¶
-
-
class
stoqlib.lib.sintegra.
SintegraRegister50
(*args, **kwargs)[source]¶ Bases:
stoqlib.lib.sintegra.SintegraRegister
-
sintegra_number
= 50¶
-
sintegra_fields
= [('cnpj', 14, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('estadual', 14, <type 'basestring'>), ('date', 8, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('state', 2, <type 'basestring'>), ('modelo', 2, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('serial', 3, <type 'basestring'>), ('numero', 6, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('cfop', 4, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('emitente', 1, <type 'basestring'>), ('total', 13, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('icms_base', 13, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('icms_total', 13, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('isenta', 13, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('outras', 13, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('aliquota_icms', 4, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('situacao', 1, <type 'basestring'>)]¶
-
-
class
stoqlib.lib.sintegra.
SintegraRegister54
(*args, **kwargs)[source]¶ Bases:
stoqlib.lib.sintegra.SintegraRegister
-
sintegra_number
= 54¶
-
sintegra_fields
= [('cnpj', 14, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('modelo', 2, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('serial', 3, <type 'basestring'>), ('numero', 6, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('cfop', 4, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('cst', 3, <type 'basestring'>), ('numero_item', 3, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('product_code', 14, <type 'basestring'>), ('product_quantity', 11, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('valor_bruto_produto', 12, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('desconto', 12, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('icms_base', 12, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('icms_subst_trib', 12, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('ipi', 12, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('icms_aliquota', 4, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>))]¶
-
-
class
stoqlib.lib.sintegra.
SintegraRegister74
(*args, **kwargs)[source]¶ Bases:
stoqlib.lib.sintegra.SintegraRegister
-
sintegra_number
= 74¶
-
sintegra_fields
= [('inventory_date', 8, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('product_code', 14, <type 'basestring'>), ('product_quantity', 13, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('total_product_value', 13, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('owner_code', 1, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('owner_cnpj', 14, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('owner_state_registry', 14, <type 'basestring'>), ('state', 2, <type 'basestring'>), ('blank', 45, <type 'basestring'>)]¶
-
-
class
stoqlib.lib.sintegra.
SintegraRegister75
(*args, **kwargs)[source]¶ Bases:
stoqlib.lib.sintegra.SintegraRegister
-
sintegra_number
= 75¶
-
sintegra_fields
= [('start_date', 8, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('end_date', 8, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('product_code', 14, <type 'basestring'>), ('ncm', 8, <type 'basestring'>), ('descricao', 53, <type 'basestring'>), ('unit', 6, <type 'basestring'>), ('aliquota_ipi', 5, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('aliquota_icms', 4, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('reducao_icms', 5, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('base_icms', 13, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>))]¶
-
-
class
stoqlib.lib.sintegra.
SintegraRegister90
(*args, **kwargs)[source]¶ Bases:
stoqlib.lib.sintegra.SintegraRegister
-
sintegra_number
= 90¶
-
sintegra_fields
= [('cgc', 14, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('estadual', 14, <type 'basestring'>), ('type', 2, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('registers', 8, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>)), ('blank', 85, <type 'basestring'>), ('number', 1, (<type 'int'>, <type 'long'>, <class 'decimal.Decimal'>))]¶
-
sintegra_requires
= (10, 11)¶
-
sintegragenerator
Module¶
Generate a Sintegra archive from the Stoqlib domain classes
-
class
stoqlib.lib.sintegragenerator.
StoqlibSintegraGenerator
(store, start, end)[source]¶ Bases:
object
This class is responsible for generating a sintegra file from the Stoq domain classes.
-
stoqlib.lib.sintegragenerator.
generate
(filename, start, end)[source]¶ Generate a sintegra file for all changes in the system between start and end dates. Start and end are normally the first and last day of a month
Parameters: - filename – filename to save the sintegra file
- start (datetime.date) – start date
- end – end date
stringutils
Module¶
Utilities for manipulating strings
-
stoqlib.lib.stringutils.
next_value_for
(value)[source]¶ Generate the next value for value.
For instance 4 -> 5, 99 -> 100, A83 -> A84 etc:
>>> next_value_for(u'999') u'1000' >>> next_value_for(u'1') u'2' >>> next_value_for(u'abc') u'abd' >>> next_value_for(u'XYZ') u'XZ0' >>> next_value_for(u'AB00099') u'AB00100'
Parameters: value (unicode) – Returns: Return type: unicode
-
stoqlib.lib.stringutils.
max_value_for
(values)[source]¶ Get the maximum value from the values
Python compares strings from left to right and thus comparisons like ‘9’ > ‘10’ would be true.
This avoid that problem by 0-“padding” the strings to the same length of the longest string on the sequence. Because of that, the return value will be in that format. For instance:
>>> max_value_for([u'1', u'2']) u'2' >>> max_value_for([u'99', u'100']) u'100' >>> max_value_for([u'99', u'0001']) u'0099'
Parameters: values – a sequence of strings Returns: the greatest string on the sequence
template
Module¶
Templating
threadutils
Module¶
Utilities to work with threading
translation
Module¶
Translation utilities for stoqlib
unittestutils
Module¶
uptime
Module¶
Application uptime
validators
Module¶
Validators for stoq applications
-
stoqlib.lib.validators.
is_date_in_interval
(date, start_date, end_date)[source]¶ Check if a certain date is in an interval. The function accepts None values for start_date and end_date and, in this case, return True if there is no interval to check.
-
stoqlib.lib.validators.
validate_cnpj
(cnpj)[source]¶ Validates a cnpj.
Parameters: cnpj – the cnpj to validate. Can be a string or number. If it’s a string, only the digits will be used.
-
stoqlib.lib.validators.
validate_cfop
(cfop)[source]¶ Validates C.F.O.P. code
Valid C.F.O.P. format: ‘9.999’, where 9 is any digit in 0-9.
-
stoqlib.lib.validators.
validate_int
(value)[source]¶ Validates an integer.
Returns if the value is a valid integer, or, in case it’s a string, if it can be converted to an integer.
-
stoqlib.lib.validators.
validate_decimal
(value)[source]¶ Validates an Decimal.
Returns if the value is a valid Decimal, or, in case it’s a string, if it can be converted to an Decimal.
webservice
Module¶
Web Service APIs
-
stoqlib.lib.webservice.
get_main_cnpj
(store)[source]¶ Get the MAIN_COMPANY’ cnpj without ORM interaction
ibpt
Module¶
Identify and apply to a product, the defined taxes by IBPT - Instituto Brasileiro de Planejamento Tributário (Brazilian Institute of Tributary Planning) According to Law 12,741 of 12/08/2012 - Taxes in Coupon.
-
class
stoqlib.lib.ibpt.
TaxInfo
(nacionalfederal, importadosfederal, estadual, fonte, chave)¶ Bases:
tuple
-
chave
¶ Alias for field number 4
-
estadual
¶ Alias for field number 2
-
fonte
¶ Alias for field number 3
-
importadosfederal
¶ Alias for field number 1
-
nacionalfederal
¶ Alias for field number 0
-
-
stoqlib.lib.ibpt.
load_taxes_csv
()[source]¶ Load the fields of IBPT table.
- Fields:
- ncm: Nomenclatura Comum do Sul.
- ex: Exceção fiscal da NCM.
- tipo: Código que pertence a uma NCM.
- descricao: Nome do produto.
- nacionalfederal: Carga tributária para os produtos nacionais.
- importadosfederal: Carga tributária para os produtos importados.
- estadual: Carga tributária estadual
- municipal: Carga tributária municipal
- vigenciainicio: Data de início da vigência desta alíquota.
- vigenciafim: Data de fim da vigência desta alíquota.
- chave: Chave que associa a Tabela IBPT baixada com a empresa.
- versao: Versão das alíquotas usadas para cálculo.
- Fonte: Fonte
xmlutils
Module¶
-
class
stoqlib.lib.xmlutils.
BaseTag
[source]¶ Bases:
lxml.etree.ElementBase
-
setup
()[source]¶ Setup hook for this tag.
Subclasses can override this if they need to create children nodes, but they always need to return self.
-
validate
(xsd_file)[source]¶ Validates this xml against the given xsd filename.
Raises: XmlValidationException
if the xml is not valid
-
-
class
stoqlib.lib.xmlutils.
Signature
[source]¶ Bases:
stoqlib.lib.xmlutils.BaseTag
-
NAMESPACE
= 'http://www.w3.org/2000/09/xmldsig#'¶
-