endi.models package

Subpackages

Submodules

endi.models.action_manager module

class endi.models.action_manager.Action(name, permission, prev_status=None, callback=None, status_attr=None, userid_attr=None, datetime_attr=None, **kwargs)

Bases : object

a state object with a name, permission and a callback callbacktion :param name: The state name :param permission: The permission needed to set this state :param callback: A callback function to call on state process :param status_attr: The attribute storing the model’s status :param userid_attr: The attribute storing the status person’s id :param prev_status: the allowed previous status (None to allow all)

allowed(context, request)

return True if this state assignement on context is allowed in the current request

Paramètres:
  • context (obj) – An object with acl

  • request (obj) – The Pyramid request object

Renvoie:

True/False

Type renvoyé:

bool

process(model, request, user_id, **kw)

Process the action

Set the model’s status_attr if needed (status) Set the model’s status user_id attribute if needed (status_user_id)

Fire a callback if needed

class endi.models.action_manager.ActionManager

Bases : object

add(action)
check_allowed(action_name, context, request)

Check that the given status could be set on the current context

Paramètres:
  • action_name (str) – The name of the action

  • context (obj) – The context to manage

  • request (obj) – The current request object

Raises:

Forbidden if the action isn’t allowed

Raises:

BadRequest if the action doesn’t exists

get_allowed_actions(request, context=None)

Return the list of next available actions regarding the current user perm’s

process(action_name, context, request, **params)

Process a specific action

Paramètres:
  • action_name (str) – The name of the action

  • context (obj) – The context to manage

  • request (obj) – The current request object

  • params (dict) – The params to pass to the callback

Raises:

colander.Invalid if the action is unknown

Raises:

Forbidden if the action is not allowed for the current request

endi.models.action_manager.get_validation_state_manager(data_type: str, userid_attr: str = 'status_user_id', datetime_attr: str = 'status_date', callbacks: dict = {}) ActionManager

Return a state machine handling the basic states

Paramètres:
  • datetime_attr – the attribute storing the last status change

  • data_type – estimation/invoice/cancelinvoice/expensesheet

  • userid_attr – the attribute holding the user who changed status

Renvoie:

An action manager machine that can be used to perform state

changes

endi.models.activity module

Models related to activities :

Activity Types Activities

class endi.models.activity.Activity(**kwargs)

Bases : Event

An activity model

action
action_id
property action_label
action_label_obj
attendances
children
companies
conseillers
created_at
datetime
documents
duration
file_requirements
files
id
mode
name
notes
objectifs
owner
owner_id
parent: Any
parent_id
point
signup_mode
status
statuses
subaction_id
property subaction_label
subaction_label_obj
type_
type_id
type_object
updated_at
class endi.models.activity.ActivityAction(**kwargs)

Bases : Base

active
children
id
label
parent
parent_id
class endi.models.activity.ActivityMode(**kwargs)

Bases : Base

id
label
class endi.models.activity.ActivityType(**kwargs)

Bases : Base

active
id
label
class endi.models.activity.Attendance(user=None, account_id=None, status=None)

Bases : Base

Relationship table used to store the attendance of a user for a given event

account_id
duplicate()
event
event_id
status
user
class endi.models.activity.Event(**kwargs)

Bases : Node

An event model

attendances
children
created_at
datetime
file_requirements
files
id
is_participant(user_id)

Return True if the user_id is one of a participant

user_id

Id of the user we’re asking the information for

name
owner
owner_id
parent: Any
parent_id
participants = ObjectAssociationProxyInstance(AssociationProxy('attendances', 'user'))
signup_mode
property sorted_attendances
property sorted_participants
status
statuses
type_
updated_at
user_status(user_id)

Return a user’s status for this given timeslot

user_id

Id of the user we’re asking the attendance status for

endi.models.activity.get_activity_years(kw=None)

Return a cached query for the years we have activities in database

Paramètres:

kw – is here only for API compatibility

endi.models.career_path module

class endi.models.career_path.CareerPath(**kwargs)

Bases : Base

Different career path stages

amendment_number
cae_situation
cae_situation_id
career_stage
career_stage_id
employee_quality
employee_quality_id
end_date
file_rel
files = ObjectAssociationProxyInstance(AssociationProxy('file_rel', 'related_file'))
goals_amount
goals_period
hourly_rate_string
id
motif_sortie
motif_sortie_id
num_hours
parcours_salary
classmethod query(user=None)

return a query

stage_type
start_date
taux_horaire
type_contrat
type_contrat_id
type_sortie
type_sortie_id
userdatas
userdatas_id
class endi.models.career_path.CareerPathFileRel(**kwargs)

Bases : Base

Relationship between userdata’s files and career path

career_path_id
file_id
related_file
class endi.models.career_path.EmployeeQualityOption(**kwargs)

Bases : ConfigurableOption

Different values for employee quality

active
id
label
order
type_
class endi.models.career_path.MotifSortieOption(**kwargs)

Bases : ConfigurableOption

Possible values for exit motivation

