Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2120 Zobrazení

I figured out why it wasn't saving, but I didn't understand why.


Why Substation is linked to its parent (plant_poi_id) when saving, but Energy Meter is not (substation_id)? Although they are identical.


For example, substation doesn’t have plant_id, but it’s okay, because his parent has, so we have a “tree tie”:

Substation create {'name': 'dasdasdas', 'plant_id': False, 'plant_poi_id': 38, 'signals': False, 'latitude': 0, 'longitude': 0, 'altitude': 0, 'tracker_ids': [], 'meteorological_data_ids': [], 'transformer_ids': [], 'first_child_energy_meter_ids': [[0, 'virtual_5', {'name': 'zzxxccdsa', 'external_source_id': False, 'latitude': 0, 'longitude': 0, 'altitude': 0, 'plant_id': False, 'substation_id': False, 'transformer_id': False, 'signals': False, 'inverter_ids': [[0, 'virtual_6', {'name': 'dasdsds', 'external_source_id': False, 'inverter_type_id': 2, 'ppc_id': False, 'plant_id': False, 'substation_id': False, 'transformer_id': False, 'energy_meter_id': False, 'latitude': 0, 'longitude': 0, 'altitude': 0, 'signals': False, 'string_box_ids': [], 'string_ids': [], 'inverter_module_ids': []}]]}]], 'first_child_inverter_ids': [[0, 'virtual_7', {'name': 'dsadsads', 'external_source_id': False, 'inverter_type_id': 2, 'ppc_id': False, 'plant_id': False, 'substation_id': False, 'transformer_id': False, 'energy_meter_id': False, 'latitude': 0, 'longitude': 0, 'altitude': 0, 'signals': False, 'string_box_ids': [], 'string_ids': [], 'inverter_module_ids': []}]]}

But energy meter doesn’t have attachment to any models:

EnergyMeter {'_id': '64b1c148ac27cd4b8f52c13f', 'name': 'zzxxccdsa', 'external_source_id': False, 'latitude': 0.0, 'longitude': 0.0, 'altitude': 0.0, 'plant_id': False, 'substation_id': False, 'transformer_id': False, 'inverter_ids': [], 'signals': False, 'id': , '__last_update': datetime.datetime(2023, 7, 14, 21, 42, 32), 'display_name': 'zzxxccdsa', 'create_uid': res.users(), 'create_date': False, 'write_uid': res.users(), 'write_date': False}


Avatar
Zrušit
Autor

Okay, this method doesn't work because sometimes (not always) the parent is created later than the child. And when created, the child does not get the parent's id.

Maybe I can do it by JS? Or change the save queue.

Related Posts Odpovědi Zobrazení Aktivita
0
srp 23
3094
0
bře 23
2734
8
dub 25
13136
2
dub 24
3453
0
zář 23
1630