Skip to content

Commit

Permalink
[FIX] spp_area_base: Fix SonarQube reported errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalesedwin1123 committed Feb 13, 2025
1 parent 642ec0b commit c3090e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 0 additions & 2 deletions spp_area_base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@


from . import models

# from . import controllers
14 changes: 7 additions & 7 deletions spp_area_base/models/area.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class OpenSPPArea(models.Model):
_parent_store = True
_order = "parent_id,name"

parent_id = fields.Many2one("spp.area", "Parent")
parent_id = fields.Many2one(_name, "Parent")
complete_name = fields.Char(compute="_compute_complete_name", recursive=True, translate=True)
name = fields.Char(translate=True, compute="_compute_name", store=True)
draft_name = fields.Char(required=True, translate=True)
Expand All @@ -32,7 +32,7 @@ class OpenSPPArea(models.Model):
altnames = fields.Char("Alternate Name")
level = fields.Integer(help="This is the area level for importing")
area_level = fields.Integer(compute="_compute_area_level", store=True, help="This is the main area level")
child_ids = fields.One2many("spp.area", "id", "Child", compute="_compute_get_childs")
child_ids = fields.One2many(_name, "id", "Child", compute="_compute_get_childs")
kind = fields.Many2one("spp.area.kind")
area_sqkm = fields.Float("Area (sq/km)")

Expand Down Expand Up @@ -67,7 +67,7 @@ def _compute_get_childs(self):
and assigns them to the child_ids field.
"""
for rec in self:
child_ids = self.env["spp.area"].search([("parent_id", "=", rec.id)])
child_ids = self.env[self._name].search([("parent_id", "=", rec.id)])
rec.child_ids = child_ids

@api.depends("parent_id")
Expand Down Expand Up @@ -139,7 +139,7 @@ def create(self, vals):
area_code = self.code
if "code" in vals:
area_code = vals["code"]
curr_area = self.env["spp.area"].search(
curr_area = self.env[self._name].search(
[
("name", "=", area_name),
("code", "=", area_code),
Expand Down Expand Up @@ -184,7 +184,7 @@ def write(self, vals):
area_code = rec.code
if "code" in vals:
area_code = vals["code"]
curr_area = self.env["spp.area"].search(
curr_area = self.env[self._name].search(
[
("name", "=", area_name),
("code", "=", area_code),
Expand All @@ -206,7 +206,7 @@ def open_area_form(self):
return {
"name": "Area",
"view_mode": "form",
"res_model": "spp.area",
"res_model": self._name,
"res_id": rec.id,
"view_id": self.env.ref("spp_area_base.view_spparea_form").id,
"type": "ir.actions.act_window",
Expand Down Expand Up @@ -267,7 +267,7 @@ def unlink(self):
if external_identifier and external_identifier.name:
raise ValidationError(_("Can't delete default Area Type"))
else:
areas = self.env["spp.area"].search([("kind", "=", rec.id)])
areas = self.env[self._name].search([("kind", "=", rec.id)])
if areas:
raise ValidationError(_("Can't delete used Area Type"))
else:
Expand Down

0 comments on commit c3090e7

Please sign in to comment.