Summary View

A brief discussion about the summary view in PBMS odoo user interface followed by ways to customize the same

Summary lines (the underlying model responsible for rendering the summary view) runs onclick of the View <Eligibility/Entitlement> List button via the method _compute_summary_lines

The programmatic flow is as follows

  • Clear existing summary lines by wizard.summary_line_ids = [(5, 0, 0)]

  • Fetch configuration parameters staff_portal_api_url, keymanager_sign_application_id for formulating a request.

  • Construct an API request payload with beneficiary_list_id and target_registry

  • Sign the payload using the keymanager.provider service and issues a POST request to the /summary endpoint of pbms staff portal api

  • Parse the JSON response, which includes two major parts:

    • beneficiary_list_summary: general summary fields for the list

    • registry_summary: optional type-specific fields

  • Iterate over the keys of both summaries (skipping excluded keys like id and target_registry). For each key:

    • If the value is a dictionary (mapping benefit_code_id → value), it resolves the benefit_mnemonic and measurement_unit and creates a line with summary_type='entitlement' if from beneficiary_list_summary, or from registry_summary it may use 'eligibility' or 'entitlement' depending on context.

    • If scalar value, formats numbers (thousands separators) and creates a line with summary_type='general' or 'eligibility'.

  • Write the list of new lines into wizard.summary_line_ids as Many2many commands [(0, 0, {...})].

  • The wizard lines are stored in the g2p.api.summary.line model, which has fields: wizard_id (Many2one), key, value, and summary_type (selection: general / entitlement / eligibility).

This is how the summary lines are stored as key value pairs instead of hard coded column headers making them easy to customize.

Each section corresponds to a summary_type:

  • General: for overall beneficiary list metrics.

  • Eligibility: for demographic or eligibility data.

  • Entitlement: for benefit distribution and entitlement statistics.

<page string="Summary">
  <group>
    <strong><field name="general_title" readonly="1" widget="handle_display"/></strong>
    <field name="summary_general_line_ids" nolabel="1">
      <tree create="false" edit="false">
        <field name="key"/><field name="value"/>
      </tree>
    </field>
  </group>
  <group>
    <strong><field name="eligibility_group_title" readonly="1" widget="handle_display"/></strong>
    <field name="summary_eligibility_line_ids" nolabel="1">
      <tree create="false" edit="false">
        <field name="key"/><field name="value"/>
      </tree>
    </field>
  </group>
  <group>
    <strong><field name="entitlement_group_title" readonly="1" widget="handle_display"/></strong>
    <field name="summary_entitlement_line_ids" nolabel="1">
      <tree create="false" edit="false">
        <field name="key"/><field name="value"/>
      </tree>
    </field>
  </group>
</page>

Last updated

Was this helpful?