Skip to content
This repository was archived by the owner on Mar 28, 2024. It is now read-only.

Add module spp_programs_sp for managing service points in entitlements #110

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup/spp_programs_sp/odoo/addons/spp_programs_sp
6 changes: 6 additions & 0 deletions setup/spp_programs_sp/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
3 changes: 3 additions & 0 deletions spp_programs_sp/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
=====================================================
OpenSPP Program Management: Service Point Integration
=====================================================
4 changes: 4 additions & 0 deletions spp_programs_sp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.

from . import models
from . import wizard
32 changes: 32 additions & 0 deletions spp_programs_sp/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
{
"name": "OpenSPP Programs (Service Points Integration)",
"category": "OpenSPP",
"version": "15.0.0.0.0",
"sequence": 1,
"author": "OpenSPP.org",
"website": "https://github.com/openspp/openspp-program",
"license": "LGPL-3",
"development_status": "Alpha",
"maintainers": ["jeremi", "gonzalesedwin1123"],
"depends": [
"base",
"g2p_programs",
"spp_programs",
"spp_service_points",
"g2p_entitlement_cash",
"spp_entitlement_in_kind",
],
"data": [
"wizard/create_program_wizard.xml",
"wizard/create_program_wizard.xml",
"views/programs_view.xml",
"views/entitlements_view.xml",
],
"assets": {},
"demo": [],
"images": [],
"application": True,
"installable": True,
"auto_install": False,
}
8 changes: 8 additions & 0 deletions spp_programs_sp/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.

from . import programs
from . import entitlement_cash
from . import entitlement_inkind
from . import entitlement_manager_default
from . import entitlement_manager_cash
from . import entitlement_manager_inkind
18 changes: 18 additions & 0 deletions spp_programs_sp/models/entitlement_cash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.

import logging

from odoo import fields, models

_logger = logging.getLogger(__name__)


class CustomSPPProgramEntitlementCash(models.Model):
"""
Add the handling of service points in entitlements
"""

_inherit = "g2p.entitlement"

service_point_ids = fields.Many2many("spp.service.point", string="Service Points")
service_point_id = fields.Many2one("spp.service.point", "Service Point")
17 changes: 17 additions & 0 deletions spp_programs_sp/models/entitlement_inkind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.

import logging

from odoo import fields, models

_logger = logging.getLogger(__name__)


class CustomSPPProgramEntitlementInKind(models.Model):
"""
Add the handling of service points in entitlements
"""

_inherit = "g2p.entitlement.inkind"

service_point_ids = fields.Many2many("spp.service.point", string="Service Points")
49 changes: 49 additions & 0 deletions spp_programs_sp/models/entitlement_manager_cash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
import logging

from odoo import models

_logger = logging.getLogger(__name__)


class G2PCashEntitlementManagerCustomSP(models.Model):
"""
G2PCashEntitlementManagerCustomSP adds the management of service points in
generating entitlements using the cash entitlement manager.

If the value of store_sp_in_entitlements in g2p.programs is True, then all generated entitlements
must store the beneficiaries service points.

"""

_inherit = "g2p.program.entitlement.manager.cash"

def _get_addl_entitlement_fields(self, beneficiary_id):
"""
Extends this function to include the service_point_ids if enabled in the program configuration.
Add the service_point_ids of the beneficiaries based on the program config.
"""
retval = super()._get_addl_entitlement_fields(beneficiary_id)
# Check if service points needs to be added in the entitlements
use_service_point_ids = False
if self.program_id.store_sp_in_entitlements:
use_service_point_ids = True

# Get the beneficiarie's service points
if use_service_point_ids:
service_point_ids = beneficiary_id.service_point_ids or None
else:
service_point_ids = None

# Add the service points to the entitlement
if retval:
retval.update(
{
"service_point_ids": service_point_ids,
}
)
else:
retval = {
"service_point_ids": service_point_ids,
}
return retval
49 changes: 49 additions & 0 deletions spp_programs_sp/models/entitlement_manager_default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
import logging

from odoo import models

_logger = logging.getLogger(__name__)


class G2PDefaultEntitlementManagerCustomSP(models.Model):
"""
G2PDefaultEntitlementManagerCustomSP adds the management of service points in
generating entitlements using the default entitlement manager.

If the value of store_sp_in_entitlements in g2p.programs is True, then all generated entitlements
must store the beneficiaries service points.

"""

_inherit = "g2p.program.entitlement.manager.default"

def _get_addl_entitlement_fields(self, beneficiary_id):
"""
Extends this function to include the service_point_ids if enabled in the program configuration.
Add the service_point_ids of the beneficiaries based on the program config.
"""
retval = super()._get_addl_entitlement_fields(beneficiary_id)
# Check if service points needs to be added in the entitlements
use_service_point_ids = False
if self.program_id.store_sp_in_entitlements:
use_service_point_ids = True

# Get the beneficiarie's service points
if use_service_point_ids:
service_point_ids = beneficiary_id.service_point_ids or None
else:
service_point_ids = None

# Add the service points to the entitlement
if retval:
retval.update(
{
"service_point_ids": service_point_ids,
}
)
else:
retval = {
"service_point_ids": service_point_ids,
}
return retval
49 changes: 49 additions & 0 deletions spp_programs_sp/models/entitlement_manager_inkind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
import logging

from odoo import models

_logger = logging.getLogger(__name__)


class G2PInKindEntitlementManagerCustomSP(models.Model):
"""
G2PInKindEntitlementManagerCustomSP adds the management of service points in
generating entitlements using the in-kind entitlement manager.

If the value of store_sp_in_entitlements in g2p.programs is True, then all generated entitlements
must store the beneficiaries service points.

"""

_inherit = "g2p.program.entitlement.manager.inkind"

def _get_addl_entitlement_fields(self, beneficiary_id):
"""
Extends this function to include the service_point_ids if enabled in the program configuration.
Add the service_point_ids of the beneficiaries based on the program config.
"""
retval = super()._get_addl_entitlement_fields(beneficiary_id)
# Check if service points needs to be added in the entitlements
use_service_point_ids = False
if self.program_id.store_sp_in_entitlements:
use_service_point_ids = True

# Get the beneficiarie's service points
if use_service_point_ids:
service_point_ids = beneficiary_id.service_point_ids or None
else:
service_point_ids = None

# Add the service points to the entitlement
if retval:
retval.update(
{
"service_point_ids": service_point_ids,
}
)
else:
retval = {
"service_point_ids": service_point_ids,
}
return retval
17 changes: 17 additions & 0 deletions spp_programs_sp/models/programs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.

import logging

from odoo import fields, models

_logger = logging.getLogger(__name__)


class CustomG2PProgram(models.Model):
"""
Add the handling of service points in entitlements
"""

_inherit = "g2p.program"

store_sp_in_entitlements = fields.Boolean("Store Service Points to Entitlements")
Binary file added spp_programs_sp/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading