Cycle Manager#

odoo.addons.g2p_programs.models.managers.cycle_manager provides the class BaseCycleManager define the interface for this manager. DefaultCycleManager is the default implementation of this class that should be used in most of the cases.

class odoo.addons.g2p_programs.models.managers.cycle_manager.BaseCycleManager[source]#
add_beneficiaries(cycle, beneficiaries, state='draft')[source]#

Add beneficiaries to the cycle

approve_cycle(cycle, auto_approve=False, entitlement_manager=None)[source]#
Parameters
  • cycle --

  • auto_approve --

  • entitlement_manager --

Returns

check_eligibility(cycle, beneficiaries=None)[source]#

Validate the eligibility of each beneficiary for the cycle

issue_payments(cycle)[source]#

Issue the payments based on entitlements for the cycle

mark_cancelled(cycle)[source]#

Mark the cycle as cancelled

mark_distributed(cycle)[source]#

Mark the cycle as distributed

mark_ended(cycle)[source]#

Mark the cycle as ended

mark_import_as_done(cycle, msg)[source]#

Complete the import of beneficiaries. Base mark_import_as_done(). This is executed when all the jobs are completed. Post a message in the chatter.

Parameters
  • cycle -- A recordset of cycle

  • msg -- A string to be posted in the chatter

Returns

mark_prepare_entitlement_as_done(cycle, msg)[source]#

Complete the preparation of entitlements. Base mark_prepare_entitlement_as_done(). This is executed when all the jobs are completed. Post a message in the chatter.

Parameters
  • cycle -- A recordset of cycle

  • msg -- A string to be posted in the chatter

Returns

new_cycle(name, new_start_date, sequence)[source]#

Create a new cycle for the program

on_start_date_change(cycle)[source]#

Hook for when the start date change

on_state_change(cycle)[source]#
Parameters

cycle --

Returns

prepare_entitlements(cycle)[source]#

Prepare the entitlements for the cycle

validate_entitlements(cycle, cycle_memberships)[source]#

Validate the entitlements for the cycle

class odoo.addons.g2p_programs.models.managers.cycle_manager.DefaultCycleManager[source]#
add_beneficiaries(cycle, beneficiaries, state='draft')[source]#

Add beneficiaries to the cycle

approver_group_id#

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

Parameters
  • comodel_name (str) -- name of the target model Mandatory except for related or extended fields.

  • domain -- an optional domain to set on candidate values on the client side (domain or string)

  • context (dict) -- an optional context to use on the client side when handling that field

  • ondelete (str) -- what to do when the referred record is deleted; possible values are: 'set null', 'restrict', 'cascade'

  • auto_join (bool) -- whether JOINs are generated upon search through that field (default: False)

  • delegate (bool) -- set it to True to make fields of the target model accessible from the current model (corresponds to _inherits)

  • check_company (bool) -- Mark the field to be verified in _check_company(). Add a default company domain depending on the field attributes.

check_eligibility(cycle, beneficiaries=None)[source]#

Default Cycle Manager eligibility checker

Parameters
  • cycle (g2p_programs.models.cycle.G2PCycle) -- The cycle that is being verified

  • beneficiaries (list or None) -- the beneficiaries that need to be verified. By Default the one with the state draft or enrolled are verified.

Returns

The list of eligible beneficiaries

Return type

list

Validate the eligibility of each beneficiary for the cycle using the configured manager(s) g2p_programs.models.managers.eligibility_manager.BaseEligibilityManager. If there is multiple managers for eligibility, each of them are run using the filtered list of eligible beneficiaries from the previous one.

The state of beneficiaries is updated to either enrolled if they match the enrollment criteria or not_eligible in case they do not match them.

copy_beneficiaries_from_program(cycle, state='enrolled')[source]#
create_date#

Encapsulates a python datetime object.

create_uid#

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

Parameters
  • comodel_name (str) -- name of the target model Mandatory except for related or extended fields.

  • domain -- an optional domain to set on candidate values on the client side (domain or string)

  • context (dict) -- an optional context to use on the client side when handling that field

  • ondelete (str) -- what to do when the referred record is deleted; possible values are: 'set null', 'restrict', 'cascade'

  • auto_join (bool) -- whether JOINs are generated upon search through that field (default: False)

  • delegate (bool) -- set it to True to make fields of the target model accessible from the current model (corresponds to _inherits)

  • check_company (bool) -- Mark the field to be verified in _check_company(). Add a default company domain depending on the field attributes.

cycle_duration#

Encapsulates an int.

display_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

  • trim (bool) -- states whether the value is trimmed or not (by default, True). Note that the trim operation is applied only by the web client.

  • translate (bool or callable) -- enable the translation of the field's values; use translate=True to translate field values as a whole; translate may also be a callable such that translate(callback, value) translates value by using callback(term) to retrieve the translation of terms.

id#

Special case for field 'id'.

mark_cancelled(cycle)[source]#
mark_distributed(cycle)[source]#
mark_ended(cycle)[source]#
new_cycle(name, new_start_date, sequence)[source]#
prepare_entitlements(cycle)[source]#
write_date#

Encapsulates a python datetime object.

write_uid#

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

Parameters
  • comodel_name (str) -- name of the target model Mandatory except for related or extended fields.

  • domain -- an optional domain to set on candidate values on the client side (domain or string)

  • context (dict) -- an optional context to use on the client side when handling that field

  • ondelete (str) -- what to do when the referred record is deleted; possible values are: 'set null', 'restrict', 'cascade'

  • auto_join (bool) -- whether JOINs are generated upon search through that field (default: False)

  • delegate (bool) -- set it to True to make fields of the target model accessible from the current model (corresponds to _inherits)

  • check_company (bool) -- Mark the field to be verified in _check_company(). Add a default company domain depending on the field attributes.