active
id
label
order
type_
class endi.models.career_path.TypeContratOption(**kwargs)

Bases : ConfigurableOption

Possible values for contract type

active
id
label
order
type_
class endi.models.career_path.TypeSortieOption(**kwargs)

Bases : ConfigurableOption

Possible values for exit type

active
id
label
order
type_
endi.models.career_path.save_file_careerpath_relationship(request, appstruct, file_object)

Save relationship between userdata’s file and career path

Delete existing relationship then insert new if needed

endi.models.career_path.start_listening()
endi.models.career_path.update_user_situation_cae(mapper, connection, target)

Update - if needed - the CAE situation of the user when it’s career path change

endi.models.career_stage module

Model for career stages

class endi.models.career_stage.CareerStage(**kwargs)

Bases : Base

Different career stages

active
cae_situation
cae_situation_id
id
name
classmethod query(include_inactive=False)

return a query

stage_type

endi.models.commercial module

Models related to the treasury module

class endi.models.commercial.TurnoverProjection(**kwargs)

Bases : Base

Turnover projection :param company_id: The company this projection is related to :param month: The month number this projection is made for :param year: The year this projection is made for

comment
company
company_id
id
month
value
year

endi.models.company module

Company model

class endi.models.company.Company(**kwargs)

Bases : Node

Company model Store all company specific stuff (headers, logos, RIB, …)

IBAN
RIB
accompagnement_activities
active
activities
address
antenne
antenne_id
bank_account
cgv
children
city
code_compta
contribution
country
created_at
customers
decimal_to_display
disable()

Disable the current company

email
employees
employs(uid)
Paramètres:

int (uiud) – User id

enable()

enable the current company

expense
file_requirements
files
follower
follower_id
classmethod format_label_from_datas(company_datas, with_select_search_datas=False)
company_datas:
can be either an SqlAlchemy.Row(

id, name, code_compta, active, nb_employees, employees_list

) or a dict : {

“id”: int, “name”: str, “code_compta”: str, “active”: bool, “nb_employees”: int, “employees_list”: str

}

property full_label

Return the company’s label to display

Add employees infos to company’s name if config ask to

general_customer_account
general_expense_account
general_overhead
general_supplier_account
get_active_employees()
get_cancelinvoices(valid=False)

Return the cancelinvoices of the current company

classmethod get_companies_select_datas(request, only_active=False)
get_company_id()

Return the current company id Allows company id access through request’s context

classmethod get_contribution(company_id, prefix='')
Renvoie:

The cae contribution percentage

get_customer_codes_and_names()

Return current company’s customer codes and names

get_employee_ids()
get_estimations(valid=False)

Return the estimations of the current company

get_general_customer_account(prefix='')
get_general_expense_account(prefix='')
get_general_supplier_account(prefix='')
classmethod get_id_by_analytical_account(analytical_account)
get_invoices(valid=False)

Return the invoices of the current company

get_last_treasury_main_indicator()

Retrieve the main indicator’s datas from the last treasury grid of a given company Return {« date », « label », « value »} of the measure

get_late_invoices()

Return invoices waiting for more than 45 days

get_main_activity()
get_nb_km_on_period(start_date, end_date)

Retrieve the kilometers declared for the current company on the given period

get_next_cancelinvoice_index()

Return the next cancelinvoice index

get_next_estimation_index()

Return the next estimation index

get_next_invoice_index()

Return the next invoice index

get_project_codes_and_names()

Return current company’s project codes and names

classmethod get_rate(company_id: int, rate_name: str, prefix: str = '')

Récupère un taux à appliquer en fonction du nom du module d’écriture comptable concerné

Paramètres:
  • company_id (int) – L’id de l’enseigne

  • rate_name (str) – Le nom du module d’écriture pour lequel on

récupère le taux :param str prefix: préfixe de l’attribut à rechercher (”” ou “internal”)

Type renvoyé:

float or None

classmethod get_rate_level(company_id: int, rate_name: str, prefix: str = '')

Renvoie le niveau (cae/company/document) auquel la contribution est définie

Paramètres:
  • company_id (int) – L’id de l’enseigne

  • rate_name (str) – Le nom du module d’écriture pour lequel on

récupère le taux :param str prefix: préfixe de l’attribut à rechercher (”” ou “internal”)

Type renvoyé:

str or None

get_real_customers(year)

Return the real customers (with invoices)

get_recent_tasks(page_nb, nb_per_page)
Paramètres:
  • nb_per_page (int) – how many to return

  • page_nb (int) – pagination index

Renvoie:

pagination for wanted tasks, total nb of tasks

get_supplier_codes_and_names()

Return current company’s supplier codes and names

get_tasks()

Get all tasks for this company, as a list

get_third_party_customer_account(prefix='')
get_third_party_supplier_account(prefix='')
get_total_expenses_and_km_on_period(start_date, end_date)

Retrieve the expense total HT and the kilometers declared for the current company on the given period

get_total_expenses_on_period(start_date, end_date)

Retrieve the expense total HT for the current company on the given period

