From 73f58a5b5e1a864a5d7b6723c400e89f804865ea Mon Sep 17 00:00:00 2001 From: emjay0921 Date: Wed, 8 Nov 2023 13:10:18 +0000 Subject: [PATCH 1/2] initital commit spp_pmt --- setup/spp_pmt/odoo/addons/spp_pmt | 1 + setup/spp_pmt/setup.py | 6 + spp_pmt/README.rst | 68 ++++ spp_pmt/__init__.py | 3 + spp_pmt/__manifest__.py | 30 ++ spp_pmt/models/__init__.py | 4 + spp_pmt/models/custom_fields_ui.py | 10 + spp_pmt/models/pmt.py | 78 +++++ spp_pmt/static/description/icon.png | Bin 0 -> 12567 bytes spp_pmt/static/description/index.html | 415 +++++++++++++++++++++++ spp_pmt/views/custom_fields_ui_view.xml | 17 + spp_pmt/views/custom_registrant_view.xml | 17 + 12 files changed, 649 insertions(+) create mode 120000 setup/spp_pmt/odoo/addons/spp_pmt create mode 100644 setup/spp_pmt/setup.py create mode 100644 spp_pmt/README.rst create mode 100644 spp_pmt/__init__.py create mode 100644 spp_pmt/__manifest__.py create mode 100644 spp_pmt/models/__init__.py create mode 100644 spp_pmt/models/custom_fields_ui.py create mode 100644 spp_pmt/models/pmt.py create mode 100644 spp_pmt/static/description/icon.png create mode 100644 spp_pmt/static/description/index.html create mode 100644 spp_pmt/views/custom_fields_ui_view.xml create mode 100644 spp_pmt/views/custom_registrant_view.xml diff --git a/setup/spp_pmt/odoo/addons/spp_pmt b/setup/spp_pmt/odoo/addons/spp_pmt new file mode 120000 index 00000000..01dac969 --- /dev/null +++ b/setup/spp_pmt/odoo/addons/spp_pmt @@ -0,0 +1 @@ +../../../../spp_pmt \ No newline at end of file diff --git a/setup/spp_pmt/setup.py b/setup/spp_pmt/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/spp_pmt/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/spp_pmt/README.rst b/spp_pmt/README.rst new file mode 100644 index 00000000..ee593876 --- /dev/null +++ b/spp_pmt/README.rst @@ -0,0 +1,68 @@ +======================== +OpenSPP Proxy Means Test +======================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-openspp%2Fopenspp--registry-lightgray.png?logo=github + :target: https://github.com/openspp/openspp-registry/tree/15.0/spp_pmt + :alt: openspp/openspp-registry + +|badge1| |badge2| |badge3| + +OpenSPP Proxy Means Test + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* OpenSPP.org + +Maintainers +~~~~~~~~~~~ + +.. |maintainer-jeremi| image:: https://github.com/jeremi.png?size=40px + :target: https://github.com/jeremi + :alt: jeremi +.. |maintainer-gonzalesedwin1123| image:: https://github.com/gonzalesedwin1123.png?size=40px + :target: https://github.com/gonzalesedwin1123 + :alt: gonzalesedwin1123 + +Current maintainers: + +|maintainer-jeremi| |maintainer-gonzalesedwin1123| + +This module is part of the `openspp/openspp-registry `_ project on GitHub. + +You are welcome to contribute. diff --git a/spp_pmt/__init__.py b/spp_pmt/__init__.py new file mode 100644 index 00000000..c4ccea79 --- /dev/null +++ b/spp_pmt/__init__.py @@ -0,0 +1,3 @@ +# Part of OpenSPP. See LICENSE file for full copyright and licensing details. + +from . import models diff --git a/spp_pmt/__manifest__.py b/spp_pmt/__manifest__.py new file mode 100644 index 00000000..c4348728 --- /dev/null +++ b/spp_pmt/__manifest__.py @@ -0,0 +1,30 @@ +# Part of OpenSPP. See LICENSE file for full copyright and licensing details. + + +{ + "name": "Proxy Means Testing", + "category": "OpenSPP", + "version": "15.0.0.0.0", + "sequence": 1, + "author": "OpenSPP.org", + "website": "https://github.com/openspp/openspp-registry", + "license": "LGPL-3", + "development_status": "Beta", + "maintainers": ["dasunhegoda"], + "depends": [ + "base", + "g2p_registry_base", + "g2p_registry_group", + "spp_custom_fields_ui", + ], + "data": [ + "views/custom_fields_ui_view.xml", + "views/custom_registrant_view.xml", + ], + "assets": {}, + "demo": [], + "images": [], + "application": True, + "installable": True, + "auto_install": False, +} diff --git a/spp_pmt/models/__init__.py b/spp_pmt/models/__init__.py new file mode 100644 index 00000000..6ebcbb15 --- /dev/null +++ b/spp_pmt/models/__init__.py @@ -0,0 +1,4 @@ +# Part of OpenSPP. See LICENSE file for full copyright and licensing details. + +from . import pmt +from . import custom_fields_ui diff --git a/spp_pmt/models/custom_fields_ui.py b/spp_pmt/models/custom_fields_ui.py new file mode 100644 index 00000000..d9cbd980 --- /dev/null +++ b/spp_pmt/models/custom_fields_ui.py @@ -0,0 +1,10 @@ +# Part of OpenSPP. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models + + +class OpenSPPCustomFieldsUI(models.Model): + _inherit = "ir.model.fields" + + field_weight = fields.Float("Weight", default=0) + with_weight = fields.Boolean(default=False) diff --git a/spp_pmt/models/pmt.py b/spp_pmt/models/pmt.py new file mode 100644 index 00000000..b956182f --- /dev/null +++ b/spp_pmt/models/pmt.py @@ -0,0 +1,78 @@ +# Part of OpenSPP. See LICENSE file for full copyright and licensing details. +import logging + +from odoo import fields, models + +_logger = logging.getLogger(__name__) + + +# Extending the built-in res.partner model in Odoo to accommodate PMT specific fields +class G2PGroupPMT(models.Model): + _inherit = "res.partner" + + # Boolean fields capturing specific conditions of an individual + x_cst_indv_gce_ol = fields.Boolean("Lower than G.C.E. Ordinary Level") + x_cst_indv_school_age = fields.Boolean( + "Currently not attending school or other educational institution" + ) + x_cst_indv_chronic_disease = fields.Boolean("Long-term (chronic) disease") + x_cst_indv_disability = fields.Boolean("Disability") + + # Floating-point field to store the computed PMT score of the group + z_ind_grp_pmt_score = fields.Float( + "PMT Score of the group", + compute="_compute_pmt_score", + ) + grp_pmt_score = fields.Float( + "PMT Score of the group", compute="_compute_pmt_score", store=True + ) + area_calc = fields.Many2one("spp.area", compute="_compute_area") + + def _compute_area(self): + for rec in self: + area_calc = None + if rec.is_group: + if rec.group_membership_ids: + individual = rec.group_membership_ids.mapped("individual.id") + members = self.env["res.partner"].search( + [("id", "in", individual), ("area_id", "!=", False)] + ) + if members: + area_calc = members[0].area_id.id + + if area_calc: + rec.area_id = area_calc + + rec.area_calc = area_calc + + def _compute_pmt_score(self): + model = self.env["ir.model"].search([("model", "=", "res.partner")]) + + fields = self.env["ir.model.fields"].search( + [ + ("model_id", "=", model.id), + ("with_weight", "=", True), + ("target_type", "=", "indv"), + ] + ) + weights = {} + if fields: + for field in fields: + weights.update({field.name: field.field_weight}) + + if weights: + for record in self: + z_ind_grp_pmt_score = 0 + if record.group_membership_ids: + total_score = 0.0 + total_weight = 0.0 + # Iterating through each member of the group to calculate the PMT score + for ind in record.group_membership_ids: + for field, weight in weights.items(): + if hasattr(ind.individual, field): + total_score += getattr(ind.individual, field) * weight + total_weight += weight + z_ind_grp_pmt_score = total_score / total_weight + + record.z_ind_grp_pmt_score = z_ind_grp_pmt_score + record.grp_pmt_score = z_ind_grp_pmt_score diff --git a/spp_pmt/static/description/icon.png b/spp_pmt/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..35f8fec263588314689c920efc4b6728b407daaa GIT binary patch literal 12567 zcmW+-b66#B8$Q|AW^J`;v$sxev+Xuxv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;u>({wIJ~SCiG}u7c&hBD*!*c*w>QW8vxpgnNm+e0zViBT0 zqu#ACIo^;b*Osmy0NKegKp`suNC6~hbM6-`U|IcLN$Fw3B*DPttJBw59VFZIEt+v5 zD$%+;YbhOv2Ynsx`~v9wpZlL*uife=tDxZEYhOY?CDU&oGMLVV86Oakbf_75(XmN@ zp~4;j4c1Hn6e#h!NIl2Fy{ zopF_ZXkI}4fd{xncTewO5uCyk>0<>=S={|}$$kP?EreV{me z$KUn3t)G0dxi~$Fos+-YS|cl1O$+*wy-)b~+6Co61!YaVB^fsXX7JQ}4SLTR%FNg@ z(OUO-2)zJM9ZDdADlZQB1lsHc7c(W4ukvlYxU7eqz^!`zmLHvwS-<)*PmOF7W(TBX z5jbaeCgL$VHqw$lT^68a9o19TsLWO%&qM%ISp(P3eL8?`uEp!r(>pyvXOGZV5{`di zyf9ab@JcQ;b^U)@#Fzr=!~J?hsr!*;Di>pNMReKDk=!PzN}A}njo)23D;iK9GRk&x z!hYKP|8Ez7QNsz+GRF?Rt$#cZ6i``XsluS69{kt?`JoQJO=6v1WfU_iE*)!WDwiOOVqV8uV zv#ws08P)`(RYv_yxOEGx&lj{f_6A5ICuQ5dW&ZX{wMY0V{p6FOJ#(eaLrw;Umr3&*y?f>)X zfeu{efiZqCb&z5SVp + + + + + +OpenSPP Custom Fields UI + + + +
+

