i keep getting an invalid move id because of the move_line.write code here.
needing help, i don't understand what i'm missing or doing wrong:
`
def update_move_lines(self, move_id, **kwargs) -> http.Response:
line_data = json.loads(http.request.httprequest.data)
try:
move_id = int(move_id)
move = http.request.env['stock.move'].browse(move_id)
if not move:
raise UserError("Stock Move not found.")
existing_lines = move.move_line_ids
existing_index = 0
for line_vals in line_data:
quantity_done = line_vals.get('quantity')
destination_package_id = line_vals.get('destination_package_id')
if existing_index (less than or equal) len(existing_lines) - 1:
move_line = http.request.env['stock.move.line'].browse(existing_lines[existing_index].id)
move_line.write({ 'qty_done': quantity_done, 'result_package_id': destination_package_id })
existing_index += 1
logging.info('update_here')
else:
logging.info('create here')
return response_template(status_code=200, status="success", data=line_data)
except ValueError:
raise UserError("Invalid Move ID.")