get_total_purchases_on_period(start_date, end_date)

Retrieve the purchase total HT for the current company on the given period

get_turnover(start_date, end_date)

Retrieve the turnover for the current company on the given period

goal
has_group_member(group_name)
has_invoices()

return True if this company owns invoices

has_trainer()
property header
header_file
header_id
id
insurance
internal
internalcontribution
internalgeneral_customer_account
internalgeneral_supplier_account
internalinsurance
internalthird_party_customer_account
internalthird_party_supplier_account
classmethod label_datas_query(request, only_active=False)
logo_file
logo_id
property main_activity

Return the company’s main activity (first “company_activity_rel” entry)

margin_rate
mobile
month_company_invoice_sequence_init_date
month_company_invoice_sequence_init_value
name
parent: Any
parent_id
phone
projects
classmethod query(keys=None, active=True)

Return a query

classmethod query_for_select_with_trainer(request)
sale_products
set_datas_from_user(user_account)
statuses
supplier_invoices
suppliers
tasks
third_party_customer_account
third_party_supplier_account
turnoverprojections
type_
updated_at
use_margin_rate_in_catalog
zip_code
class endi.models.company.CompanyActivity(**kwargs)

Bases : ConfigurableOption

Company activities

active
companies
id
label
order
type_

endi.models.competence module

Models related to competence evaluation

class endi.models.competence.CompetenceDeadline(**kwargs)

Bases : ConfigurableOption

active
id
label
order
classmethod query(*args)

return a query

requirements
type_
class endi.models.competence.CompetenceGrid(**kwargs)

Bases : Base

The competences grid

contractor
contractor_id
created_at
deadline
deadline_id
ensure_item(competence_option)

Return the item that is used to register evaluation for the given competence_option

Paramètres:

competence_option (obj) – The competence_option object

id
items
updated_at
class endi.models.competence.CompetenceGridItem(**kwargs)

Bases : Base

An item of the grid compound of two text boxes

represented by a table

property average

Return the average evaluation for this item

property contractor
ensure_subitem(competence_option)

Return a sub competence item used for the evaluation of the give competence option

Paramètres:

competence_option (obj) – The competence_option object

grid
grid_id
id
option
option_id
progress
subitems
class endi.models.competence.CompetenceGridSubItem(**kwargs)

Bases : Base

A subcompetence represented by a table line

comments
property contractor
evaluation
id
item
item_id
option
option_id
property scale

Returns the scale matching the current evaluation value Since scales can be changed, we get the first scale that is <= evaluation

class endi.models.competence.CompetenceOption(**kwargs)

Bases : ConfigurableOption

A competence model (both for the main one and the sub-competences)

Paramètres:

required_id (int) – The id of the bareme element needed

active
children
get_requirement(deadline_id)
id
label
order
classmethod query(active=True, *args)

return a query

requirement
requirements
type_
class endi.models.competence.CompetenceRequirement(**kwargs)

Bases : Base

competence
competence_id
deadline
deadline_id
requirement
class endi.models.competence.CompetenceScale(**kwargs)

Bases : ConfigurableOption

active
id
label
order
classmethod query(*args)

return a query

type_
value
class endi.models.competence.CompetenceSubOption(**kwargs)

Bases : ConfigurableOption

active
id
label
order
parent
parent_id
type_

endi.models.config module

Config model stores : enDI’s welcome message Documents footers, headers …

class endi.models.config.Config(**kwargs)

Bases : Base

Table containing the main configuration

name varchar(255) NOT NULL, value text, PRIMARY KEY (name)

classmethod get(keyname, default=None)

Return a query

classmethod get_value(keyname: str, default: ~typing.Any = <config.required>, type_: ~typing.Type = <class 'str'>)

Return a typed configuration value

Case 1 : type_ is managed by the _type_value function (one of float/int/date)

  • We try to convert the value

  • If a default is provided, we fallback on the default, else an exception is raised

Case 2 : The data is not set, we return default or None

Case 3 : The data is set but no managed type_ is provided, we return the data

Paramètres:
  • keyname (str) – The config key (name attribute)

  • default – The default value to return, if default is not set, we

return None in the Cases 2 and 3

Paramètres:

type (class) – The type_ of the value we want in return

name
classmethod set(key, value)
value
class endi.models.config.ConfigFiles(**kwargs)

Bases : PersistentACLMixin, Base

A file model

data
classmethod delete(key)

Override the default delete method to delete by key and not by id

classmethod get(key)

Override the default get method to get by key and not by id

getvalue()

Method making our file object compatible with the common file rendering utility

id
key
property label

Simple shortcut for getting a label for this file

mimetype
name
classmethod rename(key, newkey)

rename a key

classmethod set(key, appstruct)

Set a file for the given key, if the key isn’t field yet, add a new instance

size
class endi.models.config.ConfigRequired

Bases : object

class endi.models.config.TypableDict

Bases : dict

get_value(keyname, default=<config.required>, type_=<class 'str'>)
endi.models.config.convert_to_bool(v, default=<config.required>) bool

