Skip to content

Commit

Permalink
Merge pull request #31 from mkumar-02/17.0-develop
Browse files Browse the repository at this point in the history
G2P-2707: ID Deduplication: Remove ID Type from config when deleted
  • Loading branch information
shibu-narayanan authored Aug 11, 2024
2 parents bde9fea + 3678514 commit e9a68b5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 112 deletions.
110 changes: 0 additions & 110 deletions g2p_registration_portal_user/i18n/g2p_registration_portal_user.pot

This file was deleted.

4 changes: 2 additions & 2 deletions g2p_registry_id_deduplication/models/registrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from odoo import _, fields, models
from odoo.exceptions import UserError
from odoo.tools import safe_eval

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -108,8 +109,7 @@ def get_id_types_with_kind(self, id_field, is_group):
ir_config = self.env["ir.config_parameter"].sudo()
id_type_ids_str = ir_config.get_param(f"g2p_registry_id_deduplication.{id_field}", default=None)

id_type_ids = id_type_ids_str.strip("][").split(", ") if id_type_ids_str is not None else [""]
id_type_ids = id_type_ids if len(id_type_ids[0]) != 0 else []
id_type_ids = safe_eval.safe_eval(id_type_ids_str)

if len(id_type_ids) < 1:
raise UserError(_("Deduplication is not configured"))
Expand Down
26 changes: 26 additions & 0 deletions g2p_registry_id_deduplication/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,29 @@ def get_values(self):
else None,
)
return res


class G2PIDType(models.Model):
_inherit = "g2p.id.type"

def unlink(self):
ids_to_delete = self.ids

res = super().unlink()

ir_config = self.env["ir.config_parameter"].sudo()
ind_id_types_param = ir_config.get_param(
"g2p_registry_id_deduplication.ind_deduplication_id_types_ids"
)

if ind_id_types_param:
ind_id_types_ids = safe_eval.safe_eval(ind_id_types_param)
updated_ind_id_types_ids = [
id_type for id_type in ind_id_types_ids if id_type not in ids_to_delete
]
ir_config.set_param(
"g2p_registry_id_deduplication.ind_deduplication_id_types_ids",
updated_ind_id_types_ids,
)

return res

0 comments on commit e9a68b5

Please sign in to comment.