Customize Service Points#

The following article guides the reader in understanding how the service point module will work in OpenSPP and how it can be customized by providing a sample scenario and a working example.

Prerequisites#

  • Knowledge of Python, Odoo, XML, Xpaths.

  • To set up OpenSPP for development, please refer to the Developer Guide

If the Service Points module is not installed#

  1. Log into OpenSPP with administrative rights.

  2. Access the “Apps” menu from the dashboard to manage OpenSPP modules.

  3. Choose “Update Apps List” to refresh the module list.

  4. Search for “OpenSPP Service Points” and initiate installation. This will also install the other modules required

Utilising the Service Points Module#

For more detailed guidance on utilizing the Service Point module in OpenSPP, please refer to the information available at the provided link, which will be published soon.

Customize Service Points#

In this hypothetical scenario, we will add the dropdown service point type and service point operating hours, which can be shown to the beneficiaries so they can redeem their entitlements by knowing the operation hours and service point type.

A working sample module for the described scenario can be accessed at the provided link.

The key steps in module development are as follows:

  1. To customize service point, a new module can be developed.

  2. To initiate the development of a custom module for service point customization, begin by creating a manifest file. This file should include fields like name, category, and version. Additionally, it's crucial to define the dependencies of the new module as outlined below.

   "depends": [
       "spp_service_points",
   ],

  1. To add the new field in the new module, develop a Python file named service_point.py that extends spp.service.point and incorporate this file into models/init.py. The definition of the fields should be implemented as demonstrated below.

from odoo import fields, models

class OpenSPPServicePoint(models.Model):
   _inherit = "spp.service.point"

   weekday_time_start = fields.Float(string='Start Time')
   weekday_time_end = fields.Float(string='End Time')

   weekend_time_start = fields.Float(string='Start Time')
   weekend_time_end = fields.Float(string='End Time')

The code mentioned above will introduce the new fields to the spp_service_point table for storing the operating hours for weekdays and weekends. To understand further, refer to the following documentation Link 1, Link 2, Link 3

  1. To integrate new fields into the UI, the following steps should be followed. Create a new file called views/service_point_views.xml in the module. Add the below code to the manifest file.

   "data": [
       "views/service_point_views.xml",
   ],

The following code can be added to the service_point_views.xml file to show the fields in the UI.

<?xml version="1.0" encoding="utf-8" ?>
<odoo>
   <record id="view_service_points_custom" model="ir.ui.view">
       <field name="name">view_service_points_custom</field>
       <field name="model">spp.service.point</field>
       <field name="inherit_id" ref="spp_service_points.view_service_points_form" />
       <field name="arch" type="xml">
           <xpath expr="//field[@name='disabled_reason']" position="after">
               <div >
                   <h2>Weekdays</h2>
               </div>
               <field name="weekday_time_start" widget="float_time" colspan="4" />
               <field name="weekday_time_end" widget="float_time" colspan="4" />
               <div>
                   <h2>Weekends</h2>
               </div>
               <field name="weekend_time_start" widget="float_time" colspan="4" />
               <field name="weekend_time_end" widget="float_time" colspan="4" />
           </xpath>
       </field>
   </record>
</odoo>
  1. To add the service types in the service type dropdown field, the following steps should be followed. Create a new file called data/service_type_data.xml in the module and add the below code to the manifest file.

   "data": [
       "data/service_type_data.xml",
       "views/service_point_views.xml",
   ],

The following code can be added to the service_type_data.xml file to add the service types.

<?xml version="1.0" encoding="utf-8" ?>
<odoo>
   <record id="voucher_redemption_center" model="spp.service.type">
       <field name="name">Voucher Redemption Center</field>
   </record>


   <record id="in_kind_goods_distribution" model="spp.service.type">
       <field name="name">In-Kind Goods Distribution</field>
   </record>


   <record id="information_desk" model="spp.service.type">
       <field name="name">Information Desk</field>
   </record>
</odoo>
  1. Install the module to include the new changes.

The following screenshot shows the newly added fields in the above developed module.