Convert config values to boolean

endi.models.config.get_admin_mail()

Collect the administration mail in the current configuration

Renvoie:

A configured CAE administration mail

Type renvoyé:

str

endi.models.config.get_config()

Return a dict-like with the config objects

endi.models.files module

File model

class endi.models.files.File(**kwargs)

Bases : Node

A file model

associated_cached_task
children
company_header_backref
company_logo_backref
created_at
data
property data_obj
description
duplicate()
file_requirements
file_type
file_type_id
files
getvalue()

Method making our file object compatible with the common file rendering utility

id
property label

Simple shortcut for getting a label for this file

mimetype
name
parent: Any
parent_id
classmethod query_for_filetable()

Build a File query for filetable display

Query only columns used for generic display

Type renvoyé:

sqlalchemy.orm.Query

sale_file_requirements
size
statuses
template_backref
type_
updated_at
user_photo_backref
class endi.models.files.FileType(**kwargs)

Bases : ConfigurableOption

active
business_file_template_rel
business_type_rel
classmethod get_by_label(label)
get_template_id(business_type_id) int

Find the File Template for this given file type and the associated business_type_id

id
property is_used
label
order
query_indicators()

Query indicators attached to this FileType

Type renvoyé:

A SqlAlchemy query

query_requirements()

Query indicators attached to this FileType

Type renvoyé:

A SqlAlchemy query

type_
class endi.models.files.Template(**kwargs)

Bases : File

A template model for odt templates

active
associated_cached_task
children
company_header_backref
company_logo_backref
created_at
data
description
file_requirements
file_type
file_type_id
files
id
property label

Simple shortcut for getting a label for this file

mimetype
name
parent: Any
parent_id
classmethod query()

return a query

sale_file_requirements
size
statuses
template_backref
templated
type_
updated_at
user_photo_backref
class endi.models.files.TemplatingHistory(**kwargs)

Bases : Base

Record all the templating fired for a given userdata account

created_at
id
template
template_id
user
user_id
userdatas
userdatas_id

endi.models.form_options module

Form configuration related models Labels / defaults / required …

class endi.models.form_options.FormFieldDefinition(**kwargs)

Bases : Base

Custom definition for a form field inherits title/active/order

default
field_name
form
form_config() dict

Build a dict matching the form_config views representation

classmethod get_default(field_name: str, form_name: str = 'task') str
classmethod get_definition(field_name: str, form_name: str = 'task')

Fin a form definition

classmethod get_definitions(form_name: str = 'task')

Collect FormFieldDefinitions related to form_name

classmethod get_form_labels(form_name: str = 'task')
id
required
title
visible

endi.models.holiday module

Holiday model used to store employee’s holiday declaration

class endi.models.holiday.Holiday(**kwargs)

Bases : Base

Holidays table Stores the start and end date for holiday declaration user_id start_date end_date

end_date
id
start_date
user
user_id

endi.models.indicators module

class endi.models.indicators.CustomBusinessIndicator(**kwargs)

Bases : Indicator

Custom Indicator related to businesses with a label and a custom name

business
business_id
created_at
forced
id
label
name
status
type_
updated_at
validation_status
class endi.models.indicators.Indicator(**kwargs)

Bases : TimeStampedMixin, Base

Model recording computed statuses

DANGER_STATUS = 'danger'
DEFAULT_STATUS = 'none'
INVALID_STATUS = 'invalid'
STATUSES = ('danger', 'warning', 'success')
SUCCESS_STATUS = 'success'
VALIDATION_STATUS = ('invalid', 'valid', 'wait', 'none')
VALID_STATUS = 'valid'
WAIT_STATUS = 'wait'
WARNING_STATUS = 'warning'
cmp_status(other_status)

Compare the current’s instance status and the given one

Return the the lowest status

danger and danger = danger warning and danger = danger warning and success = warning danger and success = success

Paramètres:

other_status (str) – The status to compare to

Renvoie:

One of the availabe statuses

Type renvoyé:

str

created_at
classmethod find_lowest_status(statuses: List[str]) str

Find the lowest status from a list of statuses

force()
forced
id
property main_status

Compare the status and validation_status to return the most relevant one

set_default_status()

Set the default status to a default “danger”

set_validation_status(status)
status
type_
unforce()
updated_at
property validated
validation_status
class endi.models.indicators.SaleFileRequirement(*args, **kwargs)

Bases : Indicator

Model recording File Requirements status

created_at
doctype
file_id
file_object
file_type
file_type_id
forced
classmethod get_by_type_id(node_id, file_type_id)

Find the SaleFileRequirment with the given file_type_id and the given node_id

id
merge_indicator(indicator)

Merge the given SaleFileRequirement with the current one

if a file has been provided, we call the set_file method that handles the status if no file has been provided, the indicator may have been forced, we register that status

Paramètres:

indicator (obj) – an instance of the current class

node
node_id
remove_file()

Remove file reference from this indicator

requirement_type
set_default_status()

Set the default status regarding the requirement type

