From 936ed4fb44908ffb728a05952f7878a7d9f09229 Mon Sep 17 00:00:00 2001 From: mkumar-02 Date: Fri, 9 Aug 2024 10:02:42 +0530 Subject: [PATCH 1/5] Social Registry: Add unique ref_id Signed-off-by: mkumar-02 --- g2p_social_registry/__init__.py | 8 ++ g2p_social_registry/__manifest__.py | 4 + g2p_social_registry/data/cron_job.xml | 13 +++ .../data/default_ref_id_config.xml | 9 ++ g2p_social_registry/models/__init__.py | 5 +- g2p_social_registry/models/pending_ref_id.py | 26 ++++++ g2p_social_registry/models/ref_id_config.py | 83 +++++++++++++++++++ g2p_social_registry/models/region.py | 2 +- g2p_social_registry/models/registrant.py | 52 +++++++++++- .../models/res_config_settings.py | 49 +++++++++++ .../security/ir.model.access.csv | 4 + g2p_social_registry/views/registrant_view.xml | 7 +- .../views/res_config_settings_view.xml | 36 ++++++++ 13 files changed, 294 insertions(+), 4 deletions(-) create mode 100644 g2p_social_registry/data/cron_job.xml create mode 100644 g2p_social_registry/data/default_ref_id_config.xml create mode 100644 g2p_social_registry/models/pending_ref_id.py create mode 100644 g2p_social_registry/models/ref_id_config.py create mode 100644 g2p_social_registry/models/res_config_settings.py create mode 100644 g2p_social_registry/views/res_config_settings_view.xml diff --git a/g2p_social_registry/__init__.py b/g2p_social_registry/__init__.py index c32726c..4618ddb 100644 --- a/g2p_social_registry/__init__.py +++ b/g2p_social_registry/__init__.py @@ -1,2 +1,10 @@ # Part of OpenG2P Registry. See LICENSE file for full copyright and licensing details. from . import models + + +def post_init_hook(env): + partners = env["res.partner"].search([("is_registrant", "=", True), ("ref_id", "=", False)]) + for partner in partners: + env["g2p.pending.reference_id"].create( + {"registrant_id": partner.id, "status": "under_process"} + ) diff --git a/g2p_social_registry/__manifest__.py b/g2p_social_registry/__manifest__.py index 39400cc..528f901 100644 --- a/g2p_social_registry/__manifest__.py +++ b/g2p_social_registry/__manifest__.py @@ -16,9 +16,12 @@ "external_dependencies": {}, "data": [ "security/ir.model.access.csv", + "data/cron_job.xml", + "data/default_ref_id_config.xml", "views/main_view.xml", "views/region.xml", "views/registrant_view.xml", + "views/res_config_settings_view.xml", ], "assets": {}, "demo": [], @@ -26,4 +29,5 @@ "application": True, "installable": True, "auto_install": False, + "post_init_hook": "post_init_hook", } diff --git a/g2p_social_registry/data/cron_job.xml b/g2p_social_registry/data/cron_job.xml new file mode 100644 index 0000000..61cc0c7 --- /dev/null +++ b/g2p_social_registry/data/cron_job.xml @@ -0,0 +1,13 @@ + + + Reference ID Generation Cron Job + + code + model.retry_generate_ref_id() + 1 + minutes + -1 + + + + diff --git a/g2p_social_registry/data/default_ref_id_config.xml b/g2p_social_registry/data/default_ref_id_config.xml new file mode 100644 index 0000000..f706f7f --- /dev/null +++ b/g2p_social_registry/data/default_ref_id_config.xml @@ -0,0 +1,9 @@ + + + + + Default Reference ID Config + + diff --git a/g2p_social_registry/models/__init__.py b/g2p_social_registry/models/__init__.py index af928d9..b27b348 100644 --- a/g2p_social_registry/models/__init__.py +++ b/g2p_social_registry/models/__init__.py @@ -1,4 +1,7 @@ -# Part of OpenG2P Social Registry. See LICENSE file for full copyright and licensing details. +# Part of OpenG2P. See LICENSE file for full copyright and licensing details. from . import region +from . import ref_id_config +from . import res_config_settings from . import registrant +from . import pending_ref_id diff --git a/g2p_social_registry/models/pending_ref_id.py b/g2p_social_registry/models/pending_ref_id.py new file mode 100644 index 0000000..4d527d4 --- /dev/null +++ b/g2p_social_registry/models/pending_ref_id.py @@ -0,0 +1,26 @@ +import logging + +from odoo import api, fields, models + +_logger = logging.getLogger(__name__) + + +class FallbackTable(models.Model): + _name = "g2p.pending.reference_id" + + registrant_id = fields.Many2one("res.partner") + ref_id = fields.Char() + status = fields.Selection( + [("under_process", "Under Process"), ("resolved", "Resolved")], default="under_process" + ) + + @api.model + def retry_generate_ref_id(self): + records = self.search([("status", "=", "under_process")]) + for record in records: + partner = record.registrant_id + if partner: + partner.generate_ref_id() + if partner.ref_id: + record.status = "resolved" + record.ref_id = partner.ref_id diff --git a/g2p_social_registry/models/ref_id_config.py b/g2p_social_registry/models/ref_id_config.py new file mode 100644 index 0000000..64f24ce --- /dev/null +++ b/g2p_social_registry/models/ref_id_config.py @@ -0,0 +1,83 @@ +import logging +import os +from datetime import datetime + +import httpx +from jose import jwt + +from odoo import _, api, fields, models +from odoo.exceptions import UserError + +_logger = logging.getLogger(__name__) + +ID_GENERATOR_API_BASE_URL = os.getenv( + "ID_GENERATOR_API_BASE_URL", "https://api-internal.dev.mosip.net/v1/idgenerator/uin" +) +ID_GENERATOR_AUTH_URL = os.getenv( + "ID_GENERATOR_AUTH_URL", + "https://api-internal.dev.mosip.net/v1/authmanager/authenticate/clientidsecretkey", +) +ID_GENERATOR_AUTH_CLIENT_ID = os.getenv("ID_GENERATOR_AUTH_CLIENT_ID", "mosip-idrepo-client") +ID_GENERATOR_AUTH_CLIENT_SECRET = os.getenv("ID_GENERATOR_AUTH_CLIENT_SECRET", "") +ID_GENERATOR_AUTH_GRANT_TYPE = os.getenv("ID_GENERATOR_AUTH_GRANT_TYPE", "client_credentials") + + +class FallbackTable(models.Model): + _name = "g2p.reference_id.config" + _description = "G2P Reference ID Configuration" + + name = fields.Char() + base_api_url = fields.Char(default=ID_GENERATOR_API_BASE_URL) + auth_url = fields.Char(default=ID_GENERATOR_AUTH_URL) + auth_client_id = fields.Char(default=ID_GENERATOR_AUTH_CLIENT_ID) + auth_client_secret = fields.Char(default=ID_GENERATOR_AUTH_CLIENT_SECRET) + auth_grant_type = fields.Char(default=ID_GENERATOR_AUTH_GRANT_TYPE) + api_timeout = fields.Integer(default=10) + + access_token = fields.Char() + access_token_expiry = fields.Datetime() + + @api.model + def get_config(self): + return self.search([], limit=1) + + def get_access_token(self): + self.ensure_one() + + if self.access_token and self.access_token_expiry and self.access_token_expiry > datetime.utcnow(): + return self.access_token + + if not self.auth_url: + raise UserError(_("Authentication URL is not set")) + + headers = {"Content-Type": "application/json"} + data = { + "id": "string", + "version": "string", + "requesttime": "2024-07-11T05:10:53.449Z", + "metadata": {}, + "request": { + "clientId": self.auth_client_id, + "secretKey": self.auth_client_secret, + "appId": "idrepo", + }, + } + + response = httpx.post(self.auth_url, headers=headers, json=data, timeout=self.api_timeout) + _logger.debug("ID Generator Authentication API response: %s", response.text) + response.raise_for_status() + + access_token = response.cookies.get("Authorization") + token_exp = jwt.get_unverified_claims(access_token).get("exp") + + self.write( + { + "access_token": access_token, + "access_token_expiry": datetime.fromtimestamp(token_exp) + if isinstance(token_exp, int) + else datetime.fromisoformat(token_exp) + if isinstance(token_exp, str) + else token_exp, + } + ) + return access_token diff --git a/g2p_social_registry/models/region.py b/g2p_social_registry/models/region.py index 59a81ac..e89fa8f 100644 --- a/g2p_social_registry/models/region.py +++ b/g2p_social_registry/models/region.py @@ -1,4 +1,4 @@ -# Part of OpenG2P Registry. See LICENSE file for full copyright and licensing details. +# Part of OpenG2P. See LICENSE file for full copyright and licensing details. from odoo import fields, models diff --git a/g2p_social_registry/models/registrant.py b/g2p_social_registry/models/registrant.py index 8e6f45e..1788693 100644 --- a/g2p_social_registry/models/registrant.py +++ b/g2p_social_registry/models/registrant.py @@ -1,7 +1,57 @@ -from odoo import fields, models +import logging + +import httpx + +from odoo import api, fields, models + +_logger = logging.getLogger(__name__) class ResPartner(models.Model): _inherit = "res.partner" region = fields.Many2one("g2p.region") + ref_id = fields.Char(string="Reference ID", index=True) + + _sql_constraints = [ + ("ref_id_uniq", "UNIQUE(ref_id)", "ref_id is an unique identifier!"), + ] + + @api.model + def create(self, vals): + record = super().create(vals) + record.generate_ref_id() + return record + + def generate_ref_id(self): + for rec in self: + try: + config = self.env["g2p.reference_id.config"].get_config() + + access_token = config.get_access_token() + headers = {"Cookie": f"Authorization={access_token}"} + + response = httpx.get(config.base_api_url, headers=headers, timeout=config.api_timeout) + response.raise_for_status() + res = response.json() + + unique_id = res.get("response")["uin"] + rec.ref_id = rec.get_ref_id_prefix() + unique_id + + except Exception as e: + _logger.error("Failed to generate ref_id for partner %s: %s", rec.id, str(e)) + + pending_ref_id_model = self.env["g2p.pending.reference_id"].browse(rec.id) + + if not pending_ref_id_model.browse(rec.id): + pending_ref_id_model.create( + {"registrant_id": rec.id, "status": "under_process"} + ) + + def get_ref_id_prefix(self): + for rec in self: + if not rec.is_registrant: + return "" + if rec.is_group: + return "GRP" + return "IND" diff --git a/g2p_social_registry/models/res_config_settings.py b/g2p_social_registry/models/res_config_settings.py new file mode 100644 index 0000000..da3e9c7 --- /dev/null +++ b/g2p_social_registry/models/res_config_settings.py @@ -0,0 +1,49 @@ +# Part of OpenG2P. See LICENSE file for full copyright and licensing details. + +from odoo import api, fields, models + + +class RegistryConfig(models.TransientModel): + _inherit = "res.config.settings" + + id_generator_base_api_url = fields.Char() + id_generator_auth_url = fields.Char() + id_generator_auth_client_id = fields.Char() + id_generator_auth_client_secret = fields.Char() + id_generator_auth_grant_type = fields.Char() + id_generator_api_timeout = fields.Integer() + + def set_values(self): + res = super().set_values() + config = self.env["g2p.reference_id.config"].get_config() + + config.write( + { + "base_api_url": self.id_generator_base_api_url, + "auth_url": self.id_generator_auth_url, + "auth_client_id": self.id_generator_auth_client_id, + "auth_client_secret": self.id_generator_auth_client_secret, + "auth_grant_type": self.id_generator_auth_grant_type, + "api_timeout": self.id_generator_api_timeout, + } + ) + + return res + + @api.model + def get_values(self): + res = super().get_values() + config = self.env["g2p.reference_id.config"].get_config() + + res.update( + { + "id_generator_base_api_url": config.base_api_url, + "id_generator_auth_url": config.auth_url, + "id_generator_auth_client_id": config.auth_client_id, + "id_generator_auth_client_secret": config.auth_client_secret, + "id_generator_auth_grant_type": config.auth_grant_type, + "id_generator_api_timeout": config.api_timeout, + } + ) + + return res diff --git a/g2p_social_registry/security/ir.model.access.csv b/g2p_social_registry/security/ir.model.access.csv index fca2668..76b6797 100644 --- a/g2p_social_registry/security/ir.model.access.csv +++ b/g2p_social_registry/security/ir.model.access.csv @@ -1,3 +1,7 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink g2p_region_admin,Region Admin Access,g2p_social_registry.model_g2p_region,g2p_registry_base.group_g2p_admin,1,1,1,1 g2p_region_registrar,Region Registrar Access,g2p_social_registry.model_g2p_region,,1,0,0,0 +g2p_pending_reference_id_admin,Pending Reference ID Admin Access,g2p_social_registry.model_g2p_pending_reference_id,g2p_registry_base.group_g2p_admin,1,1,1,1 +g2p_pending_reference_id_registrar,Pending Reference ID Registrar Access,g2p_social_registry.model_g2p_pending_reference_id,,1,0,0,0 +g2p_reference_id_config_admin,Reference ID Config Admin Access,g2p_social_registry.model_g2p_reference_id_config,g2p_registry_base.group_g2p_admin,1,1,1,1 +g2p_reference_id_config_registrar,Reference ID Config Registrar Access,g2p_social_registry.model_g2p_reference_id_config,,1,0,0,0 diff --git a/g2p_social_registry/views/registrant_view.xml b/g2p_social_registry/views/registrant_view.xml index e524dc0..4fdf1ea 100644 --- a/g2p_social_registry/views/registrant_view.xml +++ b/g2p_social_registry/views/registrant_view.xml @@ -9,6 +9,9 @@ + + + @@ -19,9 +22,11 @@ - + + + diff --git a/g2p_social_registry/views/res_config_settings_view.xml b/g2p_social_registry/views/res_config_settings_view.xml new file mode 100644 index 0000000..49e41d6 --- /dev/null +++ b/g2p_social_registry/views/res_config_settings_view.xml @@ -0,0 +1,36 @@ + + + + + openg2p.res.config.settings.view.inherit.setup + res.config.settings + + + + + G2P Social Registry Settings + + + + + + + + + + + + + + + + + + + + + + + From ca9ea6f1f0db488f875e2354dc2595f52368569d Mon Sep 17 00:00:00 2001 From: mkumar-02 Date: Mon, 19 Aug 2024 21:45:55 +0530 Subject: [PATCH 2/5] Social Registry: Reference ID generation code refactor Signed-off-by: mkumar-02 --- g2p_social_registry/__init__.py | 4 +-- g2p_social_registry/models/pending_ref_id.py | 20 +++++++++++---- g2p_social_registry/models/registrant.py | 18 ++++++------- .../models/res_config_settings.py | 25 ++++++++++++++++++- g2p_social_registry/views/registrant_view.xml | 8 ++++++ .../views/res_config_settings_view.xml | 17 ++++++++++++- 6 files changed, 72 insertions(+), 20 deletions(-) diff --git a/g2p_social_registry/__init__.py b/g2p_social_registry/__init__.py index 4618ddb..9635e7d 100644 --- a/g2p_social_registry/__init__.py +++ b/g2p_social_registry/__init__.py @@ -5,6 +5,4 @@ def post_init_hook(env): partners = env["res.partner"].search([("is_registrant", "=", True), ("ref_id", "=", False)]) for partner in partners: - env["g2p.pending.reference_id"].create( - {"registrant_id": partner.id, "status": "under_process"} - ) + env["g2p.pending.reference_id"].create({"registrant_id": partner.id, "status": "failed"}) diff --git a/g2p_social_registry/models/pending_ref_id.py b/g2p_social_registry/models/pending_ref_id.py index 4d527d4..e66c015 100644 --- a/g2p_social_registry/models/pending_ref_id.py +++ b/g2p_social_registry/models/pending_ref_id.py @@ -10,17 +10,27 @@ class FallbackTable(models.Model): registrant_id = fields.Many2one("res.partner") ref_id = fields.Char() - status = fields.Selection( - [("under_process", "Under Process"), ("resolved", "Resolved")], default="under_process" - ) + status = fields.Selection([("failed", "Failed"), ("success", "Success")], default="failed") @api.model def retry_generate_ref_id(self): - records = self.search([("status", "=", "under_process")]) + records = self.search([("status", "=", "failed")]) for record in records: partner = record.registrant_id if partner: partner.generate_ref_id() if partner.ref_id: - record.status = "resolved" + record.status = "success" record.ref_id = partner.ref_id + + def generate_ref_id_for_selected(self): + for rec in self.env.context.get("active_ids"): + partner = self.env["res.partner"].browse(rec) + registrant = self.env["g2p.pending.reference_id"].search([("registrant_id", "=", rec)], limit=1) + + if not partner.ref_id: + partner.generate_ref_id() + + if partner.ref_id and registrant: + registrant.status = "success" + registrant.ref_id = partner.ref_id diff --git a/g2p_social_registry/models/registrant.py b/g2p_social_registry/models/registrant.py index 1788693..9b2e75f 100644 --- a/g2p_social_registry/models/registrant.py +++ b/g2p_social_registry/models/registrant.py @@ -27,31 +27,29 @@ def generate_ref_id(self): for rec in self: try: config = self.env["g2p.reference_id.config"].get_config() - + access_token = config.get_access_token() headers = {"Cookie": f"Authorization={access_token}"} - + response = httpx.get(config.base_api_url, headers=headers, timeout=config.api_timeout) response.raise_for_status() res = response.json() - + unique_id = res.get("response")["uin"] rec.ref_id = rec.get_ref_id_prefix() + unique_id except Exception as e: _logger.error("Failed to generate ref_id for partner %s: %s", rec.id, str(e)) - pending_ref_id_model = self.env["g2p.pending.reference_id"].browse(rec.id) + pending_ref_id_model = self.env["g2p.pending.reference_id"] - if not pending_ref_id_model.browse(rec.id): - pending_ref_id_model.create( - {"registrant_id": rec.id, "status": "under_process"} - ) + if not pending_ref_id_model.search([("registrant_id", "=", rec.id)]): + pending_ref_id_model.create({"registrant_id": rec.id, "status": "failed"}) def get_ref_id_prefix(self): for rec in self: if not rec.is_registrant: return "" if rec.is_group: - return "GRP" - return "IND" + return "GRP-" + return "IND-" diff --git a/g2p_social_registry/models/res_config_settings.py b/g2p_social_registry/models/res_config_settings.py index da3e9c7..186308e 100644 --- a/g2p_social_registry/models/res_config_settings.py +++ b/g2p_social_registry/models/res_config_settings.py @@ -1,6 +1,10 @@ # Part of OpenG2P. See LICENSE file for full copyright and licensing details. +import logging -from odoo import api, fields, models +from odoo import _, api, fields, models +from odoo.exceptions import UserError + +_logger = logging.getLogger(__name__) class RegistryConfig(models.TransientModel): @@ -47,3 +51,22 @@ def get_values(self): ) return res + + def add_missing_ref_id_to_retry(self): + query = """ + SELECT id FROM res_partner + WHERE is_registrant = TRUE AND ref_id is Null + """ + + pending_ref_id_model = self.env["g2p.pending.reference_id"] + + try: + self._cr.execute(query) # pylint: disable=sql-injection + + for rec in [record[0] for record in (self._cr.fetchall())]: + if not pending_ref_id_model.search([("registrant_id", "=", rec)], limit=1): + pending_ref_id_model.create({"registrant_id": rec, "status": "failed"}) + + except Exception as e: + _logger.error("Database Query Error: %s", e) + raise UserError(_("Database Query Error: %s") % e) from None diff --git a/g2p_social_registry/views/registrant_view.xml b/g2p_social_registry/views/registrant_view.xml index 4fdf1ea..852ba71 100644 --- a/g2p_social_registry/views/registrant_view.xml +++ b/g2p_social_registry/views/registrant_view.xml @@ -29,4 +29,12 @@ + + + Generate Reference ID + + + code + action = model.generate_ref_id_for_selected() + diff --git a/g2p_social_registry/views/res_config_settings_view.xml b/g2p_social_registry/views/res_config_settings_view.xml index 49e41d6..aaf20a0 100644 --- a/g2p_social_registry/views/res_config_settings_view.xml +++ b/g2p_social_registry/views/res_config_settings_view.xml @@ -13,7 +13,22 @@ G2P Social Registry Settings - + + +
+
+
From fb18f6a2ec923b4b7d108cf8a3dfc18dbf0f6cc0 Mon Sep 17 00:00:00 2001 From: mkumar-02 Date: Thu, 22 Aug 2024 14:29:46 +0530 Subject: [PATCH 3/5] SR Reference ID: Update authentication mechanism Signed-off-by: mkumar-02 --- g2p_social_registry/models/ref_id_config.py | 27 ++++++++------------- g2p_social_registry/models/registrant.py | 5 ++-- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/g2p_social_registry/models/ref_id_config.py b/g2p_social_registry/models/ref_id_config.py index 64f24ce..d8446b5 100644 --- a/g2p_social_registry/models/ref_id_config.py +++ b/g2p_social_registry/models/ref_id_config.py @@ -2,7 +2,7 @@ import os from datetime import datetime -import httpx +import requests from jose import jwt from odoo import _, api, fields, models @@ -11,13 +11,13 @@ _logger = logging.getLogger(__name__) ID_GENERATOR_API_BASE_URL = os.getenv( - "ID_GENERATOR_API_BASE_URL", "https://api-internal.dev.mosip.net/v1/idgenerator/uin" + "ID_GENERATOR_API_BASE_URL", "https://idgenerator.sandbox.net/v1/idgenerator/uin" ) ID_GENERATOR_AUTH_URL = os.getenv( "ID_GENERATOR_AUTH_URL", - "https://api-internal.dev.mosip.net/v1/authmanager/authenticate/clientidsecretkey", + "https://keycloak.openg2p.org/realms/master/protocol/openid-connect/token", ) -ID_GENERATOR_AUTH_CLIENT_ID = os.getenv("ID_GENERATOR_AUTH_CLIENT_ID", "mosip-idrepo-client") +ID_GENERATOR_AUTH_CLIENT_ID = os.getenv("ID_GENERATOR_AUTH_CLIENT_ID", "") ID_GENERATOR_AUTH_CLIENT_SECRET = os.getenv("ID_GENERATOR_AUTH_CLIENT_SECRET", "") ID_GENERATOR_AUTH_GRANT_TYPE = os.getenv("ID_GENERATOR_AUTH_GRANT_TYPE", "client_credentials") @@ -48,26 +48,19 @@ def get_access_token(self): return self.access_token if not self.auth_url: - raise UserError(_("Authentication URL is not set")) + raise UserError(_("ID Generator Authentication URL is not set")) - headers = {"Content-Type": "application/json"} data = { - "id": "string", - "version": "string", - "requesttime": "2024-07-11T05:10:53.449Z", - "metadata": {}, - "request": { - "clientId": self.auth_client_id, - "secretKey": self.auth_client_secret, - "appId": "idrepo", - }, + "grant_type": self.auth_grant_type, + "client_id": self.auth_client_id, + "client_secret": self.auth_client_secret, } - response = httpx.post(self.auth_url, headers=headers, json=data, timeout=self.api_timeout) + response = requests.post(self.auth_url, data=data, timeout=self.api_timeout) _logger.debug("ID Generator Authentication API response: %s", response.text) response.raise_for_status() - access_token = response.cookies.get("Authorization") + access_token = response.json().get("access_token", None) token_exp = jwt.get_unverified_claims(access_token).get("exp") self.write( diff --git a/g2p_social_registry/models/registrant.py b/g2p_social_registry/models/registrant.py index 9b2e75f..e44a277 100644 --- a/g2p_social_registry/models/registrant.py +++ b/g2p_social_registry/models/registrant.py @@ -1,6 +1,6 @@ import logging -import httpx +import requests from odoo import api, fields, models @@ -31,7 +31,8 @@ def generate_ref_id(self): access_token = config.get_access_token() headers = {"Cookie": f"Authorization={access_token}"} - response = httpx.get(config.base_api_url, headers=headers, timeout=config.api_timeout) + response = requests.get(config.base_api_url, headers=headers, timeout=config.api_timeout) + _logger.debug("ID Generator API response: %s", response.text) response.raise_for_status() res = response.json() From 0684fc7cdb9eac77e27a664a73be7d5b61942326 Mon Sep 17 00:00:00 2001 From: mkumar-02 Date: Thu, 22 Aug 2024 14:47:29 +0530 Subject: [PATCH 4/5] SR Reference ID: Removed ref_id field from UI. Stopped cron job Signed-off-by: mkumar-02 --- g2p_social_registry/data/cron_job.xml | 2 +- g2p_social_registry/views/registrant_view.xml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/g2p_social_registry/data/cron_job.xml b/g2p_social_registry/data/cron_job.xml index 61cc0c7..96cee2e 100644 --- a/g2p_social_registry/data/cron_job.xml +++ b/g2p_social_registry/data/cron_job.xml @@ -8,6 +8,6 @@ minutes -1 - + diff --git a/g2p_social_registry/views/registrant_view.xml b/g2p_social_registry/views/registrant_view.xml index 852ba71..ad13caa 100644 --- a/g2p_social_registry/views/registrant_view.xml +++ b/g2p_social_registry/views/registrant_view.xml @@ -9,9 +9,9 @@ - + @@ -24,9 +24,9 @@ - + From f11efc4c496f1cf5501ec4458809105f6f95bb86 Mon Sep 17 00:00:00 2001 From: mkumar-02 Date: Thu, 22 Aug 2024 15:09:18 +0530 Subject: [PATCH 5/5] SR Reference ID: Generate ID only when is_registrant flag is True --- g2p_social_registry/models/registrant.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/g2p_social_registry/models/registrant.py b/g2p_social_registry/models/registrant.py index e44a277..1514a64 100644 --- a/g2p_social_registry/models/registrant.py +++ b/g2p_social_registry/models/registrant.py @@ -20,7 +20,8 @@ class ResPartner(models.Model): @api.model def create(self, vals): record = super().create(vals) - record.generate_ref_id() + if vals.get("is_registrant"): + record.generate_ref_id() return record def generate_ref_id(self):