Entitlement Manager#

The entitlement manager determines what a beneficiary is entitled to for a given cycle.

odoo.addons.g2p_programs.models.managers.entitlement_manager provides the class BaseEntitlementManager define the interface for this manager. DefaultCashEntitlementManager is the default implementation of this class for cash distribution.

The BaseEntitlementManager can be extended to implement any other type of distribution such as in-kind.

class odoo.addons.g2p_programs.models.managers.entitlement_manager.BaseEntitlementManager[source]#
approve_entitlements(entitlements)[source]#

Base Entitlement Manager _approve_entitlements() Approve selected entitlements Override in entitlement manager

Parameters

entitlements -- Selected entitlements to approve.

Returns

cancel_entitlements(cycle)[source]#

Base Entitlement Manager cancel_entitlements() Cancel entitlements in a cycle Override in entitlement manager

Parameters

cycle -- A recordset of cycle

Returns

mark_job_as_done(cycle, msg)[source]#

Base mark_job_as_done() Post a message in the chatter

Parameters
  • cycle -- A recordset of cycle

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

Returns

open_entitlement_form(rec)[source]#

This method is used to open the form view of a selected entitlement. :param rec: The entitlement. :return:

open_entitlements_form(cycle)[source]#

This method is used to open the list view of entitlements in a cycle. :param cycle: The cycle. :return:

prepare_entitlements(cycle, beneficiaries)[source]#

This method is used to prepare the entitlement list of the beneficiaries. :param cycle: The cycle. :param beneficiaries: The beneficiaries. :return:

set_pending_validation_entitlements(cycle)[source]#

Base Entitlement Manager set_pending_validate_entitlements() Set entitlements to pending_validation in a cycle Override in entitlement manager

Parameters

cycle -- A recordset of cycle

Returns

validate_entitlements(cycle)[source]#

Base Entitlement Manager validate_entitlements() Validate entitlements for a cycle Override in entitlement manager

Parameters

cycle -- A recordset of cycle

Returns

class odoo.addons.g2p_programs.models.managers.entitlement_manager.DefaultCashEntitlementManager[source]#
IS_CASH_ENTITLEMENT = True#
amount_per_cycle#

Encapsulates a float expressed in a given res_currency.

The decimal precision and currency symbol are taken from the currency_field attribute.

Parameters

currency_field (str) -- name of the Many2one field holding the res_currency this monetary field is expressed in (default: 'currency_id')

amount_per_individual_in_group#

Encapsulates a float expressed in a given res_currency.

The decimal precision and currency symbol are taken from the currency_field attribute.

Parameters

currency_field (str) -- name of the Many2one field holding the res_currency this monetary field is expressed in (default: 'currency_id')

approve_entitlements(entitlements)[source]#

Approve entitlements. Default Entitlement Manager approve_entitlements() Approve selected entitlements

Parameters

entitlements -- Selected entitlements to approve

Return state_err

Integer number of errors

Return message

String description of the errors

cancel_entitlements(cycle)[source]#

Default Entitlement Manager cancel_entitlements() Cancel entitlements in a cycle

Parameters

cycle -- A recordset of cycle

Returns

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.

currency_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.

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.

entitlement_validation_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.

id#

Special case for field 'id'.

max_individual_in_group#

Encapsulates an int.

on_transfer_fee_amt_change()[source]#
on_transfer_fee_pct_change()[source]#
open_entitlement_form(rec)[source]#
open_entitlements_form(cycle)[source]#
prepare_entitlements(cycle, beneficiaries)[source]#

Prepare entitlements. This method is used to prepare the entitlement list of the beneficiaries. :param cycle: The cycle. :param beneficiaries: The beneficiaries. :return:

set_pending_validation_entitlements(cycle)[source]#

Set entitlements to pending validation. Default Entitlement Manager set_pending_validation_entitlements() Set entitlements to pending_validation in a cycle

Parameters

cycle -- A recordset of cycle

Returns

transfer_fee_amt#

Encapsulates a float expressed in a given res_currency.

The decimal precision and currency symbol are taken from the currency_field attribute.

Parameters

currency_field (str) -- name of the Many2one field holding the res_currency this monetary field is expressed in (default: 'currency_id')

transfer_fee_pct#

Encapsulates a float.

The precision digits are given by the (optional) digits attribute.

Parameters

digits (tuple(int,int) or str) -- a pair (total, decimal) or a string referencing a DecimalPrecision record name.

When a float is a quantity associated with an unit of measure, it is important to use the right tool to compare or round values with the correct precision.

The Float class provides some static methods for this purpose:

round() to round a float with the given precision. is_zero() to check if a float equals zero at the given precision. compare() to compare two floats at the given precision.

Example

To round a quantity with the precision of the unit of measure:

fields.Float.round(self.product_uom_qty, precision_rounding=self.product_uom_id.rounding)

To check if the quantity is zero with the precision of the unit of measure:

fields.Float.is_zero(self.product_uom_qty, precision_rounding=self.product_uom_id.rounding)

To compare two quantities:

field.Float.compare(self.product_uom_qty, self.qty_done, precision_rounding=self.product_uom_id.rounding)

The compare helper uses the __cmp__ semantics for historic purposes, therefore the proper, idiomatic way to use this helper is like so:

if result == 0, the first and second floats are equal if result < 0, the first float is lower than the second if result > 0, the first float is greater than the second

validate_entitlements(cycle)[source]#

Validate entitlements. Default Entitlement Manager validate_entitlements() Validate entitlements in a cycle

Parameters

cycle -- A recordset of cycle

Returns

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.