set_default_validation_status()

Set the default validation status regarding the validation attribute

set_file(file_id, validated=False)

Attach a file_id to this indicator

Paramètres:
  • file_id (int) – An id of a file persisted to database

  • validated (bool) – True if this file been validated in another

indicator

status
type_
update_file(file_id)

The file file_id was updated, we update the indicator if it was related to this file and if needed (if the current requirement needs validation)

Paramètres:
  • file_id (int) – An id of a file persisted to database

  • validated (bool) – True if this file been validated in another

indicator

update_status(validated=False)

Update an Indicator’s status

updated_at
validation
validation_status

endi.models.listeners module

class endi.models.listeners.SQLAListeners

Bases : object

Stores a global registry of functions configuring sqlalchemy listeners

Functions come by pair : one to configure (containing sqlalchemy.event.listen calls) and one to deconfigure (containing sqlalchemy.event.remove calls).

Goal is to be able to disable at once all event listeners in situations where we want to avoid side effect (eg: bulk data handling).

classmethod register(start_func: Callable, stop_func: Optional[Callable] = None)
start_funcs = [<function start_listening>, <function start_listening>, <function start_listening>, <function start_listening>, <function start_listening>, <function start_listening>, <function start_listening>]
classmethod start_listening()
stop_funcs = [<function stop_listening>, <function stop_listening>]
classmethod stop_listening()

endi.models.node module

Nodes model is a base model for many other models (projects, documents, files, events) This way we can easily use the parent/children relationship on an agnostic way as in a CMS

class endi.models.node.Node(**kwargs)

Bases : PersistentACLMixin, TimeStampedMixin, Base

A base node providing a parent<->children structure for most of the models (usefull for file attachment)

NODE_LABELS = {'activity': 'Rendez-vous', 'business': 'Affaire', 'cancelinvoice': 'Avoir', 'estimation': 'Devis', 'expensesheet': 'Note de dépenses', 'internalcancelinvoice': 'Avoir interne', 'internalestimation': 'Devis interne', 'internalinvoice': 'Facture interne', 'internalsupplier_invoice': 'Facture fournisseur interne', 'internalsupplier_order': 'Commande fournisseur interne', 'invoice': 'Facture', 'project': 'Dossier', 'sap_attestation': 'Attestation fiscale SAP', 'supplier_invoice': 'Facture fournisseur', 'supplier_order': 'Commande fournisseur', 'third_party': 'Tiers', 'workshop': 'Atelier'}
children
created_at
extra_statuses() Iterable[StatusLogEntry]

Can be overriden to provide additionan StatusLogEtnries

file_requirements
files
get_allowed_statuses(request: Request, permission='view.statuslogentry')
id
name
parent: Any
parent_id
statuses
type_
property type_label
updated_at

endi.models.options module

Base tools for administrable options

class endi.models.options.ConfigurableOption(**kwargs)

Bases : Base

Base class for options

active
classmethod get_next_order()
Renvoie:

The next available order

Type renvoyé:

int

id
classmethod insert(item, new_order)

Place the item at the given index

Paramètres:
  • item (obj) – The item to move

  • new_order (int) – The new index of the item

label
move_down()

Move the current instance down in the category’s order

move_up()

Move the current instance up in the category’s order

order
classmethod query(*args)

return a query

classmethod reorder()

Regenerate order attributes

type_
endi.models.options.get_id_foreignkey_col(foreignkey_str)

Return an id column as a foreignkey with correct colander configuration

foreignkey_str

The foreignkey our id is pointing to

endi.models.payments module

class endi.models.payments.Bank(**kwargs)

Bases : ConfigurableOption

Third parties bank list

active
id
label
order
type_
class endi.models.payments.BankAccount(**kwargs)

Bases : ConfigurableOption

Bank accounts used for payment registry

active
bic
code_journal
compte_cg
default
expense_payments
iban
id
label
order
payments
property rib_account_key
property rib_account_number
property rib_bank_code
property rib_bank_office
supplier_payments
type_
user_payments
class endi.models.payments.PaymentMode(**kwargs)

Bases : Base

Payment mode entry

id
label
class endi.models.payments.PaymentModelMixin

Bases : object

Common fields for payment various payment models

amount = Column(None, Integer(), table=None)
bank_remittance_id = Column(None, String(length=255), table=None)
date = Column(None, DateTime(), table=None, default=ColumnDefault(<function datetime.now>))
exported = Column(None, Boolean(), table=None, default=ColumnDefault(False))
get_amount()
mode = Column(None, String(length=50), table=None)
property parent
precision = 2

endi.models.populate module

class endi.models.populate.PopulateRegistry

Bases : object