OpenSPP Custom Fields UI

+ + +

Alpha License: LGPL-3 openspp/openspp-registry

+

OpenSPP Custom Field UI

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • OpenSPP.org
  • +
+
+
+

Maintainers

+

Current maintainers:

+

jeremi gonzalesedwin1123

+

This module is part of the openspp/openspp-registry project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/spp_pmt/views/custom_fields_ui_view.xml b/spp_pmt/views/custom_fields_ui_view.xml new file mode 100644 index 00000000..cf58cc3a --- /dev/null +++ b/spp_pmt/views/custom_fields_ui_view.xml @@ -0,0 +1,17 @@ + + + + + view_custom_fields_ui_pmt_form + ir.model.fields + 1000 + + + + + + + + + + diff --git a/spp_pmt/views/custom_registrant_view.xml b/spp_pmt/views/custom_registrant_view.xml new file mode 100644 index 00000000..5828dc26 --- /dev/null +++ b/spp_pmt/views/custom_registrant_view.xml @@ -0,0 +1,17 @@ + + + + + view_groups_pmt_form + res.partner + 1000 + + + + + + + + + + From 1d1bcab7663efb4973ccd25108ad6c81b578ea69 Mon Sep 17 00:00:00 2001 From: emjay0921 Date: Tue, 14 Nov 2023 04:41:01 +0000 Subject: [PATCH 2/2] add computation by areas --- spp_pmt/__manifest__.py | 2 ++ spp_pmt/models/custom_fields_ui.py | 12 +++++++++++- spp_pmt/models/pmt.py | 12 +++++++++++- spp_pmt/security/ir.model.access.csv | 2 ++ spp_pmt/views/custom_fields_ui_view.xml | 6 ++++++ 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 spp_pmt/security/ir.model.access.csv diff --git a/spp_pmt/__manifest__.py b/spp_pmt/__manifest__.py index c4348728..c740bf24 100644 --- a/spp_pmt/__manifest__.py +++ b/spp_pmt/__manifest__.py @@ -16,8 +16,10 @@ "g2p_registry_base", "g2p_registry_group", "spp_custom_fields_ui", + "spp_area", ], "data": [ + "security/ir.model.access.csv", "views/custom_fields_ui_view.xml", "views/custom_registrant_view.xml", ], diff --git a/spp_pmt/models/custom_fields_ui.py b/spp_pmt/models/custom_fields_ui.py index d9cbd980..99c44af2 100644 --- a/spp_pmt/models/custom_fields_ui.py +++ b/spp_pmt/models/custom_fields_ui.py @@ -6,5 +6,15 @@ class OpenSPPCustomFieldsUI(models.Model): _inherit = "ir.model.fields" - field_weight = fields.Float("Weight", default=0) + field_weight = fields.Float("Default Weight", default=0) with_weight = fields.Boolean(default=False) + area_ids = fields.One2many("spp.fields.area", "field_id", string="Areas") + + +class OpenSPPCustomFieldsArea(models.Model): + _name = "spp.fields.area" + _description = "Fields Area" + + field_id = fields.Many2one("ir.model.fields") + name = fields.Many2one("spp.area", required=True, string="Area") + weight = fields.Float(required=True, default=0) diff --git a/spp_pmt/models/pmt.py b/spp_pmt/models/pmt.py index b956182f..23817681 100644 --- a/spp_pmt/models/pmt.py +++ b/spp_pmt/models/pmt.py @@ -46,6 +46,9 @@ def _compute_area(self): rec.area_calc = area_calc def _compute_pmt_score(self): + + hh_area = self.area_id + model = self.env["ir.model"].search([("model", "=", "res.partner")]) fields = self.env["ir.model.fields"].search( @@ -58,7 +61,14 @@ def _compute_pmt_score(self): weights = {} if fields: for field in fields: - weights.update({field.name: field.field_weight}) + if hh_area: + areas = field.area_ids.filtered(lambda a: a.name.id == hh_area.id) + if areas: + weights.update({field.name: areas[0].weight}) + else: + weights.update({field.name: field.field_weight}) + else: + weights.update({field.name: field.field_weight}) if weights: for record in self: diff --git a/spp_pmt/security/ir.model.access.csv b/spp_pmt/security/ir.model.access.csv new file mode 100644 index 00000000..d09bed2e --- /dev/null +++ b/spp_pmt/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +spp_fields_area_admin,Fields Area Admin Access,spp_pmt.model_spp_fields_area,g2p_registry_base.group_g2p_admin,1,1,1,1 diff --git a/spp_pmt/views/custom_fields_ui_view.xml b/spp_pmt/views/custom_fields_ui_view.xml index cf58cc3a..8cfd5109 100644 --- a/spp_pmt/views/custom_fields_ui_view.xml +++ b/spp_pmt/views/custom_fields_ui_view.xml @@ -10,6 +10,12 @@ + + + + + +