Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1704 Lượt xem

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}


Ảnh đại diện
Huỷ bỏ
Tác giả

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.

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 8 23
2588
0
thg 3 23
2320
8
thg 4 25
11797
2
thg 4 24
2830
0
thg 9 23
1243