BASE_FUNCTIONS = [<function populate_cae_situations_and_career_stages>, <function populate_groups>, <function populate_system_user>, <function populate_accounting_treasury_measure_types>, <function populate_accounting_income_statement_measure_types>, <function populate_accounting_balance_sheet_types>, <function populate_bookentry_config>, <function populate_project_types>, <function populate_contract_types>, <function populate_file_types_and_requirements>, <function populate_number_templates>, <function populate_training_types>, <function populate_training_bpf_specialities>, <function populate_banks>, <function populate_expense_types>, <function populate_main_config>, <function populate_task_mentions>, <function populate_business_type_task_mention>, <function populate_doctype_label_override>, <function populate_tva_and_products>, <function populate_accounting_book_modules>, <function populate_form_field_definitions>, <function populate_price_study_config>, <function populate_notification_types_and_channels>, <function populate_thirdparty_account_mandatory>]
EXTRA_FUNCTIONS = []
classmethod add_function(populate_function: Callable[[Session], None]) None

Plug-in a populate function.

this function may be used by plugins to plug their functions in.

The new function will be called last on populate_database invocation.

classmethod get_functions()
endi.models.populate.populate_accounting_balance_sheet_types(session)

Populate the database with balance sheet measure type (bilan)

endi.models.populate.populate_accounting_book_modules(session)

Crée les Modules d’écritures pour les contribution et assurance

endi.models.populate.populate_accounting_income_statement_measure_types(session)

Populate the database with treasury measure types

endi.models.populate.populate_accounting_treasury_measure_types(session)

Populate the database with treasury measure types

endi.models.populate.populate_banks(session)

Populate the banks in the database

endi.models.populate.populate_bookentry_config(session)
endi.models.populate.populate_business_type_task_mention(session)

Populate travel type task mentions default values

endi.models.populate.populate_cae_situations_and_career_stages(session)

Populate the database with default CAE situation options and career stages

endi.models.populate.populate_contract_types(session)

Populate the database with default contract types

endi.models.populate.populate_database()

Populate the database with default values

endi.models.populate.populate_doctype_label_override(session)

Populate doctype label overrides

Only if there is none yet.

endi.models.populate.populate_expense_types(session)
endi.models.populate.populate_file_types_and_requirements(session)

Add default file types to the database

endi.models.populate.populate_form_field_definitions(session)

Crée les définitions pour les champs personnalisables des formulaires

endi.models.populate.populate_groups(session)

Populate the groups in the database

endi.models.populate.populate_main_config(session)

Setup main configuration options

endi.models.populate.populate_notification_types_and_channels(session)
endi.models.populate.populate_number_templates(session)
endi.models.populate.populate_price_study_config(session)
endi.models.populate.populate_project_types(session)
endi.models.populate.populate_system_user(session)

Create a system user with id 0

endi.models.populate.populate_task_mentions(session)

Populate task mentions Les autres mentions sont issues d’une migration précédente

endi.models.populate.populate_thirdparty_account_mandatory(session)

Setup config thirdparty_account_mandatory options

endi.models.populate.populate_training_bpf_specialities(session)
endi.models.populate.populate_training_types(session)

Populate the database with default training type options

endi.models.populate.populate_tva_and_products(session)

endi.models.sequence_number module

class endi.models.sequence_number.GlobalSequence(db_key: str, init_value_config_key: str, types: Tuple[str], model_class: Type[OfficialNumberMixin])

Bases : object

get_latest_index(node)
Type renvoyé:

int or None

get_next_index(node)
class endi.models.sequence_number.MonthCompanySequence(*args, **kwargs)

Bases : MonthSequence

class endi.models.sequence_number.MonthSequence(init_date_config_key, *args, **kwargs)

Bases : YearSequence

class endi.models.sequence_number.SequenceNumber(**kwargs)

Bases : Base

Sequence numbers of different chronological sequences

SEQUENCE_EXPENSESHEET_GLOBAL = 'expense_sheet_global'
SEQUENCE_EXPENSESHEET_MONTH = 'expense_sheet_month'
SEQUENCE_EXPENSESHEET_MONTH_COMPANY = 'expense_sheet_month_company'
SEQUENCE_EXPENSESHEET_YEAR = 'expense_sheet_year'
SEQUENCE_INTERNALINVOICE_GLOBAL = 'internalinvoice_global'
SEQUENCE_INTERNALINVOICE_MONTH = 'internalinvoice_month'
SEQUENCE_INTERNALINVOICE_MONTH_COMPANY = 'internalinvoice_month_company'
SEQUENCE_INTERNALINVOICE_YEAR = 'internalinvoice_year'
SEQUENCE_INTERNALSUPPLIERINVOICE_GLOBAL = 'supplier_internalinvoice_global'
SEQUENCE_INTERNALSUPPLIERINVOICE_MONTH = 'supplier_internalinvoice_month'
SEQUENCE_INTERNALSUPPLIERINVOICE_MONTH_COMPANY = 'supplier_internalinvoice_month_company'
SEQUENCE_INTERNALSUPPLIERINVOICE_YEAR = 'supplier_internalinvoice_year'
SEQUENCE_INVOICE_GLOBAL = 'invoice_global'
SEQUENCE_INVOICE_MONTH = 'invoice_month'
SEQUENCE_INVOICE_MONTH_COMPANY = 'invoice_month_company'
SEQUENCE_INVOICE_YEAR = 'invoice_year'
SEQUENCE_SUPPLIERINVOICE_GLOBAL = 'supplier_invoice_global'
SEQUENCE_SUPPLIERINVOICE_MONTH = 'supplier_invoice_month'
SEQUENCE_SUPPLIERINVOICE_MONTH_COMPANY = 'supplier_invoice_month_company'
SEQUENCE_SUPPLIERINVOICE_YEAR = 'supplier_invoice_year'
id
index
node
node_id
sequence
class endi.models.sequence_number.YearSequence(init_date_config_key, *args, **kwargs)

