Skip to content

Commit e477cfc

Browse files
[FIX] spp_code_generator: use write method in compute fields to prevent raised issues during compute field updating
1 parent 20d9d5a commit e477cfc

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

spp_code_generator/models/code_generator.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,28 +283,26 @@ def _generate_compute_method_code(self, field_name, expression, indicator_type,
283283
try:
284284
if record.is_group:
285285
# This is an individual indicator, skip groups
286-
record.{field_name} = None
286+
record.write({{'{field_name}': None}})
287287
continue
288288
289289
# Execute CEL expression using _exec helper
290290
result = record._exec(
291291
'''{expression}''',
292292
profile='registry_individuals'
293293
)
294-
295-
# Check if current record matches the expression
296294
"""
297295
if field_type == "integer":
298296
code += f"""
299-
record.{field_name} = result
297+
record.write({{'{field_name}': result}})
300298
"""
301299
else:
302300
code += f"""
303-
record.{field_name} = bool(record.id in result.get('ids', []))
301+
record.write({{'{field_name}': bool(record.id in result.get('ids', []))}})
304302
"""
305303
code += f"""
306304
except Exception as e:
307-
record.{field_name} = None
305+
record.write({{'{field_name}': None}})
308306
"""
309307
return code
310308

0 commit comments

Comments
 (0)