nh_activity_data

class activity.nh_activity_data(pool, cr)[source]

Abstract class that relates to activity from which every activity type will inherit from.

activity_id

The value of such a field is a recordset of size 0 (no record) or 1 (a single record).

Parameters:
  • comodel_name – name of the target model (string)
  • domain – an optional domain to set on candidate values on the client side (domain or string)
  • context – an optional context to use on the client side when handling that field (dictionary)
  • ondelete – what to do when the referred record is deleted; possible values are: 'set null', 'restrict', 'cascade'
  • auto_join – whether JOINs are generated upon search through that field (boolean, by default False)
  • delegate – set it to True to make fields of the target model accessible from the current model (corresponds to _inherits)

The attribute comodel_name is mandatory except in the case of related fields or field extensions.

assign(*args, **kwargs)[source]

Assigns activity to a user. Raises an exception if it is already assigned to another user. If it is already assigned to the same user, then the activity is locked.

Parameters:
Returns:

True

Return type:

bool

cancel(*args, **kwargs)[source]

Cancels an activity and sets its date_terminated.

Parameters:activity_id (int) – activity id
Returns:True
Return type:bool
check_action(state, action)[source]
complete(*args, **kwargs)[source]

Completes an activity and sets its date_terminated.

Parameters:activity_id (int) – activity id
Returns:True
Return type:bool
complete_ui(*args, **kwargs)[source]
convert_record_to_data_ref(*args, **kwargs)[source]

Useful for getting the value for domains so you can search on data_ref.

Returns:
Return type:str
create(vals) → record[source]

Creates a new record for the model.

The new record is initialized using the values from vals and if necessary those from default_get().

Parameters:

vals (dict) –

values for the model’s fields, as a dictionary:

{'field_name': field_value, ...}

see write() for details

Returns:

new record created

Raises:
  • AccessError
    • if user has no create rights on the requested object
    • if user tries to bypass access rules for create on the requested object
  • ValidateError – if user tries to enter invalid value for a field that is not in selection
  • UserError – if a loop would be created in a hierarchy of objects a result of the operation (such as setting an object as its own parent)
create_activity(*args, **kwargs)[source]

Creates a new activity of the current data type.

Parameters:
  • vals_activity (dict) – values to save in the activity
  • vals_data (dict) – values to save in the data model<activity.nh_activity_data
Returns:

activity id.

Return type:

int

date_started
date_terminated
static format_many_2_many_fields(field_names)[source]
get_activity()[source]
classmethod get_description()[source]
get_latest_activity(*args, **kwargs)[source]

Return the most recent activity for a given data model.

Parameters:
  • data_model
  • spell_activity_id
Returns:

get_open_activities(*args, **kwargs)[source]

Get open activity(s) for one spell or all spells. :return: list of activities :rtype: list

get_open_activity(*args, **kwargs)[source]

Get the latest open activity for the given model. The method assumes that only one open activity at a time is possible for the given model. If more than one is found an exception is raised.

Parameters:spell_activity_id
Returns:
is_action_allowed(state, action)[source]

Tells us if the specified action is allowed in the specified state.

Parameters:
  • state (str) – state of the activity where we want to execute the action.
  • action (str) – action we want to execute.
Returns:

True or False

Return type:

bool

name

Basic string field, can be length-limited, usually displayed as a single-line string in clients

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate (bool) – whether the values of this field can be translated
schedule(*args, **kwargs)[source]

Schedules an activity and sets its date_scheduled.

Parameters:
  • activity_id (int) – activity id
  • date_scheduled (str) – date formatted string
Returns:

True

Return type:

bool

start(*args, **kwargs)[source]

Starts an activity and sets its date_started.

Parameters:activity_id (int) – activity id
Returns:True
Return type:bool
state

Basic string field, can be length-limited, usually displayed as a single-line string in clients

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate (bool) – whether the values of this field can be translated
submit(*args, **kwargs)[source]

Updates submitted data. It creates a new instance of the data model if it does not exist yet.

Parameters:
Returns:

True

Return type:

bool

submit_ui(*args, **kwargs)[source]
terminate_uid

The value of such a field is a recordset of size 0 (no record) or 1 (a single record).

Parameters:
  • comodel_name – name of the target model (string)
  • domain – an optional domain to set on candidate values on the client side (domain or string)
  • context – an optional context to use on the client side when handling that field (dictionary)
  • ondelete – what to do when the referred record is deleted; possible values are: 'set null', 'restrict', 'cascade'
  • auto_join – whether JOINs are generated upon search through that field (boolean, by default False)
  • delegate – set it to True to make fields of the target model accessible from the current model (corresponds to _inherits)

The attribute comodel_name is mandatory except in the case of related fields or field extensions.

unassign(*args, **kwargs)[source]

Unassigns an activity. Raises an exception if it is not assigned. Raises an exception if another user tries to unassign an activity not assigned to them.

Parameters:activity_id (int) – activity id
Returns:True
Return type:bool
update_activity(*args, **kwargs)[source]

Hook for data-driven activity update. Should be called on methods that change activity data.