Bases : GlobalSequence

endi.models.statistics module

Models related to statistics

  • Sheets |- Entries

    |-Criterions

A sheet groups a number of statistics entries. Each entry is compound of a list of criterions.

class endi.models.statistics.StatisticCriterion(**kwargs)

Bases : Base

Statistic criterion :param str key: The key allows us to match the column we will build a query on through the inspector’s columns dict (ex: “coordonnees_lastname” or “activity_companydatas.name”) :param str method: The search method (eq, lte, gt …) :param str search1: The first value we search on :param str search2: The second value we search on (in case of range search) :param str searches: The list of value we will query on (in case of “oneof” search) :param str type: string/number/manytoone/date says us which query generator we will use

children
property complex
date_search1
date_search2
duplicate()
entry_id
has_parent(request=None)

Return True if the current criterion has a parent one

id
key
method
parent
parent_id
property root
search1
search2
searches
type
class endi.models.statistics.StatisticEntry(**kwargs)

Bases : Base

criteria
description
duplicate(sheet_id=None)
id
sheet
sheet_id
title
class endi.models.statistics.StatisticSheet(**kwargs)

Bases : TimeStampedMixin, Base

active
created_at
duplicate()
entries
has_entry(entry_title)
id
title
updated_at

endi.models.status module

Handle a consistent way the different statuses stored in DB

We handle several statuses (validation status, payment status, justification status…).

This module handles two things :

  • the SQLA fields to mix-in the implementors

  • the optional historization of the statuses through StatusLogEntry

  • and some status-related tools.

It does not handle state machine itself, see also ActionManager uses for state machine stuff.

class endi.models.status.PaidStatusHolderMixin

Bases : StatusHolderMixin

Holds a state machine for paid status and caches latest state

state_manager_key : « paid_status »

Inheriting class must implement a payment property containing the list of payments.

check_resulted(force_resulted=False)

Check if the expense is resulted or not and set the appropriate status

get_resulted(force_resulted, topay, payments, total)

Get the paid status resulting from the given elements

Passing topay and total allows to handle split payments (eg : for supplier invoices)

Paramètres:

force_resulted (bool) – Has the paid status been forced to resulted

? :param int topay: The amount topay to consider :param list payments: The list of recorded payments :param int total: The total amount to consider

is_resulted(topay, total)

Return True/False if the document is resulted

paid_status = Column(None, String(length=10), table=None, default=ColumnDefault('waiting'))
paid_status_comment = Column(None, Text(), table=None, nullable=False, default=ColumnDefault(''))
paid_status_date = Column(None, DateTime(), table=None, default=ColumnDefault(<function datetime.now>))
paid_status_history = <RelationshipProperty at 0x7fe5acc90f80; no key>
paid_status_user_id = Column(None, NullType(), ForeignKey('accounts.id'), table=None)
property payments

Must be implemented and (attr or property)

Typical implementation : one-many relationship. :rtype list of PaymentModelMixin implementor:

record_payment(payment, force_resulted=False)

Record a payment for the current expense

topay()

Must be implemented and provide a number

class endi.models.status.StatusHolderMixin

Bases : object

Tools to implement a stored status, with all its metadata.

This is meant to be subclassed arround a specific status (eg: ValidationStatusHolderMixin).

Final class model can inherit several statusholder childs. to implement several statuses (ex: payment status and vaidation status).

LOG_ENTRY_MAPPING = {'paid_status': {'paid_status': 'status', 'paid_status_comment': 'comment', 'paid_status_date': 'datetime', 'paid_status_user_id': 'user_id'}, 'validation_status': {'status': 'status', 'status_comment': 'comment', 'status_date': 'datetime', 'status_user_id': 'user_id'}}
historize_latest_status(state_manager_key)

Historize current status as a StatusLogEntry in db

Logs a StatusLogEntry that reflects current holder object state.

This does not handle permission / state machine stuff, it should have been done already.

class endi.models.status.StatusLogEntry(**kwargs)

Bases : Base

comment
datetime
id
label
node
node_id
pinned
state_manager_key
status
user
user_id
visibility
class endi.models.status.ValidationStatusHolderMixin

Bases : StatusHolderMixin

Holds a state machine for validation status and caches latest state

state_manager_key : « validation_status »

Would be clearer to name the model fields « validation_status », « validation_status_comment »… But for historical reason, and to avoid breaking stuff, they are named simply « status », « status_comment »…

