diff --git a/README.md b/README.md index 3869e244..97d44c0d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -[![Pre-commit Status](https://github.com/openg2p/openg2p-program/actions/workflows/pre-commit.yml/badge.svg?branch=17.0-develop)](https://github.com/openg2p/openg2p-program/actions/workflows/pre-commit.yml?query=branch%3A17.0-develop) -[![Build Status](https://github.com/openg2p/openg2p-program/actions/workflows/test.yml/badge.svg?branch=17.0-develop)](https://github.com/openg2p/openg2p-program/actions/workflows/test.yml?query=branch%3A17.0-develop) -[![codecov](https://codecov.io/gh/openg2p/openg2p-program/branch/17.0-develop/graph/badge.svg)](https://codecov.io/gh/openg2p/openg2p-program) +[![Pre-commit Status](https://github.com/openg2p/openg2p-program/actions/workflows/pre-commit.yml/badge.svg?branch=17.0-1.2)](https://github.com/openg2p/openg2p-program/actions/workflows/pre-commit.yml?query=branch%3A17.0-1.2) +[![Build Status](https://github.com/openg2p/openg2p-program/actions/workflows/test.yml/badge.svg?branch=17.0-1.2)](https://github.com/openg2p/openg2p-program/actions/workflows/test.yml?query=branch%3A17.0-1.2) +[![codecov](https://codecov.io/gh/openg2p/openg2p-program/branch/17.0-1.2/graph/badge.svg)](https://codecov.io/gh/openg2p/openg2p-program) @@ -21,43 +21,44 @@ Available addons ---------------- addon | version | maintainers | summary --- | --- | --- | --- -[g2p_entitlement_differential](g2p_entitlement_differential/) | 17.0.0.0.0 | | OpenG2P Entitlement: Differential -[g2p_entitlement_in_kind](g2p_entitlement_in_kind/) | 17.0.0.0.0 | | OpenG2P Entitlement: In-Kind -[g2p_entitlement_voucher](g2p_entitlement_voucher/) | 17.0.0.0.0 | | OpenG2P Entitlement: Voucher -[g2p_formio](g2p_formio/) | 17.0.0.0.0 | | Form builders allow you to create, manage, and use dynamic forms with ease. -[g2p_mis_importer](g2p_mis_importer/) | 17.0.0.0.0 | | G2P MIS Importer -[g2p_notifications_base](g2p_notifications_base/) | 17.0.0.0.0 | | G2P Notifications: Base -[g2p_notifications_fast2sms](g2p_notifications_fast2sms/) | 17.0.0.0.0 | | G2P Notifications: Fast2SMS Service Provider -[g2p_notifications_voucher](g2p_notifications_voucher/) | 17.0.0.0.0 | | G2P Notifications: Voucher -[g2p_notifications_wiserv](g2p_notifications_wiserv/) | 17.0.0.0.0 | | G2P Notifications: Wiserv SMS Service Provider -[g2p_odk_importer_program](g2p_odk_importer_program/) | 17.0.0.0.0 | | Import records from ODK and add then into Program -[g2p_openid_vci_programs](g2p_openid_vci_programs/) | 17.0.0.0.0 | | G2P OpenID VCI: Program Beneficiaries -[g2p_payment_cash](g2p_payment_cash/) | 17.0.0.0.0 | | OpenG2P Program Payment: Cash -[g2p_payment_files](g2p_payment_files/) | 17.0.0.0.0 | | OpenG2P Program Payments: In Files -[g2p_payment_g2p_connect](g2p_payment_g2p_connect/) | 17.0.0.0.0 | | OpenG2P Program Payment: G2P Connect Payment Manager -[g2p_payment_interop_layer](g2p_payment_interop_layer/) | 17.0.0.0.0 | | OpenG2P Program Payment (Payment Interoperability Layer) -[g2p_payment_phee](g2p_payment_phee/) | 17.0.0.0.0 | | OpenG2P Program Payment (Payment Hub EE) -[g2p_payment_simple_mpesa](g2p_payment_simple_mpesa/) | 17.0.0.0.0 | | OpenG2P Program Payment: Simple Mpesa Payment Manager -[g2p_program_approval](g2p_program_approval/) | 17.0.0.0.0 | | OpenG2P Program: Approval -[g2p_program_assessment](g2p_program_assessment/) | 17.0.0.0.0 | | OpenG2P Program: Assessment -[g2p_program_autoenrol](g2p_program_autoenrol/) | 17.0.0.0.0 | | OpenG2P Programs: Autoenrol -[g2p_program_cycleless](g2p_program_cycleless/) | 17.0.0.0.0 | | OpenG2P Programs: Cycleless -[g2p_program_documents](g2p_program_documents/) | 17.0.0.0.0 | | OpenG2P Program: Documents -[g2p_program_registrant_info](g2p_program_registrant_info/) | 17.0.0.0.0 | | G2P Program: Registrant Info -[g2p_program_reimbursement](g2p_program_reimbursement/) | 17.0.0.0.0 | | OpenG2P Programs: Reimbursement -[g2p_programs](g2p_programs/) | 17.0.0.0.0 | | OpenG2P Programs -[g2p_proxy_means_test](g2p_proxy_means_test/) | 17.0.0.0.0 | | G2P: Proxy Means Test -[g2p_social_registry_importer](g2p_social_registry_importer/) | 17.0.0.0.0 | | Import records from Social Registry -[g2p_theme](g2p_theme/) | 17.0.0.0.0 | | OpenG2P Theme +[g2p_entitlement_differential](g2p_entitlement_differential/) | 17.0.1.2.0 | | OpenG2P Entitlement: Differential +[g2p_entitlement_in_kind](g2p_entitlement_in_kind/) | 17.0.1.2.0 | | OpenG2P Entitlement: In-Kind +[g2p_entitlement_voucher](g2p_entitlement_voucher/) | 17.0.1.2.0 | | OpenG2P Entitlement: Voucher +[g2p_formio](g2p_formio/) | 17.0.1.2.0 | | Form builders allow you to create, manage, and use dynamic forms with ease. +[g2p_mis_importer](g2p_mis_importer/) | 17.0.1.2.0 | | G2P MIS Importer +[g2p_notifications_base](g2p_notifications_base/) | 17.0.1.2.0 | | G2P Notifications: Base +[g2p_notifications_fast2sms](g2p_notifications_fast2sms/) | 17.0.1.2.0 | | G2P Notifications: Fast2SMS Service Provider +[g2p_notifications_voucher](g2p_notifications_voucher/) | 17.0.1.2.0 | | G2P Notifications: Voucher +[g2p_notifications_wiserv](g2p_notifications_wiserv/) | 17.0.1.2.0 | | G2P Notifications: Wiserv SMS Service Provider +[g2p_odk_importer_program](g2p_odk_importer_program/) | 17.0.1.2.0 | | Import records from ODK and add then into Program +[g2p_openid_vci_programs](g2p_openid_vci_programs/) | 17.0.1.2.0 | | G2P OpenID VCI: Program Beneficiaries +[g2p_payment_cash](g2p_payment_cash/) | 17.0.1.2.0 | | OpenG2P Program Payment: Cash +[g2p_payment_files](g2p_payment_files/) | 17.0.1.2.0 | | OpenG2P Program Payments: In Files +[g2p_payment_g2p_connect](g2p_payment_g2p_connect/) | 17.0.1.2.0 | | OpenG2P Program Payment: G2P Connect Payment Manager +[g2p_payment_interop_layer](g2p_payment_interop_layer/) | 17.0.1.2.0 | | OpenG2P Program Payment (Payment Interoperability Layer) +[g2p_payment_phee](g2p_payment_phee/) | 17.0.1.2.0 | | OpenG2P Program Payment (Payment Hub EE) +[g2p_payment_simple_mpesa](g2p_payment_simple_mpesa/) | 17.0.1.2.0 | | OpenG2P Program Payment: Simple Mpesa Payment Manager +[g2p_program_approval](g2p_program_approval/) | 17.0.1.2.0 | | OpenG2P Program: Approval +[g2p_program_assessment](g2p_program_assessment/) | 17.0.1.2.0 | | OpenG2P Program: Assessment +[g2p_program_autoenrol](g2p_program_autoenrol/) | 17.0.1.2.0 | | OpenG2P Programs: Autoenrol +[g2p_program_cycleless](g2p_program_cycleless/) | 17.0.1.2.0 | | OpenG2P Programs: Cycleless +[g2p_program_documents](g2p_program_documents/) | 17.0.1.2.0 | | OpenG2P Program: Documents +[g2p_program_registrant_info](g2p_program_registrant_info/) | 17.0.1.2.0 | | G2P Program: Registrant Info +[g2p_program_reimbursement](g2p_program_reimbursement/) | 17.0.1.2.0 | | OpenG2P Programs: Reimbursement +[g2p_programs](g2p_programs/) | 17.0.1.2.0 | | OpenG2P Programs +[g2p_proxy_means_test](g2p_proxy_means_test/) | 17.0.1.2.0 | | G2P: Proxy Means Test +[g2p_reimbursement_portal](g2p_reimbursement_portal/) | 17.0.0.0.0 | | G2P Reimbursement Portal +[g2p_social_registry_importer](g2p_social_registry_importer/) | 17.0.1.2.0 | | Import records from Social Registry +[g2p_theme](g2p_theme/) | 17.0.1.2.0 | | OpenG2P Theme Unported addons --------------- addon | version | maintainers | summary --- | --- | --- | --- -[g2p_notifications_rest_api](g2p_notifications_rest_api/) | 17.0.0.0.0 (unported) | | G2P Notifications: REST API -[g2p_program_registrant_info_rest_api](g2p_program_registrant_info_rest_api/) | 17.0.0.0.0 (unported) | | G2P Program : Program Registrant Info Rest API -[g2p_programs_rest_api](g2p_programs_rest_api/) | 17.0.0.0.0 (unported) | | G2P Programs: REST API +[g2p_notifications_rest_api](g2p_notifications_rest_api/) | 17.0.1.2.0 (unported) | | G2P Notifications: REST API +[g2p_program_registrant_info_rest_api](g2p_program_registrant_info_rest_api/) | 17.0.1.2.0 (unported) | | G2P Program : Program Registrant Info Rest API +[g2p_programs_rest_api](g2p_programs_rest_api/) | 17.0.1.2.0 (unported) | | G2P Programs: REST API [//]: # (end addons) diff --git a/g2p_entitlement_differential/__manifest__.py b/g2p_entitlement_differential/__manifest__.py index 40d9e86e..71cbad2c 100644 --- a/g2p_entitlement_differential/__manifest__.py +++ b/g2p_entitlement_differential/__manifest__.py @@ -2,7 +2,7 @@ "name": "OpenG2P Entitlement: Differential", "category": "G2P", # Part of OpenG2P. See LICENSE file for full copyright and licensing details. - "version": "17.0.0.0.0", + "version": "17.0.1.2.0", "sequence": 1, "author": "OpenG2P", "website": "https://openg2p.org", diff --git a/g2p_entitlement_differential/readme/DESCRIPTION.rst b/g2p_entitlement_differential/readme/DESCRIPTION.rst deleted file mode 100644 index 67c1d60d..00000000 --- a/g2p_entitlement_differential/readme/DESCRIPTION.rst +++ /dev/null @@ -1 +0,0 @@ -G2P Differential Entitlement diff --git a/g2p_entitlement_in_kind/__manifest__.py b/g2p_entitlement_in_kind/__manifest__.py index 765fdd5d..b57db4c1 100644 --- a/g2p_entitlement_in_kind/__manifest__.py +++ b/g2p_entitlement_in_kind/__manifest__.py @@ -2,7 +2,7 @@ { "name": "OpenG2P Entitlement: In-Kind", "category": "G2P", - "version": "17.0.0.0.0", + "version": "17.0.1.2.0", "sequence": 1, "author": "OpenG2P", "website": "https://openg2p.org", diff --git a/g2p_entitlement_in_kind/readme/DESCRIPTION.rst b/g2p_entitlement_in_kind/readme/DESCRIPTION.rst deleted file mode 100644 index 53e1dc71..00000000 --- a/g2p_entitlement_in_kind/readme/DESCRIPTION.rst +++ /dev/null @@ -1 +0,0 @@ -OpenG2P In-Kind Entitlement diff --git a/g2p_entitlement_voucher/__manifest__.py b/g2p_entitlement_voucher/__manifest__.py index 6aabc20f..1b51c583 100644 --- a/g2p_entitlement_voucher/__manifest__.py +++ b/g2p_entitlement_voucher/__manifest__.py @@ -2,7 +2,7 @@ { "name": "OpenG2P Entitlement: Voucher", "category": "G2P", - "version": "17.0.0.0.0", + "version": "17.0.1.2.0", "sequence": 1, "author": "OpenG2P", "website": "https://openg2p.org", diff --git a/g2p_formio/__manifest__.py b/g2p_formio/__manifest__.py index 5db8c775..430f2288 100644 --- a/g2p_formio/__manifest__.py +++ b/g2p_formio/__manifest__.py @@ -2,7 +2,7 @@ { "name": "OpenG2P Formio", "category": "G2P", - "version": "17.0.0.0.0", + "version": "17.0.1.2.0", "sequence": 1, "summary": "Form builders allow you to create, manage, and use dynamic forms with ease.", "author": "OpenG2P", @@ -17,6 +17,7 @@ "g2p_program_documents", ], "data": [ + "data/formio_default_js_option.xml", "views/formio_builder.xml", "views/program_view.xml", "wizard/g2p_self_service_program_view_wizard.xml", diff --git a/g2p_formio/data/formio_default_js_option.xml b/g2p_formio/data/formio_default_js_option.xml new file mode 100644 index 00000000..83714c00 --- /dev/null +++ b/g2p_formio/data/formio_default_js_option.xml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/g2p_formio/i18n/g2p_formio.pot b/g2p_formio/i18n/g2p_formio.pot index eade3705..8cf66425 100644 --- a/g2p_formio/i18n/g2p_formio.pot +++ b/g2p_formio/i18n/g2p_formio.pot @@ -18,6 +18,16 @@ msgstr "" msgid "Create a New Program Wizard" msgstr "" +#. module: g2p_formio +#: model:ir.model,name:g2p_formio.model_formio_builder +msgid "Form Builder" +msgstr "" + +#. module: g2p_formio +#: model:ir.model.fields,field_description:g2p_formio.field_formio_builder__is_form_mapped_with_program +msgid "Is Form Mapped" +msgstr "" + #. module: g2p_formio #: model:ir.model.fields,field_description:g2p_formio.field_g2p_program__is_multiple_form_submission #: model:ir.model.fields,field_description:g2p_formio.field_g2p_program_create_wizard__is_multiple_form_submission @@ -36,8 +46,8 @@ msgid "Program" msgstr "" #. module: g2p_formio -#: model:ir.model.fields,field_description:g2p_formio.field_g2p_program__self_service_portal_form -#: model:ir.model.fields,field_description:g2p_formio.field_g2p_program_create_wizard__self_service_portal_form +#: model:ir.model.fields,field_description:g2p_formio.field_g2p_program__portal_form_builder_id +#: model:ir.model.fields,field_description:g2p_formio.field_g2p_program_create_wizard__portal_form_builder_id msgid "Program Form" msgstr "" diff --git a/g2p_formio/models/program.py b/g2p_formio/models/program.py index 7125a4d5..dcf28c3c 100644 --- a/g2p_formio/models/program.py +++ b/g2p_formio/models/program.py @@ -1,9 +1,60 @@ -from odoo import fields, models +import json + +from odoo import api, fields, models class G2PProgram(models.Model): _inherit = "g2p.program" - self_service_portal_form = fields.Many2one("formio.builder", string="Program Form") + portal_form_builder_id = fields.Many2one( + "formio.builder", string="Program Form", domain="[('is_form_mapped_with_program', '=', False)]" + ) is_multiple_form_submission = fields.Boolean(default=False) + + @api.constrains("portal_form_builder_id") + def _constrain_portal_form_mapping(self): + self.ensure_one() + + if self.portal_form_builder_id: + formio_builder = self.portal_form_builder_id + + try: + # Parse the JSON string into a dictionary + js_options = json.loads(formio_builder.formio_js_options) + + if "editForm" in js_options and "file" in js_options["editForm"]: + file_components = js_options["editForm"]["file"][0]["components"] + + for component in file_components: + if "defaultValue" in component and component["key"] == "url": + component["defaultValue"] = f"/v1/selfservice/uploadDocument/{self.id}" + + # Convert back to JSON string and update the builder + formio_builder.write( + { + "formio_js_options": json.dumps(js_options, indent=4), + "is_form_mapped_with_program": True, + } + ) + else: + formio_builder.write({"is_form_mapped_with_program": False}) + + except (json.JSONDecodeError, KeyError, IndexError): + # Handle potential JSON parsing errors or missing keys + formio_builder.write({"is_form_mapped_with_program": False}) + + @api.onchange("portal_form_builder_id") + def _onchange_portal_form_unmapping(self): + # Check if there was a previous form that is now being removed + previous_form = self._origin.portal_form_builder_id + current_form = self.portal_form_builder_id + + if previous_form and not current_form: + previous_form.write({"is_form_mapped_with_program": False}) + + +class G2PProgramFomio(models.Model): + _inherit = "formio.builder" + + is_form_mapped_with_program = fields.Boolean(string="Is Form Mapped", default=False) diff --git a/g2p_formio/views/formio_builder.xml b/g2p_formio/views/formio_builder.xml index 6cb21717..fbe1f0f4 100644 --- a/g2p_formio/views/formio_builder.xml +++ b/g2p_formio/views/formio_builder.xml @@ -21,8 +21,8 @@ 1 - - 1 + +