Skip to content

Commit fc01acc

Browse files
committed
[FIX] l10n_es_aeat: Remove unneeded computed fields from real estate model
1 parent b6b5c56 commit fc01acc

2 files changed

Lines changed: 4 additions & 33 deletions

File tree

l10n_es_aeat/models/l10n_es_aeat_real_estate.py

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -85,28 +85,8 @@ class L10nEsAeatRealEstate(models.Model):
8585
)
8686
state_id = fields.Many2one(
8787
comodel_name="res.country.state",
88-
compute="_compute_state_id",
89-
readonly=False,
90-
store=True,
91-
)
92-
state_code = fields.Char(
93-
compute="_compute_state_code",
94-
store=True,
95-
readonly=False,
96-
compute_sudo=True,
97-
)
98-
city_id = fields.Many2one(
99-
comodel_name="res.city",
100-
string="City ID",
101-
index=True,
102-
compute="_compute_city_id",
103-
readonly=False,
104-
store=True,
10588
)
10689
city = fields.Char(
107-
compute="_compute_city",
108-
store=True,
109-
readonly=False,
11090
size=30,
11191
required=True,
11292
)
@@ -153,20 +133,12 @@ def _compute_representative_vat(self):
153133
for record in self:
154134
record.representative_vat = record.partner_id.vat
155135

156-
@api.depends("city_id")
157-
def _compute_city(self):
158-
for record in self:
159-
if record.city_id and record.city_id.name:
160-
record.city = record.city_id.name
161-
else:
162-
record.city = ""
163-
164-
@api.depends("state_code")
136+
@api.depends("state_id")
165137
def _compute_check_ok(self):
166138
self.update({"check_ok": False, "error_text": False})
167139
for record in self:
168140
errors = []
169-
if not record.state_code:
141+
if not record.state_id:
170142
errors.append(self.env._("Without state"))
171143
record.check_ok = not bool(errors)
172144
record.error_text = bool(errors) and ", ".join(errors)

l10n_es_aeat/tests/test_l10n_es_aeat_real_estate.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,18 @@ def test_check_reference_constraint(self):
177177
)
178178

179179
def test_compute_check_ok(self):
180-
# Sin state_code → check_ok=False
180+
# Sin state_id → check_ok=False
181181
rec_no_state = self.env["l10n.es.aeat.real_estate"].create(
182182
self._base_vals("Sin estado")
183183
)
184184
self.assertFalse(rec_no_state.check_ok)
185185
self.assertTrue(rec_no_state.error_text)
186186

187-
# Con state_code → check_ok=True
187+
# Con state_id → check_ok=True
188188
rec_with_state = self.env["l10n.es.aeat.real_estate"].create(
189189
{
190190
**self._base_vals("Con estado"),
191191
"state_id": self.env.ref("base.state_es_m").id,
192-
"state_code": "28",
193192
}
194193
)
195194
self.assertTrue(rec_with_state.check_ok)

0 commit comments

Comments
 (0)