status = Column(None, String(length=10), table=None, default=ColumnDefault('draft'))
status_comment = Column(None, Text(), table=None, nullable=False, default=ColumnDefault(''))
status_date = Column(None, DateTime(), table=None, default=ColumnDefault(<function datetime.now>))
status_user = <RelationshipProperty at 0x7fe5acc66ef0; no key>
status_user_id = Column(None, NullType(), ForeignKey('accounts.id'), table=None)
validation_status_history = <RelationshipProperty at 0x7fe5acc1e170; no key>
class endi.models.status.ValidationStatusHolderService(*args, **kwargs)

Bases : object

waiting(*classes)

Documents waiting for validation

Paramètres:

*classes

the model classes to query (Node childs, implementing ValidationStatusHolderMixin)

Renvoie:

iterable query with documents.

endi.models.status.status_column(default='')
endi.models.status.status_comment_column()
endi.models.status.status_date_column()
endi.models.status.status_history_relationship(state_manager_key: Optional[str] = None, **options)
Paramètres:
  • state_manager_key – if ommited : relationship to all entries, including memos (they have no state_manager_key)

  • options

Renvoie:

endi.models.status.status_user_id_column()
endi.models.status.status_user_relationship(user_id_column: str)
Paramètres:

user_id_column – dotted form (Model.column) of column storing user

id.

endi.models.tools module

endi.models.tools.get_excluded_colanderalchemy(title)

Return colanderalchemy for excluded field but with title set (for other sqla inspection based modules like py3o inspection or ods generation)

endi.models.tools.get_labor_units_sqla_filter(model_cls, attribute='unity')

Build a filter to collect only labor units

endi.models.tools.get_not_labor_units_sqla_filter(model_cls, attribute='unity')
endi.models.tools.set_attribute(instance, key, value, initiator=None)

Set the value of an attribute, firing history events.

This function is copied from the attributes module but adds the « initiator » argument.

Mike Bayer’s code provided on the sqlalchemy mailling list

endi.models.tva module

Model for tva amounts

class endi.models.tva.Product(**kwargs)

Bases : Base

active
compte_cg
classmethod first_by_tva_value(tva_value, internal=False)
classmethod get_external()

Collect the products related to internal invoicing

Type renvoyé:

SQLA query

classmethod get_internal()

Collect the products related to internal invoicing

Type renvoyé:

SQLA query

id
internal
name
classmethod query(include_inactive=False)

return a query

tva
tva_id
urssaf_code_nature
class endi.models.tva.Tva(**kwargs)

Bases : Base

id int(2) NOT NULL auto_increment, name varchar(8) NOT NULL, value int(5) default int(2) default 0 #rajouté par mise à jour 1.2

active
classmethod by_value(value, or_none=False)

Returns the Tva matching this value

code
compte_a_payer
compte_cg
default
classmethod get_default()
classmethod get_external()
classmethod get_internal()

Return the Tva used to configure Internal Invoices

id
mention
name
products
classmethod query(include_inactive=False)

return a query

property rate

Return the display value

20 for 20% tva rate

property ratio

Return the ratio applied

0.2 for 20% tva rate

classmethod unique_value(value, tva_id=None)

Check that the given value has not already been attributed to a tva entry

Paramètres:
  • value (int) – The value currently configured

  • tva_id (int) – The optionnal id of the current tva object (edition

mode) :returns: True/False :rtype: bool

value

endi.models.workshop module

class endi.models.workshop.Timeslot(**kwargs)

Bases : Event

A time slot for a given workshop

attendances
children
created_at
datetime
duplicate()
property duration
end_time
file_requirements
files
id
name
owner
owner_id
parent: Any
parent_id
signup_mode
start_time
status
statuses
type_
updated_at
workshop
workshop_id
class endi.models.workshop.Workshop(**kwargs)

Bases : Event

A workshop model

It’s a meta event grouping a bunch of timeslots with each their own attendance sheet

attendances
children
company_manager
company_manager_id
created_at
datetime
description
duplicate()
file_requirements
files
get_company_id()

Usefull to get the current company if a workshop is the context

id
info1
info1_id
info2
info2_id
info3
info3_id
max_participants
name
owner
owner_id
parent: Any
parent_id
place
relates_single_day()

Does the TimeSlots are all occuring the same day as Workshop.

signup_mode
status
statuses
tags
timeslots
property title

Return a title for this given workshop

trainers
type_
updated_at
class endi.models.workshop.WorkshopAction(**kwargs)

Bases : Base

active
children
id
label
parent
parent_id
class endi.models.workshop.WorkshopTagOption(**kwargs)

Bases : ConfigurableOption

Managing tags options

active
id
label
order
type_
endi.models.workshop.get_workshop_years(kw=None)

Return a cached query for the years we have workshops in database

Paramètres:

kw – is here only for API compatibility

Module contents

Regouping all models imports is necessary to allow the metadata.create_all function to work well

endi.models.adjust_for_engine(engine)

Ajust the models definitions to fit the current database engine :param obj engine: The current engine to be used